コード例 #1
0
 def test_page_status_for_non_doctor_user(self):
     tmp_user = create_test_user(username='******', password='******')
     patient = Patient()
     patient.save()
     SystemUser.objects.create(user=tmp_user,
                               id_code='123456',
                               role=patient)
     self.client.login(username='******', password='******')
     response = self.client.get(reverse_lazy('addClinic'))
     self.assertNotEqual(response.status_code, 200)
コード例 #2
0
 def post(request):
     username = request.POST.get('username', None)
     user = User.objects.get(username=username).system_user
     last_user_role = user.role
     patient_role = Patient()
     patient_role.save()
     user.role = patient_role
     user.save()
     last_user_role.delete()
     return JsonResponse({})
コード例 #3
0
ファイル: user_views.py プロジェクト: hosseinvand/Clinic
 def form_valid(self, form):
     response = super(SystemUserCreateView, self).form_valid(form)
     username, password = form.cleaned_data.get(
         'username'), form.cleaned_data.get('password')
     new_user = authenticate(username=username, password=password)
     user = User.objects.get(username=username)
     role = Patient()
     role.save()
     SystemUser.objects.filter(user=user).update(role=role)
     login(self.request, new_user)
     return response
コード例 #4
0
 def create_system_user(self, data=user_data, should_login=False):
     user_count = User.objects.all().count()
     system_user_count = SystemUser.objects.all().count()
     if should_login:
         self.client.post(reverse_lazy('register'), data)
     else:
         tmp_user = create_test_user(**data)
         role = Patient()
         role.save()
         SystemUser.objects.create(user=tmp_user, id_code=data['id_code'])
         SystemUser.objects.filter(user=tmp_user).update(role=role)
     user = User.objects.filter(username=data['username'])
     self.assertTrue(user.exists())
     self.assertTrue(SystemUser.objects.filter(user=user[0]).exists())
     self.assertTrue(SystemUser.objects.filter(id_code=data['id_code']).exists())
     self.assertEqual(User.objects.all().count(), user_count + 1, "db doesn't changed")
     self.assertEqual(SystemUser.objects.all().count(), system_user_count + 1, "db doesn't changed")
     return SystemUser.objects.get(user=user)
コード例 #5
0
ファイル: utils.py プロジェクト: hosseinvand/Clinic
def create_test_system_user(user, id_code):
    patient = Patient()
    patient.save()
    return SystemUser.objects.create(user=user, id_code=id_code, role=patient)