Advertisement
Rich_A

local variable 'password' reference before assignment.

Feb 1st, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. @app.route('/admin/new_nurse', methods=['GET','POST'])
  2. @login_required
  3. def create_nurse():
  4. form=NurseForm()
  5. x=time.strftime("%H:%M:%S")
  6. if (x>=('00:00:00')and x<=('11:59:59')):
  7. x=(str('Good Morning'))
  8. elif x>=('12:00:00')and x<=('15:59:59'):
  9. x=(str('Good Afternoon'))
  10. elif x>=('16:00:00')and x<=('23:59:59'):
  11. x=(str('Good Evening'))
  12.  
  13. if form.validate_on_submit():
  14. if form.picture.data:
  15. picture_file = save_picture(form.picture.data)
  16. firstname=request.form['fname']
  17. surname=request.form['sname']
  18. date_of_birth=request.form['dob']
  19. age_of_nurse=request.form['age']
  20. sex_option=request.form['sexoption']
  21. nurse_telephone=request.form['telnumber']
  22. educational_status=request.form['educationalstatus']
  23. Postal_Address=request.form['postaladdress']
  24. House_No=request.form['houseno']
  25. locality=request.form['locality']
  26. dept=request.form['dpt']
  27. username=form.username.data
  28. email=form.email.data
  29. password=form.password.data
  30. relative_info=request.form['relative']
  31. hashed_password=
  32. bcrypt.generate_password_hash(password).decode('utf-8')
  33.  
  34. Nurse = User(username=form.username.data,email=email,password=hashed_password,date_created=datetime.datetime.now(),
  35. image_file=picture_file,first_name=firstname,Sur_name=surname,date_of_birth=date_of_birth,age=age_of_nurse, sex=sex_option,
  36. telephone=nurse_telephone,educational_status=educational_status,postal_address=Postal_Address,
  37. home_address=House_No,locality=locality,relative_name=relative_info,profile='')
  38. assign_Dept=Department.query.filter_by(name=dept).first()
  39. assign_role=Role.query.filter_by(id=3).first()
  40. assign_role.main_role.append(Nurse)
  41. assign_Dept.main_dept.append(Nurse)
  42. db.session.add(Nurse)
  43. db.session.commit()
  44. flash(f'Account created for {form.username.data}', 'success')
  45. data=[{'sex':'Male'}, {'sex':'Female'}]
  46. result=Department.query.with_entities(Department.name)
  47. return render_template('addnurse.html',x=x, title="New_Nurse",li="New Nurse", form=form,data=data,result=result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement