Exemple #1
0
 def assign_to(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         user_id = request.data.get('assessor_id', None)
         user = None
         if not user_id:
             raise serializers.ValidationError('An assessor 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_officer(request, user)
         serializer = InternalProposalSerializer(
             instance, context={'request': request})
         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))
Exemple #2
0
 def reissue_approval(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         status = request.data.get('status')
         if not status:
             raise serializers.ValidationError('Status is required')
         else:
             if not status in ['with_approver']:
                 raise serializers.ValidationError(
                     'The status provided is not allowed')
         instance.reissue_approval(request, status)
         serializer = InternalProposalSerializer(
             instance, context={'request': request})
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         if hasattr(e, 'error_dict'):
             raise serializers.ValidationError(repr(e.error_dict))
         else:
             raise serializers.ValidationError(repr(e[0].encode('utf-8')))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))
Exemple #3
0
 def resend(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         instance.resend(request)
         serializer = InternalProposalSerializer(
             instance.proposal, context={'request': request})
         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))
Exemple #4
0
 def assesor_send_referral(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = SendReferralSerializer(data=request.data)
         serializer.is_valid(raise_exception=True)
         instance.send_referral(request, serializer.validated_data['email'])
         serializer = InternalProposalSerializer(
             instance, context={'request': request})
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         if hasattr(e, 'error_dict'):
             raise serializers.ValidationError(repr(e.error_dict))
         else:
             raise serializers.ValidationError(repr(e[0].encode('utf-8')))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))
Exemple #5
0
 def internal_proposal(self, request, *args, **kwargs):
     instance = self.get_object()
     serializer = InternalProposalSerializer(instance,
                                             context={'request': request})
     return Response(serializer.data)