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)
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)
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)
def get(self, request, *args, **kwargs): data = serializers.MainUserSerializer(request.user) return Response(data.data)
def get(self, request, *args, **kwargs): coordinators = models.MainUser.objects.filter(is_moderator=True) data = serializers.MainUserSerializer(coordinators, many=True) return Response(data.data)
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)
def get(self, request, *args, **kwargs): experts = models.MainUser.objects.filter(is_expert=True) data = serializers.MainUserSerializer(experts, many=True) return Response(data.data)