def checkLogin(): loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginEmailId = request.form['loginEmailId'] loginVO.loginPassword = request.form['loginPassword'] loginDict = loginDAO.searchLogin(loginVO) if len(loginDict) == 0: return render_template('admin/login.html', loginemailIderror="*you are not registered") elif loginVO.loginPassword != loginDict[0]['loginPassword']: return render_template( 'admin/login.html', loginPassworderror="*Incorrect email or password") elif loginDict[0]['loginRole'] == 'admin': session['loginRole'] = loginDict[0]['loginRole'] session['loginId'] = loginDict[0]['loginId'] return redirect(url_for('loadIndex')) else: registerVO = RegisterVO() registerDAO = RegisterDAO() session['loginRole'] = loginDict[0]['loginRole'] session['loginId'] = registerVO.register_LoginId = loginDict[0][ 'loginId'] firstnameDict = registerDAO.findFirstName(registerVO) session['registerFirstname'] = firstnameDict[0]['registerFirstname'] return redirect(url_for("loadIndex"))
def updateProfile(): try: registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerGender = request.form['registerGender'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerContact = request.form['registerContact'] loginVO.loginEmailId = request.form['registerEmailId'] loginVO.loginPassword = request.form['loginPassword'] loginVO.loginId = registerVO.register_LoginId = request.form['loginId'] loginDict = loginDAO.searchLoginIddata(loginVO) if loginVO.loginPassword == loginDict[0]['loginPassword']: loginDAO.updateProfile(loginVO) registerDAO.updateProfile(registerVO) return redirect(url_for('loadProfile')) else: session['error'] = "*wrong password Please enter again" return redirect(url_for('loadEditprofile')) except: return render_template('admin/login.html')
def updateProfile(): if session['loginRole'] != 'user': return redirect(url_for('login')) loginDAO = LoginDAO() loginVO = LoginVO() registerDAO = RegisterDAO() registerVO = RegisterVO() loginVO.loginId = session['loginId'] loginVO.loginEmailId = request.form['registerEmailId'] loginVO.loginActiveStatus = 'active' registerVO.register_LoginId = session['loginId'] registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerContact = request.form['registerContact'] registerVO.registerActiveStatus = 'active' registerDAO.updateRegister(registerVO) loginDAO.updateLogin(loginVO) return redirect(url_for('userProfile'))
def adminLoadDashboard(): try: if adminLoginSession() == 'admin': complainCount = 0 feedbackCount = 0 userCount = 0 complainDAO = ComplainDAO() complainList = complainDAO.complainCount() print('complainList>>>>>', complainList) complainCount = complainList[0][0] feedbackDAO = FeedbackDAO() feedbackList = feedbackDAO.adminViewFeedback() feedbackCount = len(feedbackList) registerDAO = RegisterDAO() registerList = registerDAO.viewRegister() userCount = len(registerList) return render_template('admin/index.html', complainCount=complainCount, feedbackCount=feedbackCount, userCount=userCount) else: return adminLogoutSession() except Exception as ex: print(ex)
def loadIndex(): try: if session['loginRole'] == 'admin': registerDAO = RegisterDAO() datasetDAO = DatasetDAO() blogDAO = BlogDAO() videoDAO = VideoDAO() complaintDAO = ComplaintDAO() feedbackDAO = FeedbackDAO() predictDAO = PredictDAO() userdict = registerDAO.countuser() companydict = datasetDAO.countcompany() blogDict = blogDAO.countBlog() videoDict = videoDAO.countVideo() complaintDict = complaintDAO.countComplaint() feedbackDict = feedbackDAO.countfeedback() predictDict = predictDAO.searchDPrediction() return render_template('admin/index.html', userdict=userdict, companydict=companydict, blogDict=blogDict, videoDict=videoDict, feedbackDict=feedbackDict, complaintDict=complaintDict, predictDict=predictDict) else: blogDAO = BlogDAO() blogDict = blogDAO.searchBlog() return render_template('user/index.html', blogDict=blogDict) except: return render_template('admin/login.html')
def insertRegister(): try: firstname = request.form['firstname'] lastname = request.form['lastname'] username = request.form['username'] password = request.form['password'] registerVO = RegisterVO() registerDAO = RegisterDAO() loginVO = LoginVO() loginDAO = LoginDAO() registerVO.registerFirstname = firstname registerVO.registerLastname = lastname registerVO.registerUsername = username registerVO.registerPassword = password loginVO.loginUsername = username loginVO.loginPassword = password registerDAO.insertRegister(registerVO) loginDAO.insertRegister(loginVO) return render_template('Login.html') except Exception as ex: print(ex)
def adminunblockUser(): try: loginVO = LoginVO() loginDAO = LoginDAO() loginId = request.args.get('loginId') print('loginId::', loginId) loginVO.loginId = loginId registerDAO = RegisterDAO() loginVO.loginRole = 'user' loginVO.loginStatus = 'active' loginDAO.validateLogin(loginVO) registerDAO.viewRegister() loginDAO.unblockUser(loginVO) return redirect(url_for('adminViewUser')) except Exception as ex: print(ex)
def register_user(): firstname = request.form['firstname'] lastname = request.form['lastname'] username = request.form['username'] password = request.form['password'] register_dao_obj = RegisterDAO() register_dao_obj.insert_data(firstname, lastname, username, password) return redirect('/')
def viewUser(): try: if session['loginRole'] == 'admin': registerDAO = RegisterDAO() userDict = registerDAO.searchUser() return render_template('admin/viewUser.html', userDict=userDict) else: return render_template('admin/login.html') except: return render_template('admin/login.html')
def adminViewUser(): try: if adminLoginSession() == 'admin': registerDAO = RegisterDAO() registerVOList = registerDAO.viewUser() print(registerVOList) return render_template('admin/viewUser.html', registerVOList=registerVOList) except Exception as ex: print(ex)
def adminloadVideo(): try: if adminLoginSession() == 'admin': registerDAO = RegisterDAO() registerVOList = registerDAO.viewRegister_User() return render_template('admin/addVideo.html', registerVOList=registerVOList) else: return adminLogoutSession() except Exception as ex: print(ex)
def deleteseller(): if session['loginDictrole'] == "admin": registerDAO = RegisterDAO() registerVO = RegisterVO() registerVO.registerId = request.form['registerId'] registerDAO.deleteseller(registerVO) return redirect("/viewseller")
def adminViewUser(): try: if adminLoginSession() == 'admin': registerDAO = RegisterDAO() registerVOList = registerDAO.viewRegister() print("___________________", registerVOList) status = 'active' return render_template('admin/viewUser.html', registerVOList=registerVOList, status=status) else: return adminLogoutSession() except Exception as ex: print(ex)
def insertRegister(): registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() loginVO.loginEmailId = request.form['registerEmailId'] loginDict = loginDAO.searchLoginByEmailId(loginVO) if loginDict: flash('EmailAddress Is Already Taken', 'success') return render_template('admin/register.html') registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerContact = request.form['registerContact'] registerVO.registerDate, registerVO.registerTime = str( datetime.now()).split(' ') registerVO.registerActiveStatus = 'active' loginVO.loginRole = 'user' loginVO.loginActiveStatus = 'active' loginVO.loginPassword = '******' loginDAO.insertLogin(loginVO) loginDict = loginDAO.getMaxId() registerVO.register_LoginId = loginDict[0]['MAX(loginId)'] registerDAO.insertRegister(registerVO) loginDict = loginDAO.searchLoginByEmailId(loginVO) session['loginRole'] = loginDict[0]['loginRole'] session['loginId'] = loginDict[0]['loginId'] fromaddr = "*****@*****.**" toaddr = loginVO.loginEmailId msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "welcome to lemanhouse" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("*****@*****.**", "HeisenBerg_1102008") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() return redirect(url_for('home'))
def adminViewRegister(): try: if adminLoginSession() == "admin": registerDAO = RegisterDAO() registerVOList = registerDAO.viewRegister() print("_________", registerVOList) return render_template("admin/viewUser.html", registerVOList=registerVOList) else: return redirect(url_for("adminLogoutSession")) except Exception as ex: print(ex)
def userEditRegister(): try: if adminLoginSession() == 'user': loginId = session['session_loginId'] registerVO = RegisterVO() registerDAO = RegisterDAO() registerVO.register_LoginId = loginId registerVOList = registerDAO.editProfile(registerVO) return render_template('user/editProfile.html', registerVOList=registerVOList) else: return adminLogoutSession() except Exception as ex: print(ex)
def blockUser(): try: if session['loginRole'] == 'admin': registerVO = RegisterVO() registerDAO = RegisterDAO() loginDAO = LoginDAO() loginVO = LoginVO() registerVO.register_LoginId = loginVO.loginId = request.args.get( 'register_LoginId') registerVO.registerActiveStatus = loginVO.loginActiveStatus = 'deactive' registerDAO.blockUser(registerVO) loginDAO.blockUser(loginVO) return redirect(url_for('viewUser')) else: return render_template('admin/login.html') except: return render_template('admin/login.html')
def userEditRegister(): try: if adminLoginSession() == 'user': loginId = request.args.get('loginId') registerVO = RegisterVO() registerDAO = RegisterDAO() registerVO.register_LoginId = loginId registerVOList = registerDAO.editProfile(registerVO) print("registerVOList >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ", registerVOList) return render_template('user/editProfile.html', registerVOList=registerVOList) else: return adminLogoutSession() except Exception as ex: print(ex)
def loadForum(): try: if session['loginRole'] == 'admin': return render_template('admin/index.html') else: forumQuestionDAO = ForumQuestionDAO() forumQuestionDict = forumQuestionDAO.searchForumQuestion() forumAnswerDAO = ForumAnswerDAO() forumAnswerDict = forumAnswerDAO.searchForumAnswer() registerDAO = RegisterDAO() registerDict = registerDAO.searchRegister() return render_template('user/forum.html', forumQuestionDict=forumQuestionDict, forumAnswerDict=forumAnswerDict, registerDict=registerDict, session=session) except: return render_template('admin/login.html')
def insertRegister(): registerDAO=RegisterDAO() registerVO=RegisterVO() loginDAO=LoginDAO() loginVO=LoginVO() registerVO.registerOrganizationname=request.form['registerOrganizatonname'] registerVO.registerContact=request.form['registerContact'] registerVO.registerCategory=request.form['registerCategory'] registerVO.registerAddress=request.form['registerAddress'] registerVO.register_LoginId = str(loginDAO.searchLoginId(loginVO)[0].values()[0]) loginVO.loginEmail = request.form['registerEmail'] loginVO.loginPassword = ''.join((random.choice(string.ascii_letters + string.digits)) for x in range(8)) loginVO.loginRole='user' print(loginVO.loginEmail) loginDict = loginDAO.searchLogin(loginVO) if len(loginDict) == 0: print("registerPassword="******"*****@*****.**" toaddr = loginVO.loginEmail msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "PYTHON PASSWORD" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(fromaddr, "BHAIbhai4725") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() loginDAO.insertLogin(loginVO) registerDAO.insertRegister(registerVO) return redirect(url_for('loadLogin')) else: flash('Email already exist !', 'danger') return redirect(url_for('loadRegister'))
def adminLoadDashboard(): try: if adminLoginSession() == 'admin': complainDAO = ComplainDAO() feedbackDAO = FeedbackDAO() registerDAO = RegisterDAO() complainVOList = complainDAO.viewComplain() totalComplainCount = len(complainVOList) feedbackVOList = feedbackDAO.adminViewFeedback() totalFeedbackCount = len(feedbackVOList) registerVOList = registerDAO.viewRegister() totalUserCount = len(registerVOList) return render_template('admin/Index.html', totalUserCount=totalUserCount, totalComplainCount=totalComplainCount, totalFeedbackCount=totalFeedbackCount) else: return adminLogoutSession() except Exception as ex: print(ex)
def update_user(id): if request.method == 'GET': register_dao_obj = RegisterDAO() return_data = register_dao_obj.search_data(id) return render_template('update.html', result=return_data) else: firstname = request.form['firstname'] lastname = request.form['lastname'] username = request.form['username'] password = request.form['password'] register_dao_obj = RegisterDAO() register_dao_obj.update_data(firstname, lastname, username, password, id) return redirect('/search')
def insertRegister(): registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() loginVO.loginEmailId = request.form['registerEmailId'] registerDict = loginDAO.searchLogin(loginVO) if len(registerDict) > 0: return render_template('user/register.html', errorreg="*already registered") else: registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerGender = request.form['registerGender'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerContact = request.form['registerContact'] registerVO.registerDate, registerVO.registerTime = str( datetime.now()).split(' ') registerVO.registerActiveStatus = 'active' loginVO.loginRole = 'user' loginVO.loginActiveStatus = 'active' loginVO.loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) fromaddr = "*****@*****.**" toaddr = loginVO.loginEmailId msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "your password" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(fromaddr, "iamdarshil") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() loginDAO.insertLogin(loginVO) loginDict = loginDAO.searchLoginId() registerVO.register_LoginId = loginDict[0]['max(loginId)'] registerDAO.insertRegister(registerVO) return redirect(url_for('loadLogin')) return redirect(url_for('loadLogin'))
def adminInsertRegister(): try: loginVO = LoginVO() loginDAO = LoginDAO() registerVO = RegisterVO() registerDAO = RegisterDAO() loginUsername = request.form['loginUsername'] registertrafficPoliceStationName = request.form[ 'registertrafficPoliceStationName'] registertrafficPoliceStationAreaName = request.form[ 'registertrafficPoliceStationAreaName'] registertrafficPoliceStationAddress = request.form[ 'registertrafficPoliceStationAddress'] registertrafficPoliceStationContact = request.form[ 'registertrafficPoliceStationContact'] loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) print("loginPassword="******"*****@*****.**" receiver = loginUsername msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = "TRAFFIC POLICE STATION LOGIN PASSWORD" msg.attach(MIMEText(loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, "trafficease123") text = msg.as_string() server.sendmail(sender, receiver, text) loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginVO.loginRole = "user" loginVO.loginStatus = "active" print('hello') loginDAO.insertLogin(loginVO) registerVO.registertrafficPoliceStationName = registertrafficPoliceStationName registerVO.registertrafficPoliceStationAreaName = registertrafficPoliceStationAreaName registerVO.registertrafficPoliceStationAddress = registertrafficPoliceStationAddress registerVO.registertrafficPoliceStationContact = registertrafficPoliceStationContact registerVO.register_LoginId = loginVO.loginId registerDAO.insertRegister(registerVO) server.quit() return render_template("admin/login.html") except Exception as ex: print(ex)
def userInsertRegister(): try: loginUsername = request.form['loginUsername'] loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) print("password="******"user" loginVO.loginStatus = "active" sender = "*****@*****.**" receiver = loginUsername msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = "LOGIN PASSWORD" msg.attach(MIMEText(loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, "parents123eye123") text = msg.as_string() server.sendmail(sender, receiver, text) loginDAO.insertLogin(loginVO) registerFirstName = request.form['registerFirstName'] registerLastName = request.form['registerLastName'] registerAddress = request.form['registerAddress'] registerContact = request.form['registerContact'] registerVO = RegisterVO() registerDAO = RegisterDAO() registerVO.registerFirstName = registerFirstName registerVO.registerLastName = registerLastName registerVO.registerAddress = registerAddress registerVO.registerContact = registerContact registerVO.register_LoginId = loginVO.loginId registerDAO.insertRegister(registerVO) server.quit() return render_template("admin/login.html") except Exception as ex: print(ex)
def userUpdateRegister(): try: if adminLoginSession() == 'user': registerVO = RegisterVO() registerDAO = RegisterDAO() loginId = request.form['loginId'] loginUsername = request.form['loginUsername'] registerId = request.form['registerId'] registerFirstName = request.form['registerFirstName'] registerLastName = request.form['registerLastName'] registerAddress = request.form['registerAddress'] registerContact = request.form['registerContact'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = loginId loginList = loginDAO.viewLogin(loginVO) if loginList[0].loginUsername == loginUsername: pass else: loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) sender = "*****@*****.**" receiver = loginUsername msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = "ACCOUNT PASSWORD" msg.attach(MIMEText(loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, "parents123eye123") text = msg.as_string() server.sendmail(sender, receiver, text) server.quit() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginDAO.updateLogin(loginVO) registerVO.registerId = registerId registerVO.registerFirstName = registerFirstName registerVO.registerLastName = registerLastName registerVO.registerAddress = registerAddress registerVO.registerContact = registerContact registerDAO.updateRegister(registerVO) return redirect(url_for('userLoadDashboard')) else: return adminLogoutSession() except Exception as ex: print(ex)
def userInsertRegister(): try: loginVO = LoginVO() loginDAO = LoginDAO() registerVO = RegisterVO() registerDAO = RegisterDAO() loginUsername = request.form['loginUsername'] companyName = request.form['companyName'] registerFirstname = request.form['registerFirstname'] registerLastname = request.form['registerLastname'] registerGender = request.form['registerGender'] registerAddress = request.form['registerAddress'] registerContact = request.form['registerContact'] loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) print("loginPassword= "******"dkppwd1998@") text = msg.as_string() server.sendmail(sender, receiver, text) loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginVO.loginRole = 'user' loginVO.loginStatus = 'active' loginDAO.insertLogin(loginVO) registerVO.companyName = companyName registerVO.registerFirstname = registerFirstname registerVO.registerLastname = registerLastname registerVO.registerAddress = registerAddress registerVO.registerGender = registerGender registerVO.registerContact = registerContact registerVO.register_LoginId = loginVO.loginId registerDAO.insertRegister(registerVO) server.quit() return render_template('admin/login.html') except Exception as ex: print(ex)
def insertRegister(): registerVO = RegisterVO() registerDAO = RegisterDAO() loginVO = LoginVO() loginDAO = LoginDAO() alphabet = string.ascii_letters + string.digits password = ''.join(choice(alphabet) for i in range(8)) registerVO.registerName = request.form['registerName'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerGender = request.form['registerGender'] registerVO.registerArea = request.form['registerArea'] registerVO.registerCity = request.form['registerCity'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerMobileno = request.form['registerMobileno'] registerVO.registerEmail = request.form['registerEmail'] registerVO.registerActivestatus = 'active' print("Hello i am Seller") loginVO.loginEmail = request.form['registerEmail'] loginVO.loginPassword = password loginVO.loginRole = 'seller' loginVO.loginActivestatus = 'active' print('EMAIL', loginVO.loginEmail) print("password", loginVO.loginPassword) print("role", loginVO.loginRole) print("status", loginVO.loginActivestatus) loginDict = loginDAO.loadlogin(loginVO) print(loginDict) fromaddr = "*****@*****.**" #email msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = loginVO.loginEmail msg['Subject'] = "PASSWORD FOR YOUR LOGIN" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() passw = "hardik@4693" #password server.login(fromaddr, passw) text = msg.as_string() server.sendmail(fromaddr, loginVO.loginEmail, text) server.quit() loginDict = loginDAO.searchloginId() print(loginDict) registerVO.register_loginId = str(loginDict) registerDAO.insertRegister(registerVO) return render_template('admin/login.html')
def display_user(): register_dao_obj = RegisterDAO() return_data = register_dao_obj.search_data() return render_template('index.html', result=return_data)
def userupdateProfile(): try: if adminLoginSession() == 'user': registerId = request.form['registerId'] companyName = request.form['companyName'] registerFirstname = request.form['registerFirstname'] registerLastname = request.form['registerLastname'] registerGender = request.form['registerGender'] registerAddress = request.form['registerAddress'] registerContact = request.form['registerContact'] loginId = request.form['loginId'] loginUsername = request.form['loginUsername'] registerVO = RegisterVO() registerDAO = RegisterDAO() loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = loginId loginList = loginDAO.getLoginDetails(loginVO) if loginUsername != loginList[0].loginUsername: loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) print("loginPassword= "******"dkppwd1998@") text = msg.as_string() server.sendmail(sender, receiver, text) server.quit() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginDAO.updatePassword(loginVO) registerVO.registerId = registerId registerVO.companyName = companyName registerVO.registerFirstname = registerFirstname registerVO.registerLastname = registerLastname registerVO.registerAddress = registerAddress registerVO.registerGender = registerGender registerVO.registerContact = registerContact registerDAO.updateProfile(registerVO) return redirect(url_for('userLoadDashboard')) else: return adminLogoutSession() except Exception as ex: print(ex)