예제 #1
0
파일: patients.py 프로젝트: ganap/so
    def post(self, request, *args, **kwargs):
        is_admin = getattr(request.user, 'is_admin', None)
        is_moderator = getattr(request.user, 'is_moderator', None)
        if not is_admin or not is_moderator:
            return Response({}, status.HTTP_403_FORBIDDEN)
        data = dict(request.data)
        send_mail = not data['send_email']
        patient = users.CreateUser(data['username'],
                                   data['email'],
                                   password=data['password'],
                                   unittest=send_mail)

        patient_mongo = fhir_users.Patient(
            owner=patient.pk,
            name=creator.HumanName(data['patient']['name']),
            degree=data['patient']['degree'],
            speciality=data['patient']['speciality'],
            clinical_patientise=data['patient']['clinical_patientise'],
            link_to_drupal=data['patient']['link_to_drupal'])
        patient_mongo.save()
        patient.is_patient = True
        patient.patient = str(patient_mongo.pk)
        patient.save()
        data = serializers.MainUserSerializer(patient)
        return Response(data.data, status.HTTP_201_CREATED)
예제 #2
0
 def get(self, request, *args, **kwargs):
     is_moderator = getattr(request.user, 'is_moderator', False)
     if not is_moderator:
         return Response({}, status.HTTP_403_FORBIDDEN)
     users = models.MainUser.objects.filter(is_admin=False,
                                            is_moderator=False,
                                            is_expert=False)
     data = profile_serializers.MainUserSerializer(users, many=True)
     return Response(data.data)
예제 #3
0
 def post(self, request, *args, **kwargs):
     is_admin = getattr(request.user, 'is_admin', None)
     if not is_admin:
         return Response({}, status.HTTP_403_FORBIDDEN)
     data = dict(request.data)
     send_mail = not data['send_email']
     coordinator = users.CreateUser(data['username'],
                                    data['email'],
                                    password=data['password'],
                                    unittest=send_mail)
     coordinator.is_moderator = True
     coordinator.save()
     data = serializers.MainUserSerializer(coordinator)
     return Response(data.data, status.HTTP_201_CREATED)
예제 #4
0
파일: profile_helpers.py 프로젝트: ganap/so
 def get(self, request, *args, **kwargs):
     data = serializers.MainUserSerializer(request.user)
     return Response(data.data)
예제 #5
0
 def get(self, request, *args, **kwargs):
     coordinators = models.MainUser.objects.filter(is_moderator=True)
     data = serializers.MainUserSerializer(coordinators, many=True)
     return Response(data.data)
예제 #6
0
파일: patients.py 프로젝트: ganap/so
 def get(self, request, *args, **kwargs):
     patients = models.MainUser.objects.filter(is_expert=False,
                                               is_moderator=False,
                                               is_admin=False)
     data = serializers.MainUserSerializer(patients, many=True)
     return Response(data.data)
예제 #7
0
파일: experts.py 프로젝트: ganap/so
 def get(self, request, *args, **kwargs):
     experts = models.MainUser.objects.filter(is_expert=True)
     data = serializers.MainUserSerializer(experts, many=True)
     return Response(data.data)