From 43c3b5ecfa7f5a105b8440eb63eaa3667e8e4cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Beaul=C3=A9?= Date: Sun, 6 Dec 2020 14:44:48 -0500 Subject: [PATCH 1/3] Only show declared winners in scores sheets A declared winners dropdown doesn't make much sense when the winner(s) are already explicitly selected. --- tabbycat/results/templates/ballot/ballot_set.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabbycat/results/templates/ballot/ballot_set.html b/tabbycat/results/templates/ballot/ballot_set.html index 29789653a92..c0b0e6ceb39 100644 --- a/tabbycat/results/templates/ballot/ballot_set.html +++ b/tabbycat/results/templates/ballot/ballot_set.html @@ -80,7 +80,7 @@

{% endif %} - {% if form.using_declared_winner %} + {% if form.using_declared_winner and form.has_scores %}
{% include "components/form-field.html" with field=sheet.declared_winner %}
From 4febe89817d4ab9e427fa1946c58ca600ba591a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Beaul=C3=A9?= Date: Sun, 13 Dec 2020 11:19:10 -0500 Subject: [PATCH 2/3] Don't cache tournaments/rounds for API views Getting odd intermittent 404 errors, and which were Django HTML rather than DRF JSON, so was either a wrong URL or the Tournament/Round not getting found. For that, the debate middleware will ignore API paths, and the properties in the API mixins will not use cached values, returning DRF 404s. --- tabbycat/api/mixins.py | 19 ++++++++++++++++--- tabbycat/utils/middleware.py | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tabbycat/api/mixins.py b/tabbycat/api/mixins.py index bdb00da7523..24e15a54e09 100644 --- a/tabbycat/api/mixins.py +++ b/tabbycat/api/mixins.py @@ -1,18 +1,25 @@ import operator +from rest_framework.generics import get_object_or_404 from rest_framework.permissions import IsAdminUser -from tournaments.mixins import RoundFromUrlMixin, TournamentFromUrlMixin +from tournaments.models import Round, Tournament from .permissions import APIEnabledPermission, IsAdminOrReadOnly, PublicIfReleasedPermission, PublicPreferencePermission -class TournamentAPIMixin(TournamentFromUrlMixin): +class TournamentAPIMixin: tournament_field = 'tournament' access_operator = operator.eq access_setting = True + @property + def tournament(self): + if not hasattr(self, "_tournament"): + self._tournament = get_object_or_404(Tournament, slug=self.kwargs['tournament_slug']) + return self._tournament + def lookup_kwargs(self): return {self.tournament_field: self.tournament} @@ -28,10 +35,16 @@ def get_serializer_context(self): return context -class RoundAPIMixin(TournamentAPIMixin, RoundFromUrlMixin): +class RoundAPIMixin(TournamentAPIMixin): tournament_field = 'round__tournament' round_field = 'round' + @property + def round(self): + if not hasattr(self, "_round"): + self._round = get_object_or_404(Round, tournament=self.tournament, seq=self.kwargs['round_seq']) + return self._round + def perform_create(self, serializer): serializer.save(**{self.round_field: self.round}) diff --git a/tabbycat/utils/middleware.py b/tabbycat/utils/middleware.py index 967fa68aeac..cce7f618aa2 100644 --- a/tabbycat/utils/middleware.py +++ b/tabbycat/utils/middleware.py @@ -14,7 +14,7 @@ def __call__(self, request): return response def process_view(self, request, view_func, view_args, view_kwargs): - if 'tournament_slug' in view_kwargs: + if 'tournament_slug' in view_kwargs and request.path.split('/')[1] != 'api': cached_key = "%s_%s" % (view_kwargs['tournament_slug'], 'object') cached_tournament_object = cache.get(cached_key) From 20d950224ffb56fe6d3a15d54bf194381aaf9cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Beaul=C3=A9?= Date: Sun, 13 Dec 2020 11:37:00 -0500 Subject: [PATCH 3/3] Prepare for 2.5.4 hotfix release --- .github/CHANGELOG.rst | 8 ++++++++ docs/conf.py | 2 +- tabbycat/settings/core.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/CHANGELOG.rst b/.github/CHANGELOG.rst index c6b2e0a3e32..283176dc2aa 100644 --- a/.github/CHANGELOG.rst +++ b/.github/CHANGELOG.rst @@ -2,6 +2,14 @@ Change Log ========== +2.5.4 +----- +*Release date: 14 December 2020* + +- Corrected a conflict in ballots when using declared winners without scores +- Removed tournament/round caching from API views + + 2.5.3 ----- *Release date: 7 December 2020* diff --git a/docs/conf.py b/docs/conf.py index 40aaa10c01d..8580e5ce3bb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,7 +60,7 @@ # The short X.Y version. version = '2.5' # The full version, including alpha/beta/rc tags. -release = '2.5.3' +release = '2.5.4' rst_epilog = """ .. |vrelease| replace:: v{release} diff --git a/tabbycat/settings/core.py b/tabbycat/settings/core.py index 3a1b3d1d2b1..e88338fbf81 100644 --- a/tabbycat/settings/core.py +++ b/tabbycat/settings/core.py @@ -22,9 +22,9 @@ # Version # ============================================================================== -TABBYCAT_VERSION = '2.5.3' +TABBYCAT_VERSION = '2.5.4' TABBYCAT_CODENAME = 'Nebelung' -READTHEDOCS_VERSION = 'v2.5.3' +READTHEDOCS_VERSION = 'v2.5.4' # ============================================================================== # Internationalization and Localization