コード例 #1
0
ファイル: api.py プロジェクト: wilsonc86/ledger
 def make_admin_user(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = OrgUserAcceptSerializer(data=request.data)
         serializer.is_valid(raise_exception=True)
         user_obj = EmailUser.objects.get(
             email=serializer.validated_data['email'])
         instance.make_admin_user(user_obj, request)
         serializer = self.get_serializer(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))
コード例 #2
0
ファイル: api.py プロジェクト: wilsonc86/ledger
 def relink_user(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = OrgUserAcceptSerializer(data=request.data)
         serializer.is_valid(raise_exception=True)
         user_obj = EmailUser.objects.get(
             email = serializer.validated_data['email']
             )
         instance.relink_user(user_obj,request)
         serializer = self.get_serializer(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))