Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support showing multiple concurrent 'news' entities #348

Closed
krestenlaust opened this issue Aug 26, 2023 · 3 comments
Closed

Support showing multiple concurrent 'news' entities #348

krestenlaust opened this issue Aug 26, 2023 · 3 comments

Comments

@krestenlaust
Copy link
Member

krestenlaust commented Aug 26, 2023

Currently, if multiple news entries are concurrent, an error is returned when accessing the frontpage.
Error on frontpage

In case, there's no interest in implementing support for multiple news entities, then adding a warning to the admin interface when multiple news entities are overlapping, would be appropriate imo.

Traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/1/

Django Version: 2.2.28
Python Version: 3.6.13
Installed Applications:
['stregsystem',
'stregreport',
'kiosk',
'django_select2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'debug_toolbar']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'stregsystem.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware']

Traceback:

File "C:\ProgramData\miniconda3\envs\stregsystem\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)

File "C:\ProgramData\miniconda3\envs\stregsystem\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)

File "C:\ProgramData\miniconda3\envs\stregsystem\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\kress\source\repos\stregsystemet\stregsystem\views.py" in index
77. news = __get_news()

File "C:\Users\kress\source\repos\stregsystemet\stregsystem\views.py" in __get_news
57. return News.objects.filter(stop_date__gte=timezone.now(), pub_date__lte=timezone.now()).get()

File "C:\ProgramData\miniconda3\envs\stregsystem\lib\site-packages\django\db\models\query.py" in get
412. (self.model._meta.object_name, num)

Exception Type: MultipleObjectsReturned at /1/
Exception Value: get() returned more than one News -- it returned 2!

@falkecarlsen
Copy link
Member

this is duplicate of #346, as the solution that I imagine to concurrent news is the approach we have for kiosk; fetching a random valid entry

@krestenlaust
Copy link
Member Author

Wow, I even participated in that thread without realising it was to solve this issue. (Personally, I prefer issue naming be issue/feature oriented, and let pull requests be implementation oriented e.g. respectively, what the problem is, and what the solution is)

While random is a simple solution to the problem, I don't see the problem with simply serving the news in an sequential order. As far as I understand, the reasoning for it being random in kiosk, is that there's multiple screens with kiosk-view, and it's preferable for them to display different items at once. Not my call to make though.

@krestenlaust
Copy link
Member Author

Technically resolved by #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants