Exemplo n.º 1
0
 def find_all_events_in_range(self):
     lower = datetime.now()
     upper = datetime(lower.year + 1, lower.month, lower.day)
     all_clients = self.get_all_clients()
     filtered = []
     for client in all_clients:
         date = DateHelper.get_date_from_string(client[3])
         if lower < date < upper:
             filtered.append(client)
     return filtered
Exemplo n.º 2
0
 def find_all_events_for_day(self, dt: datetime):
     all_busy_hours = []
     all_clients = self.get_all_clients()
     for client in all_clients:
         date = DateHelper.get_date_from_string(client[3])
         if date.year == dt.year and date.month == dt.month and date.day == dt.day:
             lower = client[4]
             upper = client[5]
             session_hours = [x for x in range(lower, upper)]
             all_busy_hours = all_busy_hours + session_hours
     available_hours = DateHelper.return_available_hours(all_busy_hours)
     print(f"Available hours are: {available_hours}")
     return available_hours
Exemplo n.º 3
0
 def check_if_user_has_appointment(self, user_id: int):
     clients = self.get_all_clients()
     if not clients:
         return False
     client = list(filter(lambda x: x[0] == user_id, clients))
     if not client:
         return False
     client = client[0]
     session_date = client[3]
     session_start = client[4]
     dt = DateHelper.get_date_from_string(session_date)
     registration_date = datetime(dt.year, dt.month, dt.day,
                                  int(session_start))
     current_date = datetime.now()
     if registration_date < current_date:
         self.delete_the_user(user_id)
         return False
     if registration_date > current_date:
         return True
     return False