def validate_email(self, email): cursor.execute("SELECT * from is_employee_deleted where employee_email_id = '"+ email.data+ "'") temp = cursor.fetchone() if temp is not None: raise ValidationError('Please use a different email address.') cursor.execute("SELECT * from temp_data_storage_table where emp_email_id = %s)",(email,)) temp = cursor.fetchone() if temp is not None: raise ValidationError('Email-ID already exists!')
def validate_username(self, username): cursor.execute("SELECT * FROM is_user_deleted where username = '******'") temp = cursor.fetchone() if temp is not None: raise ValidationError('Please use a different username.') cursor.execute("SELECT * from temp_data_storage_table where username = %s)",(username,)) temp = cursor.fetchone() if temp is not None: raise ValidationError('Username already exists!')
def workflowEditor(): if request.method == 'POST': JSONformLayout = request.form['custId'] session['formdata'] = JSONformLayout print(JSONformLayout) JSONworkflowNodes = request.form['workflow_nodes'] print(JSONworkflowNodes) JSONworkflowDetails = request.form['workflow_details'] print(JSONworkflowDetails) admins = cursor.execute( "SELECT post_email_id FROM employees_holding_post_not_associated_with_department WHERE role_name = 'admin'" ) # admins = ["admin1", "admin2", "admin3", "admin4", "admin5"]#this thing will be fetched from database role_dept = [["role_1", "dept_1"], ["role_2", "dept_2"], ["role_3", "dept_3"], ["role_4", "dept_4"], ["role_5", "dept_5"]] #also fetched from the database roles = ["role_1", "role_2", "role_3", "role_4", "role_5"] #roles without any dept also fetched from the database return render_template( 'admin/workflowEditor.html', admins=admins, role_dept=role_dept, roles=roles ) #the list of all ppl at all roles will be passed from here...
def register(): form = Registration_Form() if form.validate_on_submit(): depart_name = str(request.form.get('department')) print(depart_name) cursor.execute("Insert into temp_data_storage_table values ('" + form.email.data + "',crypt('" + form.password.data + "',gen_salt('bf')),'" + form.username.data + "','" + form.name.data + "','" + depart_name + "')") flash( "You will be notified through email regarding the registration request." ) return redirect(url_for('login.login')) cursor.execute("SELECT department_name FROM departments ") temp = cursor.fetchall() return render_template('Authentication/register.html', form=form, items=temp)
def workflows(): employee_typ = session['employee_typ'] login_employee = session['login_employee'] if employee_typ == 'role_dept': role_name = login_employee[8] department = login_employee[3] cursor.execute( "select * from workflow_details where workflow_id in (select workflow_id from workflow_accessed_by_emp_and_role_dept where role_name = %s and department_name = %s)", ( role_name, department, )) elif employee_typ == 'emp': role_name = 'employee' department = login_employee[3] cursor.execute( "select * from workflow_details where workflow_id in (select workflow_id from workflow_accessed_by_emp_and_role_dept where role_name = %s and department_name = %s)", ( role_name, department, )) else: role_name = login_employee[4] cursor.execute( "select * from workflow_details where workflow_id in (select workflow_id from workflow_accessed_by_role where role_name = %s)", (role_name, )) temp = cursor.fetchall() return render_template()
def action_on_request(email, action): if action == 'Approve': cursor.execute( "SELECT * FROM temp_data_storage_table where emp_email_id = %s", (email, )) temp = cursor.fetchone() cursor.execute("insert into users(username,name) values (%s,%s)", ( temp[2], temp[3], )) cursor.execute( "insert into employees(employee_email_id,password,username,department) values (%s,%s,%s,%s)", ( temp[0], temp[1], temp[2], temp[4], )) cursor.execute( "delete from temp_data_storage_table where emp_email_id = %s", (email, )) return redirect(url_for('system_admin.registration_requests'))
def registration_requests(): cursor.execute("select * from temp_data_storage_table") temp = cursor.fetchall() return render_template('system_admin/registration_requests.html', requests=temp)
def get_department_list(): cursor.execute("SELECT department_name FROM departments ") temp = cursor.fetchall() return temp
def login(): error = '' try: if request.method == "POST": cursor.execute("SELECT * from all_email WHERE '" + request.form.get('email_id') + "' = email") email = request.form['email_id'] password = request.form['pass'] temp = cursor.fetchone() print(temp) if temp == None: return render_template('index.html', msg='Email Id not registered') employee_type = temp[1] if employee_type == 'emp': cursor.execute("SELECT * FROM employees WHERE '" + email + "'= employee_email_id AND password = crypt('" + password + "',password) ") elif employee_type == 'role_dept': cursor.execute( "SELECT * FROM employees_holding_post_associated_with_department WHERE '" + email + "'=role_email_id and password=crypt('" + password + "',password)") else: cursor.execute( "SELECT * FROM employees_holding_post_not_associated_with_department WHERE '" + email + "'=post_email_id and password= crypt('" + password + "',password)") temp = cursor.fetchone() print(temp) if temp == None: return render_template('index.html', msg='Invalid credentials') # store the login position details in session as session['login_employee'] session['login_employee'] = temp session['emailid'] = email session['employee_typ'] = employee_type if employee_type == 'role_dept': cursor.execute( "SELECT username FROM employees WHERE employee_email_id = '" + temp[2] + "'") username_row = cursor.fetchone() username = username_row[0] else: username = temp[2] cursor.execute("SELECT * FROM users WHERE username = '******'") temp = cursor.fetchone() # store the users informations in session as session[login_user] session['login_user'] = temp if employee_type == 'emp': return render_template('Employee/home_page.html') elif employee_type == 'role_dept': return render_template('Role_dept/home_page.html') else: if session['login_employee'][4] == 'System Admin': return render_template('system_admin/home_page.html') elif session['login_employee'][4] == 'Admin': return render_template('Role/Admin/home_page.html') elif session['login_employee'][4] == 'Supervisor': return render_template('Role/Supervisor/home_page.html') else: return render_template('Role/Employee/home_page.html') return render_template("Authentication/index.html", error=error) except Exception as e: flash(e) return render_template("Authentication/index.html", error=error)