Merge branch 'feature/black_list' into feature/pyapp
# Conflicts: # src/db/mongo_manager.py # src/pojo/black_contact.py
This commit is contained in:
+19
-4
@@ -2,12 +2,13 @@ import datetime
|
||||
import logging
|
||||
|
||||
from pymongo import MongoClient
|
||||
|
||||
from src.pojo.ReserveResultPojo import ReserveResultPojo
|
||||
from src.pojo.contact_pojo import ContactPojo
|
||||
from pojo.ReserveResultPojo import ReserveResultPojo
|
||||
from pojo.black_contact import BlackContactPojo
|
||||
from pojo.contact_pojo import ContactPojo
|
||||
|
||||
MONGO_DB_URL = "mongo.lpaconsulting.fr"
|
||||
CAPTCHA_ERROR_COLLECTION_PREFIX = "CAPTCHA_ERROR_"
|
||||
BLACK_LIST = "BLACK_LIST"
|
||||
|
||||
|
||||
class MongoDbManager:
|
||||
@@ -38,6 +39,18 @@ class MongoDbManager:
|
||||
except Exception as error:
|
||||
self.logger.info(error)
|
||||
|
||||
def insert_blacklist_contact(self, contact: ContactPojo):
|
||||
collection_name = BLACK_LIST
|
||||
black_contact = BlackContactPojo(contact.phone, contact.passport, contact.last_name, contact.first_name,
|
||||
contact.mail)
|
||||
try:
|
||||
collection_to_use = self.db[collection_name]
|
||||
collection_to_use.replace_one(filter={'_id': black_contact.mail, },
|
||||
replacement=black_contact.to_firestore_dict(),
|
||||
upsert=True)
|
||||
except Exception as error:
|
||||
self.logger.info(error)
|
||||
|
||||
def get_captcha_error_contacts_for_current_day(self) -> list:
|
||||
day = str(datetime.date.today())
|
||||
collection_name = CAPTCHA_ERROR_COLLECTION_PREFIX + day
|
||||
@@ -60,4 +73,6 @@ class MongoDbManager:
|
||||
|
||||
if __name__ == '__main__':
|
||||
db_manager = MongoDbManager()
|
||||
print(db_manager.get_captcha_error_contacts_for_current_day())
|
||||
contact = ContactPojo(phone_number='0755667750', passport_number='123456789', last_name='PAN', first_name='Lei',
|
||||
mail='panleicim@gmail.com')
|
||||
print(db_manager.insert_blacklist_contact(contact))
|
||||
|
||||
Reference in New Issue
Block a user