From 333b04a01be0ab420360d2556e9e49e5f755613b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 May 2020 16:04:53 +0200 Subject: [PATCH] Order tables --- apps/tournament/forms.py | 2 +- apps/tournament/tables.py | 2 ++ apps/tournament/views.py | 3 ++- tfjm/settings.py | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/tournament/forms.py b/apps/tournament/forms.py index a5eca06..9518d97 100644 --- a/apps/tournament/forms.py +++ b/apps/tournament/forms.py @@ -30,7 +30,7 @@ class TournamentForm(forms.ModelForm): class Meta: model = Tournament - fields = '__all__' + exclude = ('year',) widgets = { "price": AmountInput(), "date_start": DatePickerInput(), diff --git a/apps/tournament/tables.py b/apps/tournament/tables.py index e16b0fa..7e22749 100644 --- a/apps/tournament/tables.py +++ b/apps/tournament/tables.py @@ -26,6 +26,7 @@ class TournamentTable(tables.Table): attrs = { 'class': 'table table-condensed table-striped table-hover' } + order_by = ('date_start', 'name',) class TeamTable(tables.Table): @@ -40,6 +41,7 @@ class TeamTable(tables.Table): attrs = { 'class': 'table table-condensed table-striped table-hover' } + order_by = ('-validation_status', 'trigram',) class SolutionTable(tables.Table): diff --git a/apps/tournament/views.py b/apps/tournament/views.py index 49c6478..3b7ea6d 100644 --- a/apps/tournament/views.py +++ b/apps/tournament/views.py @@ -427,7 +427,8 @@ class PoolListView(LoginRequiredMixin, SingleTableView): qs = qs.filter(Q(juries=user) | Q(teams__tournament__organizers=user)) elif user.participates: qs = qs.filter(teams=user.team) - return qs.distinct() + qs = qs.distinct().order_by('teams__tournament__date_start', 'teams__tournament__name', 'round',) + return qs class PoolCreateView(AdminMixin, CreateView): diff --git a/tfjm/settings.py b/tfjm/settings.py index 3b6d20b..46a2edc 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -157,6 +157,8 @@ USE_TZ = True LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")] +FIXTURE_DIRS = [os.path.join(BASE_DIR, "tfjm/fixtures")] + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/