diff --git a/tabbycat/options/forms.py b/tabbycat/options/forms.py index 31b2045d436..4b42489ad37 100644 --- a/tabbycat/options/forms.py +++ b/tabbycat/options/forms.py @@ -49,7 +49,11 @@ def get_pref(name, section=section): def tournament_preference_form_builder(instance, preferences=[], **kwargs): - if kwargs.get('section') in [str(s) for s in global_preferences_registry.sections()]: + if kwargs.get('section') == 'all_sections': + + return preference_form_builder(TournamentPreferenceForm, preferences=[], model={'instance': instance}) + + 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) diff --git a/tabbycat/options/preferences.py b/tabbycat/options/preferences.py index c6865a2f930..459b9b99060 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 Preferences")) +# ============================================================================== + + +@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..97495932001 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 "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 %} + +