From f809db0430987841fb4dda691e20d56d7706d33d Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Mon, 5 Oct 2020 12:07:04 +0200 Subject: [PATCH] Attempt to fix some tracebacks --- server/openslides/agenda/models.py | 1 + server/openslides/users/views.py | 4 ++++ server/openslides/utils/autoupdate.py | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/server/openslides/agenda/models.py b/server/openslides/agenda/models.py index b3fddb52d..6167e00be 100644 --- a/server/openslides/agenda/models.py +++ b/server/openslides/agenda/models.py @@ -432,6 +432,7 @@ class SpeakerManager(models.Manager): """ if isinstance(user, AnonymousUser): raise OpenSlidesError("An anonymous user can not be on lists of speakers.") + if self.filter( user=user, list_of_speakers=list_of_speakers, begin_time=None ).exists(): diff --git a/server/openslides/users/views.py b/server/openslides/users/views.py index cc6ed75bf..781a7655a 100644 --- a/server/openslides/users/views.py +++ b/server/openslides/users/views.py @@ -847,6 +847,10 @@ class WhoAmIDataView(APIView): user_full_data = async_to_sync(element_cache.get_element_data)( self.request.user.get_collection_string(), user_id ) + if user_full_data is None: + return Response( + {"detail": "Cache offline, could not fetch user"}, status=500 + ) auth_type = user_full_data["auth_type"] user_data = async_to_sync(element_cache.restrict_element_data)( user_full_data, self.request.user.get_collection_string(), user_id diff --git a/server/openslides/utils/autoupdate.py b/server/openslides/utils/autoupdate.py index fba9626ad..b77ba101f 100644 --- a/server/openslides/utils/autoupdate.py +++ b/server/openslides/utils/autoupdate.py @@ -8,6 +8,7 @@ from channels.layers import get_channel_layer from django.db.models import Model from mypy_extensions import TypedDict +from .auth import UserDoesNotExist from .cache import ChangeIdTooLowError, element_cache, get_element_id from .projector import get_projector_data from .timing import Timing @@ -303,6 +304,15 @@ class AutoupdateBundleMiddleware: async def get_autoupdate_data( from_change_id: int, user_id: int +) -> Tuple[int, Optional[AutoupdateFormat]]: + try: + return await _get_autoupdate_data(from_change_id, user_id) + except UserDoesNotExist: + return 0, None + + +async def _get_autoupdate_data( + from_change_id: int, user_id: int ) -> Tuple[int, Optional[AutoupdateFormat]]: """ Returns the max_change_id and the autoupdate from from_change_id to max_change_id