Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tabbycat/options/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 20 additions & 0 deletions tabbycat/options/preferences.py
Original file line number Diff line number Diff line change
@@ -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 _
Expand All @@ -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"))
# ==============================================================================
Expand Down
6 changes: 6 additions & 0 deletions tabbycat/options/templates/preferences_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}


</ul>
</div>

Expand Down