1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:02:22 +00:00

Order participations by validity status and by trigram

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-04-11 22:41:52 +02:00
parent 59268f2d1e
commit 0e7a275a28
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
5 changed files with 35 additions and 6 deletions

View File

@ -0,0 +1,20 @@
# Generated by Django 4.2 on 2023-04-11 20:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("participation", "0007_note_observer_oral_passage_observer"),
]
operations = [
migrations.AlterModelOptions(
name="participation",
options={
"ordering": ("valid", "team__trigram"),
"verbose_name": "participation",
"verbose_name_plural": "participations",
},
),
]

View File

@ -341,6 +341,7 @@ class Participation(models.Model):
class Meta: class Meta:
verbose_name = _("participation") verbose_name = _("participation")
verbose_name_plural = _("participations") verbose_name_plural = _("participations")
ordering = ('valid', 'team__trigram',)
class Pool(models.Model): class Pool(models.Model):

View File

@ -54,6 +54,7 @@ class ParticipationTable(tables.Table):
} }
model = Team model = Team
fields = ('name', 'trigram', 'valid',) fields = ('name', 'trigram', 'valid',)
order = ('-valid',)
class TournamentTable(tables.Table): class TournamentTable(tables.Table):

View File

@ -24,7 +24,7 @@ from django.utils.crypto import get_random_string
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView, DetailView, FormView, RedirectView, TemplateView, UpdateView, View from django.views.generic import CreateView, DetailView, FormView, RedirectView, TemplateView, UpdateView, View
from django.views.generic.edit import FormMixin, ProcessFormView from django.views.generic.edit import FormMixin, ProcessFormView
from django_tables2 import SingleTableView from django_tables2 import SingleTableView, MultiTableMixin
from magic import Magic from magic import Magic
from odf.opendocument import OpenDocumentSpreadsheet from odf.opendocument import OpenDocumentSpreadsheet
from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties
@ -555,16 +555,24 @@ class TournamentUpdateView(VolunteerMixin, UpdateView):
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
class TournamentDetailView(DetailView): class TournamentDetailView(MultiTableMixin, DetailView):
""" """
Display tournament detail. Display tournament detail.
""" """
model = Tournament model = Tournament
def dispatch(self, request, *args, **kwargs):
self.tables = [
ParticipationTable(self.get_object().participations.all()),
PoolTable(self.get_object().pools.order_by('id').all()),
]
return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["teams"] = ParticipationTable(self.object.participations.all()) tables = context['tables']
context["pools"] = PoolTable(self.object.pools.order_by('id').all()) context["teams"] = tables[0]
context["pools"] = tables[1]
notes = dict() notes = dict()
for participation in self.object.participations.all(): for participation in self.object.participations.all():

View File

@ -19,8 +19,7 @@ class RegistrationTable(tables.Table):
) )
def order_type(self, queryset, desc): def order_type(self, queryset, desc):
types = ["volunteerregistration", "-volunteerregistration__admin", "participantregistration"] return queryset.order_by(('-' if desc else '') + 'polymorphic_ctype'), True
return queryset.order_by(*(("-" if desc else "") + t for t in types)), True
class Meta: class Meta:
attrs = { attrs = {