def crearUsuario(self): controller = UserController() a = controller.createUser(self.name.get(), self.surname.get(), self.user.get(), self.password.get(), 100000) if a == True: self.respuestaL = Label(self.respuesta, text='Usuario Creado Exitosamente', background='pale green') self.respuestaL.grid(row=0, column=0) else: self.respuestaL = Label(self.respuesta, text='Usuario ya existe', background='orange red') self.respuestaL.grid(row=0, column=0)
def ingresar(self): controller = UserController() a = controller.validateUser(self.user.get(), self.password.get()) print(a) if a != None: self.respuesta = Label(self.respuesta, text=('Bienvenido/a: ' + a.name), background= 'pale green') self.respuesta.grid(row= 0, column=0) self.name = a.name self.surname = a.surname self.new_window2() else: print('Usuario vacio') self.respuesta = Label(self.respuesta, text="Usuario o contrase;a incorrecto", background= 'coral') self.respuesta.grid(row= 0, column=0)
# Import section from Model.User import User from Controller.UserController import UserController # Main section while True: print("=" * 50) print("{:^50}".format("MAIN MENU - SCHOOL MANAGEMENT SYSTEM")) print("{}{:<50}".format(" " * 5, "1. Student Management Menu")) print("{}{:<50}".format(" " * 5, "2. Teacher Management Menu")) print("{}{:<50}".format(" " * 5, "3. Class Management Menu")) print("=" * 50) try: command = int(input(">> Enter your command (Enter 0 to exit): ")) except ValueError: print("** WARNING: Invalid command. Please enter number only!") continue if command == 0: exit() elif command == 1: # User controller user = UserController() pass elif command == 2: # Teacher controller pass elif command == 3: # Class controller pass else: print("** WARNING: Your command is invalid. Please try again")
def registerUser(name,email,password,typeuser): usercontroll=UserController() if usercontroll.store(name=name.get(),email=email.get(),password=password.get(),type=typeuser.get()): messagebox.showinfo(title="Success",message="Registro correcto")
class Root: root = Tk() loginScreen = Frame(root, bg='#32425B') form = Frame(loginScreen, bg='#32425B', width=400, height=450) loginForm = Frame(form, bg='#32425B', width=400, height=450) registerForm = Frame(form, bg='#32425B', width=400, height=450) dashboard = Frame(root, bg='#32425B', width=800, height=450) userController = UserController() def __init__(self): pass def createWindow(self): Root.root.resizable(False, False) Root.root.iconbitmap(self.resource_path('assets/images/logo.ico')) Root.root.title('Password Book') Root.root.configure(background='#32425B') Root.root.geometry("800x450") render = ImageTk.PhotoImage( Image.open(self.resource_path('assets/images/bg.png'))) leftDecoration = Label(Root.loginScreen, image=render, borderwidth=0) leftDecoration.image = render LoginForm().createWindow(Root.loginForm, self.handleLogin, self.handleGoToRegister) credit = Label(Root.form, bg='#32425B', fg='white', font=('Roboto', 8), text="Made by Tejus Revi", borderwidth=0, cursor="hand2") credit.place(relx=0.5, rely=0.98, anchor=CENTER) credit.bind( "<Button-1>", lambda e: webbrowser.open_new('https://tejus-dev.web.app/')) Root.loginForm.pack() Root.form.pack(side='right') leftDecoration.pack(side='left') Root.loginScreen.pack() return Root.root def handleRegisterButton(self, username, password, confirmPassword, errorLabel): if username.get() == '' or password.get() == '': errorLabel.config(text="Username and password are required") else: if not Root.userController.isUsernameAvailable(username.get()): errorLabel.config(text="Sorry. That username is taken") else: if password.get() == confirmPassword.get(): Root.userController.createUser(username.get(), password.get()) self.handleGoToLogin() else: errorLabel.config(text="Passwords don't match") def handleLogin(self, username, password, errorLabel): if Root.userController.authenticateUser(username.get(), password.get()): Root.loginScreen.pack_forget() Dashboard(Root.userController).createWindow( Root.dashboard, self.handleLogout) Root.dashboard.pack() else: errorLabel.config(text="Incorrect credentials") def handleGoToRegister(self): Root.loginForm.pack_forget() RegisterForm().createWindow(Root.registerForm, self.handleRegisterButton, self.handleGoToLogin) Root.registerForm.pack() def handleGoToLogin(self): Root.registerForm.pack_forget() LoginForm().createWindow(Root.loginForm, self.handleLogin, self.handleGoToRegister) Root.loginForm.pack() def handleLogout(self): Root.root.quit() def resource_path(self, relative_path): try: base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") print(os.path.join(base_path, relative_path)) return os.path.join(base_path, relative_path)
def UserChangeInfo(): res = UserController().UserChangeInfoController(request.values) return jsonify(res)
def UserQuery(): res = UserController().UserQueryInfoController(request.values) return jsonify(res)
def UserCloseAccount(): res = UserController().UserCloseAccountController(request.values) return jsonify(res)
def UserLogout(): res = UserController().UserLogOutController(request.values) return jsonify(res)
def UserRegister(): res = UserController().UserRigisterController(request.values) return jsonify(res)
def Userlogin(): res = UserController().UserLoginController(request.values) return jsonify(res)
import os import sys projectRootDirectory = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) sys.path.append(projectRootDirectory) os.chdir(projectRootDirectory) from json import loads from Controller.UserController import UserController from Essence.User import User jsonFile = open("SetUp/UserCredentials.json", "r") userData = loads(jsonFile.read()) UserController().add(User(userData['userName'], userData['password']))