Esempio n. 1
0
              paramType: header
        responseMessages:
            - code: 200
              message: OK
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        if Note.objects.exists(pk=pk):
            note = Note.objects.get(id=pk)
            if Patient.objects.exists(pk=note.patient_id):
                patient = Patient.objects.get(id=pk)
                if User.objects.exists_user(pk=patient.user_id):
                    user = User.objects.get(id=patient.user_id)
                    if has_permission(request.META, user):
                        note.delete()
                        return Response(status=status.HTTP_200_OK)
                    return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)


router.register_nested(r'patients',
                       r'notes',
                       NotePatientViewSet,
                       parent_lookup_name='patient',
                       base_name='notes')
router.register(r'notes', NoteViewSet, base_name='note')
Esempio n. 2
0
            device_os=request.data.get("device_os")
            if device_token and device_os:
                device = Device.objects.register(
                    device_token=device_token,
                    device_os=device_os,
                    user=user)

            response_serializer = LoginResponseSerializer()
            return Response(response_serializer.get_token(user))

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


router.register(
    r'auth',
    LoginViewSet,
    base_name="signin",
    router_class=SingleObjectRouter
)
router.register(
    r'auth',
    RecoveryPasswordViewSet,
    base_name="recovery-password",
    router_class=SingleObjectRouter
)
router.register(
    r'auth',
    ResetPasswordWithCodeViewSet,
    base_name="reset-password-code",
    router_class=SingleObjectRouter
)
router.register(
Esempio n. 3
0
        omit_parameters:
            - form
        parameters:
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 200
              message: OK
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        if Subscription.objects.exists(pk=pk):
            subscription = Subscription.objects.get(pk=pk)
            if has_permission(request.META):
                subscription.delete()
                return Response(status=status.HTTP_200_OK)
            return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)


router.register(r'subscriptions',
                SubscriptionViewSet,
                base_name='subscriptions')
Esempio n. 4
0
        """
        if Card.objects.exists(pk=pk):
            card = Card.objects.get(id=pk)
            if User.objects.exists_user(pk=card.user_id):
                user = User.objects.get(id=card.user_id)
                if has_permission(request.META, user):
                    card_deleted = conekta_sita.delete_card(user=user, card=card)
                    card.delete()
                    card = Card.objects.filter(user_id=user.id)
                    if card:
                        card_default = conekta_sita.set_default_card(user=user, card=card[0])
                        card[0].is_default = True
                        card[0].save()
                    print card
                    return Response(status=status.HTTP_200_OK)
            return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)

router.register_nested(
    r'users',
    r'cards',
    CardUserViewSet,
    parent_lookup_name='user',
    base_name='cards'
)
router.register(
    r'cards',
    CardViewSet,
    base_name='card'
)
Esempio n. 5
0
        response_serializer: UserListSerializer
        parameters:
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
            - name: q
              description: Search word.
              paramType: query
              type: string
        responseMessages:
            - code: 200
              message: OK
            - code: 401
              message: UNAUTHORIZED
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        # Verify if the user has permission to use
        if has_permission(request.META):
            return super(UserViewSet, self).list(request, *args, **kwargs)
        return Response(status=status.HTTP_401_UNAUTHORIZED)


router.register(r'users', UserViewSet, base_name='user')
Esempio n. 6
0
        consumes:
            - application/json
        produces:
            - application/json
        """
        if Patient.objects.exists(pk=pk):
            patient = Patient.objects.get(pk=pk)
            if User.objects.exists_user(pk=patient.user_id):
                user = User.objects.get(id=patient.user_id)
                if patient.user_id == user.id and patient.is_active:
                    if has_permission(request.META, user):
                        patient.is_active = False
                        patient.save()
                        return Response(status=status.HTTP_200_OK)
                    return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)

router.register_nested(
    r'users',
    r'patients',
    PatientUserViewSet,
    parent_lookup_name='user',
    base_name='patients'
)

router.register(
    r'patients',
    PatientViewSet,
    base_name='patient'
)