def registerUser(self): if self.usertype.get()=="Customer": self.customer=Customer() self.customer.setEmail(self.email.get()) self.customer.setPassword(self.password.get()) self.customer.setUserName(self.username.get()) self.customer.setPhoneNumber(self.phonenum.get()) self.customer.setUserType(self.usertype.get()) self.customer.setCustomerName(self.name.get()) id=''.join([str(random.randint(0, 999)).zfill(3) for _ in range(2)]) self.customer.setCustomerId(id) try: self.customer.createCustomerAccount(self.username.get(),id,self.email.get(),self.phonenum.get()) showinfo("Sucess","Account Created") except: showinfo("Error", "Error in Creating Account ") if self.usertype.get()=="Admin": self.admin=Admin() self.admin.setEmail(self.email.get()) self.admin.setPassword(self.password.get()) self.admin.setUserName(self.username.get()) self.admin.setPhoneNumber(self.phonenum.get()) self.admin.setUserType(self.usertype.get()) self.admin.setAdminName(self.name.get()) id2= ''.join([str(random.randint(0, 999)).zfill(3) for _ in range(2)]) self.admin.setAdminId(id2) try: self.admin.createAdminAccount(self.username.get(),id2,self.email.get(),self.phonenum.get()) showinfo("Sucess","Admin Account Created") except: showinfo("Error","Error in Creating Account ")
def login_admin(): print("----Login as Admin----\n") email_or_user_name = input("Enter user name or email: ") password = input("Enter password: "******"No" in response: print("Incorrect User Name or Email") email_or_user_name = input("Enter user name or email: ") password = input("Enter password: "******"Wrong" in response: print("Incorrect Password") password = input("Enter password: "******"Correct" in response: print("Logged In Successfully...") Console.clear_screen(2) show_admin_menu(admin)
def Login_Selection(self): if self.Function_Dropbox.currentIndex() == 0: if self.linedit1.text() == "o" and self.linedit2.text() == "o": self.Screen_4 = Screen_4(self.width, self.height, self, root) self.Screen_4.show() self.close() elif self.linedit1.text() != str(self.rows[1]): self.Status_Bar.showMessage("Incorrect username! Enter the correct username.") self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red") elif self.linedit2.text() != str(self.rows[2]): self.Status_Bar.showMessage("Incorrect password! Enter the correct password.") self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red") elif self.Function_Dropbox.currentIndex() == 1: if self.linedit1.text() == "a" and self.linedit2.text() == "a": self.Admin = Admin(self.width, self.height, self, root) self.Admin.show() self.close() elif self.linedit1.text() != str(self.rows[3]): self.Status_Bar.showMessage("Incorrect username! Enter the correct username.") self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red") elif self.linedit2.text() != str(self.rows[4]): self.Status_Bar.showMessage("Incorrect password! Enter the correct password.") self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red")
def main(): aQueue = Queue.Queue() HOST = "0.0.0.0" PORT = 8000 logging.basicConfig(level=logging.DEBUG) AdminThd = Admin(aQueue) AdminThd.daemon = True AdminThd.start() tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) tcpsock.bind((HOST, PORT)) tcpsock.listen(10) print("En écoute...") while True: (cs, (ip, port)) = tcpsock.accept() cQueue = Queue.Queue() newThread = Client(cQueue, aQueue, ip, port, cs) newThread.daemon = True settings.cThreads.append(newThread) newThread.start() AdminThd.join()
def studentadd(): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) result=request.form srn,name,pgm,address,phone,branch=result["StudentSRN"],result["StudentName"],result["Program"],result["Address"],result["Phone"],result["Branch"] email,passw,repassw=result["email"],result["password"],result["repassword"] error,success="","" if passw!=repassw: error="Passwords Didn't Match!" else: db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") cur=db_conn.cursor() A1=Admin(db_conn,session['email']) k=A1.AddStudent(db_conn,email,srn,name,address,phone,pgm,branch) if k[0]: success=k[1] acct_type='student' passw=sha256_crypt.hash(passw) query="INSERT INTO users(`password`,account_type,email) VALUES(%s,%s,%s)" cur.execute(query,(passw,acct_type,email,)) db_conn.commit() else: error=k[1] db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") cur=db_conn.cursor() query="SELECT srn,studname FROM student" cur.execute(query) res=cur.fetchall() if success: return render_template("admin_students.html",students=res,success="Student Successfully Added") return render_template("admin_students.html",students=res,error=error)
def LoginButtonfunction(): User = Person() User.Username = UsernameField.get("1.0", END) User.Password = passwordField.get("1.0", END) if len(User.Username) - 1 != 0 and len(User.Password) - 1 != 0: Data = User.Login(User.Username, User.Password) if Data[0] and Data[1].Authorize: if not Data[1].Admin: User = Users() else: User = Admin() User.Username = Data[1].Username User.Password = Data[1].Password User.Folderpath = Data[1].Folderpath User.Authorize = Data[1].Authorize User.Admin = Data[1].Admin if not User.Admin: root.destroy() root.quit() from Dashboard import Dashboard next = Dashboard(User) else: pass # الى هيعمل ال admin else: tkinter.messagebox.showinfo(" Invalid Credintial", "User Doesnot exist thank you :)") root.destroy() root.quit() else: tkinter.messagebox.showinfo("Empty fields", "Do net leave any field empty ")
def facultyadd(): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) res=request.form id,name,address,phone,date=res['FacultyID'],res["FacultyName"],res['Address'],res['FacultyPhone'],res['date'] email,pwd,rpwd=res['email'],res['password'],res['repassword'] error,success="","" if pwd!=rpwd: error="Passwords Didn't Match" else: db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") cur=db_conn.cursor() A1=Admin(db_conn,session['email']) k=A1.AddFaculty(db_conn,email,id,name,address,phone,date) if k[0]: success=k[1] acct_type="faculty" passw=sha256_crypt.hash(pwd) query="INSERT INTO users(`password`,account_type,email) VALUES(%s,%s,%s)" cur.execute(query,(passw,acct_type,email,)) db_conn.commit() else: error=k[1] db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") cur=db_conn.cursor() query="SELECT FacultyID,`Name` FROM faculty" cur.execute(query) res=cur.fetchall() if success: return render_template("admin_faculty.html",faculty=res,success="Faculty Successfully Added") return render_template("admin_faculty.html",faculty=res,error=error)
def enroll_ta(): # URL requested will look like /control/instructor_cp/modify_course/?cid=some-value course_id = request.args.get('cid') user = current_user username = user.get_id() instructor = Instructor(username) user2 = current_user username2 = user2.get_id() admin = Admin(username2) course_data = instructor.get_course_data(course_id) ta_list = instructor.show_tas(course_id) ta_ids = [] for ta in ta_list: ta_ids.append(ta[0]) user_list = admin.show_all_users() user_ids = [] for use in user_list: user_ids.append(use[0]) if request.method == 'POST': taID = request.form['taID'] if taID not in ta_ids and len(taID) < 7 and taID in user_ids: instructor.enroll_ta_in_course(taID, course_id) return redirect(url_for('instructor_cp')) else: return redirect(url_for('instructor_cp')) return render_template('instr_enroll_ta.html')
def getUserTyp(type, name): if type == 'user': return User(name) if type == 'translator': return Translator(name) if type == 'admin': return Admin(name)
def admin_cp(): user = current_user username = user.get_id() admin = Admin(username) user_list = admin.show_all_users() course_data = admin.show_courses() return render_template('admin_cp.html', user=user, course_data=course_data, user_list=user_list)
def edit_notifications(): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") A1 = Admin(db_conn, session['email']) all_announcements = A1.ViewAnnouncements(db_conn) return render_template("edit_notifications.html", all_announcements = all_announcements)
def select_points(): # payload = request.get_json() print("select_point is called: ", payload) #print payload['keys'][0] # u'keys': [{u'LocName': u'Georgia Tech', u'DateTime': u'Tue, 31 Jan 2017 18:37:00 GMT'}]}) if 'keys' in payload and len(payload['keys']) > 0: new_admin = Admin() new_admin.changeDP(payload['keys'], payload['acc']) # pass return jsonify({"succ": 0, "c": payload})
def main(): # 欢迎页面 admin = Admin() # 欢迎页面 admin.printWelcomeView() if admin.adminOption(): return -1 # 提款机对象 # 将当前的系统中的用户信息保存到文件中 filePath = os.path.join(os.getcwd(), 'allusers.txt') file = open(filePath, 'rb') allUsers = pickle.load(file) print('******************************') print(allUsers) # ATM对象 atm = ATM(allUsers) while True: # 功能页面 admin.printFunctionView() # 登陆成功, 等待用户操作 option = input('请输入您的操作:') if option == '1': atm.creatUser() elif option == '2': atm.searchUserInfo() elif option == '3': atm.getAccountMoney() elif option == '4': atm.saveMoney() elif option == '5': atm.transformAccountMoney() elif option == '6': atm.reviseAccountPassword() elif option == '7': atm.lockAccount() elif option == '8': atm.unlockAccount() elif option == '9': atm.reserAccountCard() elif option == '0': atm.removeAccount() elif option == 't': # 将当前系统中的用户信息保存到文件中 file1 = open(filePath, 'wb') pickle.dump(atm.allUsers, file1) file1.close() time.sleep(2) print('退出成功') return -1
def export_data(): username = current_user.get_id() admin = Admin(username) user_list = admin.show_all_users() data = '' for tuple in user_list: data += tuple[0] + "," # id data += tuple[1] + "," # first name data += tuple[2] + "," # last name data += tuple[3] + "<br>" # account type return data
def ShowAdmin(self, Tum): List = [] for record in Tum: admin = Admin() admin.set_adminid(record[0]) admin.set_passwd(record[1]) admin.set_connection(record[2]) admin.set_permission(record[3]) List.append(admin) result = tuple(List) return result
def __init__(self): self.connection = pymysql.connect( host="localhost", user="******", password="", db='UNIVERSITY1', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) self.cursor = self.connection.cursor() self.user = User(self) self.admin = Admin(self)
def save_account(): payload = request.get_json() print('saving account [accept / reject]', payload) # {'id': p.id, 'status': acc? 1 : 0, 'email': p.EmailAddress} if 'id' in payload: # currently only for accpet or reject accounts # pass new_admin = Admin() new_admin.changeCOA_one(payload['email'], payload['status']) else: pass # won't reach here for this assignment return jsonify({'succ': 0, 'c': payload})
def delete_notification(NOTIF_ID = ""): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") A1 = Admin(db_conn, session['email']) print("deleting...") A1.RemoveAnnouncement(db_conn, ID = NOTIF_ID) return redirect(url_for("edit_notifications"))
def fetch_points(): # fetch pending data points newA = Admin() result = newA.pendingDP() ''' return jsonify({ 'succ': 0, 'c': [ {"loc": 0, "attr": "AQI", "val": 31, 'id': 0, 'ts': '12-08-2014', 'status': -1} , {"loc": 1, "attr": "AQI", "val": 1099, 'id': 3, 'ts': '04-21-2017', 'status': -1} , {"loc": 1, "attr": "Mold", "val": 653, 'id': 5, 'ts': '10-02-2017', 'status': -1} , {"loc": 3, "attr": "Mold", "val": 9, 'id': 15, 'ts': '09-11-2015', 'status': -1} ]}) ''' return jsonify({'succ': 0, 'c': result})
def add_notification(): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) if(request.method == "POST"): db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******", password = "******", database = "pesuapp") form_data = request.form print(form_data) A1 = Admin(db_conn, session['email']) A1.AddAnnouncement(db_conn, Title=form_data['Title'], Location=form_data['Location'], Description=form_data['Description'], PictureLink=form_data['PictureLink'], HyperLink=form_data['HyperLink']) return redirect(url_for("admin_notifications")) return render_template("add_notification.html")
def view_feedback(CourseID = ""): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") A1 = Admin(db_conn, session['email']) if(CourseID): CourseFeedback = A1.ViewFeedback(db_conn, CourseID) return render_template("view_course_feedback.html", CourseFeedback = CourseFeedback, CourseID = CourseID) all_courses = A1.ViewCourse(db_conn) return render_template("view_feedback.html", all_courses = all_courses)
def main(): #管理员对象 admin = Admin() admin.printAdminView() if admin.adminOption(): return -1 #提款机对象 filePath = os.path.join(os.getcwd(), "allUsers.txt") f = open(filePath, "rb") allUsers = pickle.load(f) allUsers = {} atm = ATM(allUsers) while True: admin.printsysFunctionView() #等待用户操作 option = input("请输入您的操作:") if option == "1": #开户 atm.createUser() elif option == "2": atm.searchUserInfo() elif option == "3": atm.getMoney() elif option == "4": print("存款") elif option == "5": print("转账") elif option == "6": print("改密") elif option == "7": ATM.lockUser() elif option == "8": print("解锁") elif option == "9": print("补卡") elif option == "0": print("销户") elif option == "t": if not admin.adminOption(): #将系统中的用户信息保存到文件中 f = open(filePath, "a") pickle.dump(atm.allUsers, f) f.close() return -1 time.sleep(2)
def __init__(self, clientId, data, verifykey, apiEndPoint): self.message = data self.sessionkey = verifykey self.apiEndPoint = apiEndPoint self.splitUrl = apiEndPoint.split('/') self.auth = Authentication() self.master = Master() self.admin = Admin() self.role = roleManage() self.attendance = attendanceManage() self.project = projectManage() self.labourer = labbourerManage() self.labclass = labourerClass() self.shift = shiftManage() self.log = Logger() self.paymentDesk = paymentDesk() self.clientId = clientId
def admin_modify_instructor(): course_id = request.args.get('cid') user = current_user username = user.get_id() admin = Admin(username) user_list = admin.show_all_users() user_ids = [] for user_id in user_list: user_ids.append(user_id[0]) if request.method == 'POST': id = request.form['id'] if len(id) > 0 and id in user_ids: admin.mod_instructor(id, course_id) return redirect(url_for('admin_cp')) return render_template('admin_modify_instructor.html', user=user, course_id=course_id)
def startSelector(self, RS, cursor, conn): while (True): if RS == 0: RS = login(self) elif (RS == 'admin'): Admin(cursor, conn) RS = 0 elif (RS == 'user'): User(cursor, conn) RS = 0 elif RS == 'q': close(self) print('Wyszedłeś z programu') break else: close(self) print('Wyszedłeś z programu') break
def register_admin(): print("----Rick Inc Registration Form----\n") admin_first_name = input("Enter First Name: ") while not is_valid_name(admin_first_name): admin_first_name = input("Enter First Name: ") admin_first_name = format_name(admin_first_name) admin_last_name = format_name(input("Enter Last Name: ")) while not is_valid_name(admin_last_name): admin_last_name = input("Enter Last Name: ") admin_last_name = format_name(admin_last_name) admin_email = input("Enter Email: ") while not is_valid_email(admin_email): admin_email = input("Enter Email: ") admin_user_name = input("Enter User Name: ") while not is_valid_user_name(admin_user_name): admin_user_name = input("Enter User Name: ") admin_password = input("Enter Password: "******"Enter Password: "******"Confirm Password: "******"Enter Password: "******"Enter Password: "******"Confirm Password: "******"%d-%m-%Y") new_admin = Admin(admin_first_name, admin_last_name, admin_user_name, admin_email, admin_password, date_added) db.insert_admin(new_admin) print("Thank you for registering with us!") print("Redirecting to login page...") sleep(3) Console.clear_screen(3) login_admin()
def facultyedit(): try: if session['type']!="admin": return redirect(url_for("logout")) except: return redirect(url_for("logout")) result=request.form id,name,address,phonenumber,courseid=result['FacultyID'],result['FacultyName'],result['Address'],result['Phone'],result['CID'] courseid=courseid.split(",") courseid=[x.strip() for x in courseid] db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp") A1=Admin(db_conn,session['email']) k=A1.EditFaculty(db_conn,id,name,address,phonenumber,courseid) cur=db_conn.cursor() query="SELECT FacultyID,`Name` FROM faculty" cur.execute(query) res=cur.fetchall() if k[0]: return render_template("admin_faculty.html",faculty=res,success="Faculty Successfully Edited") return render_template("admin_faculty.html",faculty=res,error=k[1])
def login(cursor): uname = input("Enter your username: "******"Select * from Users where Uname=%s", uname) if uname != str(uinfo[2]): create = input( "User not exists, do you want to create one?\nEnter Y/y to continue or any other key to return to the menu:" ) if create == 'Y' or create == 'y': createUser(cursor) else: upwd = input("Enter the password: ") if upwd == str(uinfo[1]): if str(uinfo[3]) == 'u': newone = User(str(uinfo[0]), str(uinfo[3]), str(uinfo[2])) elif str(uinfo[3]) == 's': newone = Suser(str(uinfo[0]), str(uinfo[3]), str(uinfo[2])) elif str(uinfo[3]) == 'a': newone = Admin(str(uinfo[0]), str(uinfo[3]), str(uinfo[2])) return newone return False
def login_menu(self): """ Display Login options for users to choose. :return: True """ print("LOGIN MENU") username = input("Username: "******"Password: "******"\nWrong Credentials! Try again.") self.login_menu() return True
def LoginUser(self): if self.usertype.get() == "Customer": self.customer = Customer() self.customer.setUserType(self.usertype.get()) result = self.customer.login(self.username.get(), self.password.get()) if result == True: showinfo("Sucess", "Login Sucessfull") if result == False: showinfo("Error", "Login Unsucessfull") if self.usertype.get() == "Admin": self.admin = Admin() self.admin.setUserType(self.usertype.get()) result = self.admin.login(self.username.get(), self.password.get()) if result == True: showinfo("Sucess", "Login Sucessfull") if result == False: showinfo("Error", "Login Unsucessfull")