Advertisement
Mochinov

Untitled

Nov 13th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. def add_a_doctor(request, id):
  2. polyclinic = Polyclinic.objects.get(id=id)
  3. login = request.POST.get('login')
  4. fio = request.POST.get('fio')
  5. specialty = request.POST.get('specialty')
  6. phone = request.POST.get('phone')
  7. drivers_license = request.POST.get('drivers_license')
  8. position = request.POST.get('position')
  9. password = generate_password()
  10. logging.info(' login : %s, fio : %s,specialty : %s, phone : %s, drivers_license : %s, position : %s ' % (login,fio,specialty, phone,drivers_license,position))
  11.  
  12. try:
  13. account = User.objects.get(username = login)
  14. except Exception as e:
  15. account = User.objects.create(username = login, password = password)
  16. doctor = Doctor.objects.create(
  17. fio=fio,
  18. phone=phone,
  19. specialty=specialty,
  20. polyclinic = polyclinic,
  21. town = polyclinic.town,
  22. user = account,
  23. position = position,
  24. drivers_license = drivers_license,
  25. password = password
  26. )
  27. return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement