Esempio n. 1
0
 def amendment_request(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         instance.amendment_request(request)
         serializer = OrganisationRequestSerializer(instance)
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(repr(e.error_dict))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))
Esempio n. 2
0
 def assign_to(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         user_id = request.data.get('user_id', None)
         user = None
         if not user_id:
             raise serializers.ValiationError('A user id is required')
         try:
             user = EmailUser.objects.get(id=user_id)
         except EmailUser.DoesNotExist:
             raise serializers.ValidationError(
                 'A user with the id passed in does not exist')
         instance.assign_to(user, request)
         serializer = OrganisationRequestSerializer(instance)
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(repr(e.error_dict))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))