diff --git a/main.py b/main.py index d1e027e7bc07690765f799668cc77b8b2d1854f4..85cca5102567bd2baee919db490681eef8e34563 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,7 @@ def loginAttempt(username: str, password: str) -> StaffUser | ManagerUser | Admi StaffUser | ManagerUser | AdminUser | None: returns user object or NoneType if login unsucssesfull. """ # get permissionLevel and user_id where username and password are match. - conditon = json.loads(select_from_tbl_where("tblUsers", f"userName='{username}' AND userPass='{password}'", "permissionLevel")) # condition is a 2 item dict. + conditon = json.loads(select_from_tbl_where("tblUsers", f"userName='{username}' AND userPass='{password}'", "permissionLevel")) # returns a dict with args to be used in condition switch. # based on permissonLevel create the relevant user class object. match conditon['permissionLevel']: @@ -139,15 +139,15 @@ def encrypt(string:str) -> str: def main_cli() -> None: print("\n\nSTARTING CINEMA MANAGEMENT SYSTEM.\n\n") # test db is connected.... -# if not getConnection(): -# logging.critical("Database cannot connect, or dose not exist. \nClosing application.") -# exit() + #if not getConnection(): + # logging.critical("Database cannot connect, or dose not exist. \nClosing application.") + # exit() print("To login please enter your credentials.\n") while True: username = encrypt(sanitize(input("Username: "))) password = encrypt(sanitize(input("Password: "))) #user = loginAttempt(username=username, password=password) - user = ManagerUser() # dev remove later + user = ManagerUser(impBool=1) # dev remove later if user is None: print("Login attempt failed please try again.") else: diff --git a/src/__pycache__/staffUser.cpython-312.pyc b/src/__pycache__/staffUser.cpython-312.pyc index 7646ac2ece181c549112fca4ccf3c14f045548b3..4988db65302ceac12f65b8e5218373debd4dc439 100644 Binary files a/src/__pycache__/staffUser.cpython-312.pyc and b/src/__pycache__/staffUser.cpython-312.pyc differ diff --git a/src/staffUser.py b/src/staffUser.py index 4cf93e0668b120cf804675019fbd3b52ece7407f..27e217a97b3d5a6a74547b50801e1b6c91e0c866 100644 --- a/src/staffUser.py +++ b/src/staffUser.py @@ -6,15 +6,21 @@ from .cinemaObj import Cinema # trying to make this a base implementation for all user classes. class StaffUser(object): - def __init__(self): - # staff id number assigned by manager during onboarding. - self.userID:int = 0 - self.userName:str = "" - self.userPass:str = "" - # staff software level. - self.permissionLevel:int = 0 - # list of branches active at. - self.cinemas = [] + def __init__(self, id:int, name:str, passw:str, permLvl:int, cinemas:list, impBool:bool=0): + # impbool used to switch case on a newly created user or imported from database. + if impBool: + # import user from db + select_from_tbl_where(table="tblUsers", condition="") + pass + else: + # staff id number assigned by manager during onboarding. + self.userID:int = id + self.userName:str = name + self.userPass:str = passw + # staff software level. + self.permissionLevel:int = permLvl + # list of branches active at. + self.cinemas = cinemas def __str__(self): return f"{self.__class__.__name__} user object(userID={self.userID}, userName={self.userName}, userPass={self.userPass}, permissionLevel={self.permissionLevel})"