Catch some tracebacks
This commit is contained in:
parent
7277a1bb01
commit
582215042d
@ -6,6 +6,7 @@ from django.contrib.auth import get_user_model
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Case, When
|
from django.db.models import Case, When
|
||||||
from django.db.models.deletion import ProtectedError
|
from django.db.models.deletion import ProtectedError
|
||||||
|
from django.db.utils import IntegrityError
|
||||||
from django.http.request import QueryDict
|
from django.http.request import QueryDict
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
|
||||||
@ -514,7 +515,10 @@ class MotionViewSet(TreeSortMixin, ModelViewSet):
|
|||||||
and not motion.is_supporter(request.user)
|
and not motion.is_supporter(request.user)
|
||||||
):
|
):
|
||||||
raise ValidationError({"detail": "You can not support this motion."})
|
raise ValidationError({"detail": "You can not support this motion."})
|
||||||
motion.supporters.add(request.user)
|
try:
|
||||||
|
motion.supporters.add(request.user)
|
||||||
|
except IntegrityError:
|
||||||
|
raise ValidationError({"detail": "You are already a supporter."})
|
||||||
# Send new supporter via autoupdate because users without permission
|
# Send new supporter via autoupdate because users without permission
|
||||||
# to see users may not have it but can get it now.
|
# to see users may not have it but can get it now.
|
||||||
# TODO: Skip history.
|
# TODO: Skip history.
|
||||||
|
@ -6,6 +6,7 @@ from django.db import models
|
|||||||
|
|
||||||
from . import logging
|
from . import logging
|
||||||
from .access_permissions import BaseAccessPermissions
|
from .access_permissions import BaseAccessPermissions
|
||||||
|
from .auth import UserDoesNotExist
|
||||||
from .autoupdate import AutoupdateElement, inform_changed_data, inform_elements
|
from .autoupdate import AutoupdateElement, inform_changed_data, inform_elements
|
||||||
from .rest_api import model_serializer_classes
|
from .rest_api import model_serializer_classes
|
||||||
from .utils import convert_camel_case_to_pseudo_snake_case, get_element_id
|
from .utils import convert_camel_case_to_pseudo_snake_case, get_element_id
|
||||||
@ -185,7 +186,12 @@ class RESTModelMixin:
|
|||||||
"""
|
"""
|
||||||
Converts a list of elements from full_data to restricted_data.
|
Converts a list of elements from full_data to restricted_data.
|
||||||
"""
|
"""
|
||||||
return await cls.get_access_permissions().get_restricted_data(elements, user_id)
|
try:
|
||||||
|
return await cls.get_access_permissions().get_restricted_data(
|
||||||
|
elements, user_id
|
||||||
|
)
|
||||||
|
except UserDoesNotExist:
|
||||||
|
return []
|
||||||
|
|
||||||
def get_full_data(self) -> Dict[str, Any]:
|
def get_full_data(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user