Exemplo n.º 1
0
 def accept(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         instance.accept(request)
         serializer = InternalComplianceSerializer(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))
Exemplo 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 = InternalComplianceSerializer(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))
Exemplo n.º 3
0
 def internal_compliance(self, request, *args, **kwargs):
     instance = self.get_object()
     serializer = InternalComplianceSerializer(instance,
                                               context={'request': request})
     return Response(serializer.data)