Exemplo n.º 1
0
 def update_personal(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = PersonalSerializer(instance,data=request.data)
         serializer.is_valid(raise_exception=True)
         with transaction.atomic():
             instance = serializer.save()
             instance.log_user_action(EmailUserAction.ACTION_PERSONAL_DETAILS_UPDATE.format(
             '{} {} ({})'.format(instance.first_name, instance.last_name, instance.email)), request)
         serializer = UserSerializer(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 update_personal(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = PersonalSerializer(instance, data=request.data)
         serializer.is_valid(raise_exception=True)
         with transaction.atomic():
             instance = serializer.save()
             instance.log_user_action(
                 EmailUserAction.ACTION_PERSONAL_DETAILS_UPDATE.format(
                     '{} {} ({})'.format(
                         instance.first_name,
                         instance.last_name,
                         instance.email)),
                 request)
         serializer = UserSerializer(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 get(self, request, format=None):
     serializer = PersonalSerializer(request.user)
     return Response(serializer.data)