diff --git a/Diagrams/Class_Diagram.asta b/Diagrams/Class_Diagram.asta index 30b621abdd575ea99de2c6a14af8055852341808..380f0f83d9eaacf79b268d7bc5aadb7e68d78f3d 100644 Binary files a/Diagrams/Class_Diagram.asta and b/Diagrams/Class_Diagram.asta differ diff --git a/GUI.py b/GUI.py index c555654617472306651b38950ed243f0b3762cee..8707a9766399995411bfb7065a6df8889a4f0891 100644 --- a/GUI.py +++ b/GUI.py @@ -49,16 +49,20 @@ def apply_theme(): theme_toggle_button.configure(bg=current_theme["button_bg"], fg=current_theme["button_fg"]) # Handle login action -def login(): +def gui_login(): username = username_entry.get() password = password_entry.get() # check form not empty if not username or not password: messagebox.showwarning("Warning", "Please fill in both fields.") - else: - + # escape function + else: # remove else and message box when login function is finished. messagebox.showinfo("Login", "Login successful!") - + # function call "loginAttempt()" from main.py + user = loginAttempt(username=username, password=password) + if user == None: + # escape function + pass # Make rows and columns in the main window expand to center the form frame window.grid_rowconfigure(0, weight=1) @@ -76,7 +80,7 @@ username_label = Label(form_frame, text="Username", fg=current_theme["fg"], bg=c username_entry = Entry(form_frame, width=25, bg=current_theme["entry_bg"], fg=current_theme["entry_fg"]) password_label = Label(form_frame, text="Password", fg=current_theme["fg"], bg=current_theme["bg"]) password_entry = Entry(form_frame, show="*", width=25, bg=current_theme["entry_bg"], fg=current_theme["entry_fg"]) -login_button = Button(form_frame, text="Login", command=login, bg=current_theme["button_bg"], fg=current_theme["button_fg"], width=20) +login_button = Button(form_frame, text="Login", command=gui_login, bg=current_theme["button_bg"], fg=current_theme["button_fg"], width=20) # Button for Light/Dark Mode theme_toggle_button = Button(form_frame, text="Toggle Light/Dark Mode", command=toggle_theme, diff --git a/main.py b/main.py index 905ec359c27776998efa68a26ffca36c54747969..fce1bf12866eef9516ade71c3711485d3274c5ec 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,11 @@ from src import * -""" -_summary_ +"""_summary_ + - logic should be seprate from the GUI - this file handles interfacing with the database and classes. +- most functionalisty should also be here +- using main() as a test function during development, and after can be used as a CLI version of the program. 'idealy there should be a sort of intermeditary between the GUI and database, for example last year most groups queried the database directly from tkintet, although thats not ideal.' - lecturer idk there name 'you should be able to make python classes directly from your class diagram' - same lecturer @@ -11,15 +13,39 @@ _summary_ """ +def loginAttempt(username, password): + """_summary_ + quereies database for matching args + returns user(staff, admin or manager) obj if found + else returns None type. + + Args: + username (_type_): _description_ + password (_type_): _description_ + Returns: + staffUser: _description_ + """ + pass +def logout(): + pass -def main() -> None: - pass +def main() -> None: + print("\n\nSTARTING CINEMA MANAGEMENT SYSTEM.\n\n\n\n") + user = None + while user == None: + username = str(input("To login please enter your\nUsername: ")) + password = str(input("Password: ")) + user = loginAttempt(username=username, password=password) + if user == None: + print("Login attempt failed please try again.") + # load options and so on... + +# following code will only execute if run directly from this file. if __name__ == "__main__": - #main() - pass \ No newline at end of file + main() \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py index 57bcd328a111622564b8bfda784cf3409110d867..efd245651907d4907e6f69e4d1a8b93082540e74 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -4,4 +4,4 @@ from managerUser import * from reciptObj import * from reportObj import * from staffUser import * -from userClass import * \ No newline at end of file +from dbfunc import * \ No newline at end of file diff --git a/src/__pycache__/__init__.cpython-313.pyc b/src/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cc87ac7651bfc8be0e261670e1255aba41e5de0a Binary files /dev/null and b/src/__pycache__/__init__.cpython-313.pyc differ diff --git a/src/__pycache__/adminUser.cpython-313.pyc b/src/__pycache__/adminUser.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cfa2383e4b7d9e1132db9e1fcef7eed32ae52aee Binary files /dev/null and b/src/__pycache__/adminUser.cpython-313.pyc differ diff --git a/src/__pycache__/staffUser.cpython-313.pyc b/src/__pycache__/staffUser.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bb81dca420dc056d9126ee0e007db0ef2c094e84 Binary files /dev/null and b/src/__pycache__/staffUser.cpython-313.pyc differ diff --git a/src/adminUser.py b/src/adminUser.py index 1113af6d7feca0e509eaae6688dd8413fe01c976..f8864a86450ced42cb24fa0ca7ff9533bd91d1f9 100644 --- a/src/adminUser.py +++ b/src/adminUser.py @@ -1,7 +1,14 @@ -from . import userClass +import staffUser -class AdminUser(userClass.User): - pass +class AdminUser(staffUser.StaffUser): + """_summary_ + + Args: + staffUser (_type_): _description_ + """ + def __init__(self): + super().__init__() + self.permissionLevel = 1 @@ -15,6 +22,6 @@ class AdminUser(userClass.User): # following code will only execute if run directly from this file. if __name__ == "__main__": - # test + # testing user1 = AdminUser() print(user1) diff --git a/src/cinemaObj.py b/src/cinemaObj.py index 86d21b97909e418399256740d3c29a198ec219fa..32ca4922482e1d26eed3b30269f0bac9a43d8477 100644 --- a/src/cinemaObj.py +++ b/src/cinemaObj.py @@ -17,5 +17,6 @@ class Cinema(object): if __name__ == "__main__": - #test() - pass \ No newline at end of file + # testing + test = Cinema() + print(test) \ No newline at end of file diff --git a/dbfunc.py b/src/dbfunc.py similarity index 93% rename from dbfunc.py rename to src/dbfunc.py index c8e13fe14b803591e34cfddc24833a63a933989d..229334ed4ff2053098ff5c12dc87f98b963875ce 100644 --- a/dbfunc.py +++ b/src/dbfunc.py @@ -1,7 +1,6 @@ import mysql.connector from mysql.connector import errorcode - # Vars hostname = "localhost" username = "" @@ -9,6 +8,7 @@ passwd = "" def getConnection(db=""): + # if specifyed database if db != "": try: @@ -26,6 +26,7 @@ def getConnection(db=""): else: print("Connected to server.") return conn + # if database not specifyed try defult from line 5 else: try: conn = mysql.connector.connect(host = hostname, diff --git a/src/filmObj.py b/src/filmObj.py index c520910a40552af52d3f7c0581980556eb4183b8..1533a47f0aad5665aadeb462f6921b188b73101a 100644 --- a/src/filmObj.py +++ b/src/filmObj.py @@ -12,4 +12,13 @@ class Film(object): pass def removeListing(self): - pass \ No newline at end of file + pass + + + + +# following code will only execute if run directly from this file. +if __name__ == "__main__": + # testing + test = Film() + print(test) \ No newline at end of file diff --git a/src/managerUser.py b/src/managerUser.py index 1c21ee12aecd326b11f27c80779ee8798e5d0f70..bbdf0e52602a069de0a0d6e120dfcabfaf71ab31 100644 --- a/src/managerUser.py +++ b/src/managerUser.py @@ -1,11 +1,14 @@ -from . import userClass +import adminUser -class ManagerUser(userClass.User): +class ManagerUser(adminUser.AdminUser): """ Args: userClass (_type_): _description_ """ + def __init__(self): + super().__init__() + self.permissionLevel = 2 def expandBuisness(self): # creates new cinemaObj and adds it to db. @@ -23,6 +26,6 @@ class ManagerUser(userClass.User): # following code will only execute if run directly from this file. if __name__ == "__main__": - # test + # testing user1 = ManagerUser() print(user1) diff --git a/src/reciptObj.py b/src/reciptObj.py index 23676420744b50019cbe1487edfeb5ecea9ce8cd..8004b9ffec82935c7cc5ed79cba0f7529ff95830 100644 --- a/src/reciptObj.py +++ b/src/reciptObj.py @@ -18,5 +18,6 @@ class Recipt(object): if __name__ == "__main__": - #test() - pass \ No newline at end of file + # testing + test = Recipt() + print(test) \ No newline at end of file diff --git a/src/reportObj.py b/src/reportObj.py index 63e93787c2b06b8e72eaa0e27cbad64fdb01b682..2eb4ea59315fc58b9b6ef57f557dd64e2d66fc16 100644 --- a/src/reportObj.py +++ b/src/reportObj.py @@ -13,5 +13,6 @@ class Report(object): if __name__ == "__main__": - #test() - pass \ No newline at end of file + # testing + test = Report() + print(test) \ No newline at end of file diff --git a/src/staffUser.py b/src/staffUser.py index 2a7ec89c39c2fcb9adee7f55367b29b7c503d428..13f19456a67c3c7304aa2f3f50bd2cb8b6e151a8 100644 --- a/src/staffUser.py +++ b/src/staffUser.py @@ -1,30 +1,44 @@ -from . import userClass - -class StaffUser(userClass.User): - """_summary_ - - Args: - userClass (_type_): _description_ - """ - +import random + + +class StaffUser(object): + def __init__(self): + + self.userID:int = random.randint(0,10000) + self.userName:str = self.encrypt("") + self.userPass:str = self.encrypt("") + self.permissionLevel = 0 + + def __str__(self): + if self.permissionLevel == 1: + userType = "Admin" + elif self.permissionLevel == 2: + userType = "Manager" + else: + userType = "BookingStaff" + + return f"{userType} user object(userID={self.userID}, userName={self.userName}, userPass={self.userPass})" + + def login(self): + pass + + def logout(self): + pass + def veiwFilmListing(self): pass def manageBooking(): pass - - - - - - - - - - - + + def encrypt(self, inputString): + return inputString + + + + # following code will only execute if run directly from this file. if __name__ == "__main__": - # test + # testing user1 = StaffUser() - print(user1) + print(user1) \ No newline at end of file diff --git a/src/userClass.py b/src/userClass.py deleted file mode 100644 index 79564fcbb37d679fab1e404ce1d001bd679212e1..0000000000000000000000000000000000000000 --- a/src/userClass.py +++ /dev/null @@ -1,30 +0,0 @@ -import random -from . import dbfunc - -class User(object): - def __init__(self): - - self.userID:int = random.randint(0,10000) - self.userName:str = self.encrypt("") - self.userPass:str = self.encrypt("") - - def __str__(self): - return f"'User' Object(userID={self.userID}, userName={self.userName}, userPass={self.userPass})" - - def login(self): - pass - - def logout(self): - pass - - def encrypt(self, inputString): - return inputString - - - - -# following code will only execute if run directly from this file. -if __name__ == "__main__": - # test - user1 = User() - print(user1) \ No newline at end of file