From a969dacd292a2999b2f554299e85dc19481a6f64 Mon Sep 17 00:00:00 2001 From: JWPCode Date: Mon, 22 Sep 2025 22:36:04 +1000 Subject: [PATCH 1/3] Finished feature, Have to format code now --- tabbycat/options/forms.py | 8 ++++++++ tabbycat/options/preferences.py | 20 +++++++++++++++++++ .../options/templates/preferences_index.html | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/tabbycat/options/forms.py b/tabbycat/options/forms.py index 31b2045d436..b3524dba981 100644 --- a/tabbycat/options/forms.py +++ b/tabbycat/options/forms.py @@ -49,6 +49,14 @@ def get_pref(name, section=section): def tournament_preference_form_builder(instance, preferences=[], **kwargs): + if kwargs.get('section') == 'all_sections': + + return preference_form_builder( + TournamentPreferenceForm, + preferences=[], + model={'instance': instance}, + ) + if kwargs.get('section') in [str(s) for s in global_preferences_registry.sections()]: # Check for global preferences return preference_form_builder(GlobalPreferenceForm, preferences, **kwargs) diff --git a/tabbycat/options/preferences.py b/tabbycat/options/preferences.py index c6865a2f930..2d77daf02ff 100644 --- a/tabbycat/options/preferences.py +++ b/tabbycat/options/preferences.py @@ -1,5 +1,6 @@ from decimal import Decimal +from django import forms from django.core.validators import EmailValidator, MinValueValidator, validate_slug from django.forms import SelectMultiple from django.utils.translation import gettext_lazy as _ @@ -17,6 +18,25 @@ from .types import MultiValueChoicePreference from .utils import validate_metric_duplicates + +# ============================================================================== +all_sections = Section('all_sections', verbose_name=_("All Preferances")) +# ============================================================================== + + +@tournament_preferences_registry.register +class DummyAllSectionsPreference(StringPreference): + section = all_sections + name = 'dummy_all_sections' + default = '' + verbose_name = 'All Sections Placeholder' + + def get_field_kwargs(self): + kwargs = super().get_field_kwargs() + kwargs['widget'] = forms.HiddenInput + return kwargs + + # ============================================================================== scoring = Section('scoring', verbose_name=_("Score Rules")) # ============================================================================== diff --git a/tabbycat/options/templates/preferences_index.html b/tabbycat/options/templates/preferences_index.html index 896e57f06af..dec31089346 100644 --- a/tabbycat/options/templates/preferences_index.html +++ b/tabbycat/options/templates/preferences_index.html @@ -82,6 +82,12 @@ {% trans "Settings which can affect all tournaments on the site" as description %} {% include "components/item-action.html" with type="primary" emoji="🌏" text=title extra=description %} + {% tournamenturl 'options-tournament-section' section='all_sections' as url %} + {% trans "Preferance List" as title %} + {% trans "All preferance options in one place" as description %} + {% include "components/item-action.html" with type="primary" emoji="📋" text=title extra=description %} + + From ba81909d3d5b85a882d5cda64accc66efee065a5 Mon Sep 17 00:00:00 2001 From: JWPCode Date: Mon, 22 Sep 2025 23:01:14 +1000 Subject: [PATCH 2/3] Changed some code formatting --- tabbycat/options/forms.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tabbycat/options/forms.py b/tabbycat/options/forms.py index b3524dba981..4b42489ad37 100644 --- a/tabbycat/options/forms.py +++ b/tabbycat/options/forms.py @@ -51,13 +51,9 @@ def get_pref(name, section=section): def tournament_preference_form_builder(instance, preferences=[], **kwargs): if kwargs.get('section') == 'all_sections': - return preference_form_builder( - TournamentPreferenceForm, - preferences=[], - model={'instance': instance}, - ) + return preference_form_builder(TournamentPreferenceForm, preferences=[], model={'instance': instance}) - if kwargs.get('section') in [str(s) for s in global_preferences_registry.sections()]: + elif kwargs.get('section') in [str(s) for s in global_preferences_registry.sections()]: # Check for global preferences return preference_form_builder(GlobalPreferenceForm, preferences, **kwargs) From 5034a4325d7b55b4c4755d60d5975c09f185dc95 Mon Sep 17 00:00:00 2001 From: JWPCode <129910942+JWPCode@users.noreply.github.com> Date: Sun, 11 Jan 2026 22:16:33 +1000 Subject: [PATCH 3/3] Fixed spelling errors from my previous commits Co-authored-by: Teymour Aldridge --- tabbycat/options/preferences.py | 2 +- tabbycat/options/templates/preferences_index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tabbycat/options/preferences.py b/tabbycat/options/preferences.py index 2d77daf02ff..459b9b99060 100644 --- a/tabbycat/options/preferences.py +++ b/tabbycat/options/preferences.py @@ -20,7 +20,7 @@ # ============================================================================== -all_sections = Section('all_sections', verbose_name=_("All Preferances")) +all_sections = Section('all_sections', verbose_name=_("All Preferences")) # ============================================================================== diff --git a/tabbycat/options/templates/preferences_index.html b/tabbycat/options/templates/preferences_index.html index dec31089346..97495932001 100644 --- a/tabbycat/options/templates/preferences_index.html +++ b/tabbycat/options/templates/preferences_index.html @@ -83,8 +83,8 @@ {% include "components/item-action.html" with type="primary" emoji="🌏" text=title extra=description %} {% tournamenturl 'options-tournament-section' section='all_sections' as url %} - {% trans "Preferance List" as title %} - {% trans "All preferance options in one place" as description %} + {% trans "Preference List" as title %} + {% trans "All preference options in one place" as description %} {% include "components/item-action.html" with type="primary" emoji="📋" text=title extra=description %}