From 671ce2a31279ae502da2cbff9cf52d39e5f56853 Mon Sep 17 00:00:00 2001 From: Nathan <Nathan.baker303@gmail.com> Date: Sun, 10 Nov 2024 09:10:44 +0000 Subject: [PATCH] updated user classes --- .idea/git_toolbox_prj.xml | 15 +++++++++++ GUI.py | 6 ++--- main.py | 57 +++++++++++++++++++++------------------ src/adminUser.py | 4 +-- src/cinemaObj.py | 11 ++++++-- src/managerUser.py | 4 +-- src/staffUser.py | 39 ++++++++++++++++++--------- 7 files changed, 88 insertions(+), 48 deletions(-) create mode 100644 .idea/git_toolbox_prj.xml diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml new file mode 100644 index 0000000..02b915b --- /dev/null +++ b/.idea/git_toolbox_prj.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="GitToolBoxProjectSettings"> + <option name="commitMessageIssueKeyValidationOverride"> + <BoolValueOverride> + <option name="enabled" value="true" /> + </BoolValueOverride> + </option> + <option name="commitMessageValidationEnabledOverride"> + <BoolValueOverride> + <option name="enabled" value="true" /> + </BoolValueOverride> + </option> + </component> +</project> \ No newline at end of file diff --git a/GUI.py b/GUI.py index f69e760..8a45610 100644 --- a/GUI.py +++ b/GUI.py @@ -1,5 +1,5 @@ from tkinter import Tk, Frame, Label, Entry, Button, messagebox -from .main import * +from main import * # Initialize main window window = Tk() @@ -60,9 +60,9 @@ def gui_login(): messagebox.showinfo("Login", "Login successful!") # function call "loginAttempt()" from main.py user = None - while user == None: + while user is None: user = loginAttempt(username=username, password=password) - if user != None: + if user: break # Make rows and columns in the main window expand to center the form frame diff --git a/main.py b/main.py index 0a76411..e74890a 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ import logging -logging.basicConfig(level=logging.DEBUG, format="{asctime} - {levelname} - {message}", style="{", datefmt="%Y-%m-%d %H:%M") +logging.basicConfig(level=0, format="{asctime} - {levelname} - {message}", style="{", datefmt="%Y-%m-%d %H:%M") from src import * """_summary_ @@ -32,74 +32,74 @@ def loginAttempt(username: str, password: str) -> StaffUser | ManagerUser | Admi return del_later def staffUser_options_cli(user:StaffUser) -> None: - selection = True - while selection: - selection = input("Menu options:\n" + case = True + while case: + case = input("Menu options:\n" " 1. View Listings \n" " 2. Create booking \n" " 3. Logout \n" " please return a number to select: ") # switch case: - if selection == "1": + if case == "1": logging.debug("selection 1, View listings") user.viewFilmListings() # get from cinema the listings and display film data in dict/jason # user.viewFilmListings() # format and display data - elif selection == "2": + elif case == "2": logging.debug("selection 2, Create booking") # create booking obj and display attributes for selection # save booking to cinema and db # user.createBooking() - elif selection == "3": + elif case == "3": logging.debug("selection 3, logout") user.logout() exit() else: print("Invalid input, please input an integer value corresponding with an option.") - selection = True + case = True def managerUser_options_cli(user:ManagerUser) -> None: - selection = True - while selection: - selection = input("Menu options:\n" + case = True + while case: + case = input("Menu options:\n" " 1. View Listings \n" " 2. Create booking \n" " 3. Logout \n" " please return a number to select: ") # switch case: - if selection == "1": + if case == "1": logging.debug("selection 1, View listings") - elif selection == "2": + elif case == "2": logging.debug("selection 2, Create booking") - elif selection == "3": + elif case == "3": logging.debug("selection 3, logout") user.logout() exit() else: print("Invalid input, please input an integer value corresponding with an option.") - selection = False + case = False def adminUser_options_cli(user:AdminUser) -> None: - selection = True - while selection: - selection = input("Menu options:\n" + case = True + while case: + case = input("Menu options:\n" " 1. View Listings \n" " 2. Create booking \n" " 3. Logout \n" " please return a number to select: ") # switch case: - if selection == "1": + if case == "1": logging.debug("selection 1, View listings") - elif selection == "2": + elif case == "2": logging.debug("selection 2, Create booking") - elif selection == "3": + elif case == "3": logging.debug("selection 3, logout") user.logout() exit() else: print("Invalid input, please input an integer value corresponding with an option.") - selection = False + case = False def load_cinema(cinemaID) -> Cinema: pass @@ -114,6 +114,10 @@ def san(string:str) -> str: """ return string.strip().replace('/', '_').replace('\\', '_') +def encrypt(string:str) -> str: + # add encryption when necessary + return string + def save(): pass @@ -125,14 +129,14 @@ def main_cli() -> None: # exit() user = None while user is None: - username = str(input("To login please enter your\nUsername: ")) - password = str(input("Password: ")) + username = encrypt(san(str(input("To login please enter your credentials.\nUsername: ")))) + password = encrypt(san(str(input("Password: ")))) user = loginAttempt(username=username, password=password) if user is None: print("Login attempt failed please try again.") else: break - print("successful login, loading menu...") + logging.info("successful login, loading menu...") user.login() if user.permissionLevel == 1: @@ -144,4 +148,5 @@ def main_cli() -> None: # following code will only execute if run directly from this file. if __name__ == "__main__": - main_cli() \ No newline at end of file + main_cli() + logging.debug("main_cli finished, program exiting. bye bye!") diff --git a/src/adminUser.py b/src/adminUser.py index 98f08a2..069c0d7 100644 --- a/src/adminUser.py +++ b/src/adminUser.py @@ -1,6 +1,6 @@ -from . import staffUser +from .staffUser import StaffUser -class AdminUser(staffUser.StaffUser): +class AdminUser(StaffUser): """_summary_ Args: diff --git a/src/cinemaObj.py b/src/cinemaObj.py index e0f670c..84a7037 100644 --- a/src/cinemaObj.py +++ b/src/cinemaObj.py @@ -9,10 +9,17 @@ class Cinema(object): object (_type_): _description_ """ def __init__(self, id:int=0) -> None: + self.cinema_id = id self.listings = [] self.screens = [] - + if id != 0: + self.load() + + def load(self) -> None: + """load cinema from database""" + pass + def create_screen(self): obj_screen = Screen(capacity=0, sizeH=19,sizeW=16,resolutionH=1080,resolutionW=1920,isIMAX=False) # add screen to db @@ -24,7 +31,7 @@ class Cinema(object): def get_listings(self): # return listing if dict/jason format? - pass + return self.listings def addListing(self, movieID): # get movie details via movieId diff --git a/src/managerUser.py b/src/managerUser.py index 934a4db..1b947fa 100644 --- a/src/managerUser.py +++ b/src/managerUser.py @@ -1,6 +1,6 @@ -from . import adminUser +from .adminUser import AdminUser -class ManagerUser(adminUser.AdminUser): +class ManagerUser(AdminUser): """ Args: diff --git a/src/staffUser.py b/src/staffUser.py index eed2bbe..c313fb3 100644 --- a/src/staffUser.py +++ b/src/staffUser.py @@ -1,12 +1,15 @@ +import logging import random +from .cinemaObj import Cinema + class StaffUser(object): def __init__(self): self.userID:int = 0 - self.userName:str = self.encrypt("") - self.userPass:str = self.encrypt("") + self.userName:str = "" + self.userPass:str = "" self.permissionLevel:int = 0 self.cinemas = [0] @@ -28,26 +31,36 @@ class StaffUser(object): # """ # options:dict = {"View film Listings":self.viewFilmListing, "Create booking":self.createBooking, "Logout":self.logout} # return options - + + def save(self): + """save self to db.""" + def login(self): - print("this is the login func") - + logging.debug(f"user {self.userID} logging in.") + def logout(self): - pass + logging.debug(f"user {self.userID} logging out.") + self.save() def viewFilmListings(self): - print("this is the viewFilmListing func") - # load cinema.showings - listing_format = f"" + logging.debug("this is the viewFilmListing func") + cinema = Cinema(id=1) + for i in cinema.get_listings(): + # will need formating + print(f"listing:{i}") + + case = input("Options: 1-exit, 2-move to create booking, 3-logout\n: ") + if case == "2": + self.createBooking() + elif case == "3": + self.logout() def createBooking(self): - print("this is the createBooking func") + logging.debug("this is the createBooking func") def manageBooking(self): pass - - def encrypt(self, inputString): - return inputString + -- GitLab