added check accepted or not before sending request
This commit is contained in:
@@ -4,6 +4,7 @@ from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.pojo.contact_pojo import ContactPojo
|
||||
|
||||
SEVEN_DAYS_IN_S = 7 * 24 * 3600
|
||||
TWO_WEEKS_IN_S = 2 * SEVEN_DAYS_IN_S
|
||||
|
||||
|
||||
def is_already_sent(contact: ContactPojo) -> bool:
|
||||
@@ -24,5 +25,22 @@ def is_in_white_list(contact: ContactPojo) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def is_in_accepted_list(contact: ContactPojo) -> bool:
|
||||
accepted_appointment_list = MONGO_STORE_MANAGER.get_all_accepted_appointments()
|
||||
for accepted_contact in accepted_appointment_list:
|
||||
if contact.mail == accepted_contact.email:
|
||||
# check date
|
||||
return accepted_contact.accepted_at + TWO_WEEKS_IN_S > time.time()
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def can_send_request(contact: ContactPojo) -> bool:
|
||||
return is_in_white_list(contact) and (not is_already_sent(contact=contact))
|
||||
return is_in_white_list(contact) and (not is_already_sent(contact=contact)) and (
|
||||
not is_in_accepted_list(contact=contact))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
contact = ContactPojo(phone_number='605764105', passport_number='23023672', last_name='Jia', first_name='Roujin',
|
||||
mail='alanobierx@hotmail.com')
|
||||
print(can_send_request(contact))
|
||||
|
||||
Reference in New Issue
Block a user