def retrieve(self, request): current_request_profile = model_access.get_self(request.user.username) serializer = serializers.ProfileSerializer(current_request_profile, context={ 'request': request, 'self': True }) return Response(serializer.data)
def update(self, request): current_request_profile = model_access.get_self(request.user.username) serializer = serializers.ProfileSerializer(current_request_profile, data=request.data, context={'request': request}, partial=True) if not serializer.is_valid(): logger.error('{0!s}'.format(serializer.errors)) raise errors.ValidationException('{0!s}'.format(serializer.errors)) serializer.save() return Response(serializer.data, status=status.HTTP_200_OK)
def update(self, request, pk=None): current_request_profile = model_access.get_self(request.user.username) if current_request_profile.highest_role() != 'APPS_MALL_STEWARD': raise errors.PermissionDenied profile_instance = self.get_queryset().get(pk=pk) serializer = serializers.ProfileSerializer(profile_instance, data=request.data, context={'request': request}, partial=True) if not serializer.is_valid(): logger.error('{0!s}'.format(serializer.errors)) raise errors.RequestException('{0!s}'.format(serializer.errors)) serializer.save() return Response(serializer.data, status=status.HTTP_200_OK)