def admin_page_project(): if current_user.admin: form = AdminAssignForm() list1 = P_Info.query.filter_by(visibility=True).all() list = einfo.query.filter_by(admin=0, visibility=True).all() if request.method == 'POST': pnames = request.form.get('pnames') field = request.form.get('field') enames = request.form.get('enames') if pnames and enames: P_id = P_Info.query.filter_by(P_Name=pnames).first() E_id = einfo.query.filter_by(E_Name=enames).first() if P_id: P_id = P_Info.query.filter_by(P_Name=pnames).first().P_id if E_id: E_id = einfo.query.filter_by(E_Name=enames).first().id timeshift = TimeShift(id=E_id, Field=field, P_id=P_id, Verified=False) db.session.add(timeshift) db.session.commit() return render_template('admin_page_project.html', logo=logo, form=form, list=list, list1=list1) else: logout_user() return redirect(url_for('login'))
def user_page_RNA(): form = ReportNonAssignForm() if current_user.admin == 0: list1 = P_Info.query.filter_by(visibility=True).all() if form.validate_on_submit(): pnames = request.form.get('pnames') P_id = P_Info.query.filter_by(P_Name=pnames).first() date = form.date.data date_str = date.strftime('%d-%m-%y') head = form.Head.data house = form.House.data time_form = form.Time.data Description = form.Description.data Field = form.Field.data timeshift = TimeShift(id=current_user.id, P_id=P_id.P_id, Date=date_str, Head=head, House=house, Time=time_form, Description=Description, Field=Field, Verified=True) db.session.add(timeshift) db.session.commit() return redirect(url_for('user_page_RNA')) return render_template('user_page_RNA.html', logo=logo, form=form, list1=list1) else: logout_user() return redirect(url_for('login'))