mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 17:02:24 +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:
parent
59268f2d1e
commit
0e7a275a28
20
participation/migrations/0008_alter_participation_options.py
Normal file
20
participation/migrations/0008_alter_participation_options.py
Normal 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",
|
||||
},
|
||||
),
|
||||
]
|
@ -341,6 +341,7 @@ class Participation(models.Model):
|
||||
class Meta:
|
||||
verbose_name = _("participation")
|
||||
verbose_name_plural = _("participations")
|
||||
ordering = ('valid', 'team__trigram',)
|
||||
|
||||
|
||||
class Pool(models.Model):
|
||||
|
@ -54,6 +54,7 @@ class ParticipationTable(tables.Table):
|
||||
}
|
||||
model = Team
|
||||
fields = ('name', 'trigram', 'valid',)
|
||||
order = ('-valid',)
|
||||
|
||||
|
||||
class TournamentTable(tables.Table):
|
||||
|
@ -24,7 +24,7 @@ from django.utils.crypto import get_random_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, DetailView, FormView, RedirectView, TemplateView, UpdateView, View
|
||||
from django.views.generic.edit import FormMixin, ProcessFormView
|
||||
from django_tables2 import SingleTableView
|
||||
from django_tables2 import SingleTableView, MultiTableMixin
|
||||
from magic import Magic
|
||||
from odf.opendocument import OpenDocumentSpreadsheet
|
||||
from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties
|
||||
@ -555,16 +555,24 @@ class TournamentUpdateView(VolunteerMixin, UpdateView):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class TournamentDetailView(DetailView):
|
||||
class TournamentDetailView(MultiTableMixin, DetailView):
|
||||
"""
|
||||
Display tournament detail.
|
||||
"""
|
||||
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):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["teams"] = ParticipationTable(self.object.participations.all())
|
||||
context["pools"] = PoolTable(self.object.pools.order_by('id').all())
|
||||
tables = context['tables']
|
||||
context["teams"] = tables[0]
|
||||
context["pools"] = tables[1]
|
||||
|
||||
notes = dict()
|
||||
for participation in self.object.participations.all():
|
||||
|
@ -19,8 +19,7 @@ class RegistrationTable(tables.Table):
|
||||
)
|
||||
|
||||
def order_type(self, queryset, desc):
|
||||
types = ["volunteerregistration", "-volunteerregistration__admin", "participantregistration"]
|
||||
return queryset.order_by(*(("-" if desc else "") + t for t in types)), True
|
||||
return queryset.order_by(('-' if desc else '') + 'polymorphic_ctype'), True
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
|
Loading…
Reference in New Issue
Block a user