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))
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))