diff --git a/services.py b/services.py index d0e485c..72f4653 100644 --- a/services.py +++ b/services.py @@ -51,6 +51,8 @@ class Services: self.cursor.execute(query) def AddService(self, date, groups): + if(date < datetime.datetime.now()): + return "You cant add a date in the past" query = f""" INSERT INTO services (date, groups) VALUES('{date}', '{groups}'); @@ -70,6 +72,17 @@ class Services: self.cursor.execute(query) self.db.commit() + def CleanServices(self): + """ + Remove all services that are in the past + """ + ser = self.GetAllServices() + for i in ser: + if(ser[i][0] < datetime.datetime.now()): + #delete service that lives in the past + self.RemoveService(ser[i][0]) + + class UserManager(): def __init__(self, db) -> None: self.db = db @@ -126,9 +139,9 @@ if __name__ == "__main__": ser = Services(db) us = UserManager(db) - us.AddUser("Eljakim", "Kunnenwe?") + # us.AddUser("Eljakim", "Kunnenwe?") us.Authenticate("Eljakim", "Kunnenwe?") - us.Authenticate("Eljakim", "Kunnenwe2?") + ser.CleanServices() # for i in range(100): # d = datetime.datetime.now() # d = d.replace(hour=random.randint(1, 23), day = random.randint(1, 28), month = random.randint(1, 12)) diff --git a/sqlite.db b/sqlite.db index 9caeaeb..37ba680 100644 Binary files a/sqlite.db and b/sqlite.db differ