mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-30 04:13:01 +00:00
Merge branch 'fix_ActivityList' into 'main'
Allow to order the 2 tables and to fix the bug of several activities See merge request bde/nk20!252
This commit is contained in:
commit
6e54ac207a
@ -17,7 +17,8 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
from django.views.generic import DetailView, TemplateView, UpdateView
|
from django.views.generic import DetailView, TemplateView, UpdateView
|
||||||
from django_tables2.views import SingleTableView
|
from django.views.generic.list import ListView
|
||||||
|
from django_tables2.views import MultiTableMixin
|
||||||
from note.models import Alias, NoteSpecial, NoteUser
|
from note.models import Alias, NoteSpecial, NoteUser
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
||||||
@ -57,27 +58,40 @@ class ActivityCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
return reverse_lazy('activity:activity_detail', kwargs={"pk": self.object.pk})
|
return reverse_lazy('activity:activity_detail', kwargs={"pk": self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, ListView):
|
||||||
"""
|
"""
|
||||||
Displays all Activities, and classify if they are on-going or upcoming ones.
|
Displays all Activities, and classify if they are on-going or upcoming ones.
|
||||||
"""
|
"""
|
||||||
model = Activity
|
model = Activity
|
||||||
table_class = ActivityTable
|
tables = [ActivityTable, ActivityTable]
|
||||||
ordering = ('-date_start',)
|
|
||||||
extra_context = {"title": _("Activities")}
|
extra_context = {"title": _("Activities")}
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
return super().get_queryset(**kwargs).distinct()
|
return super().get_queryset(**kwargs).distinct()
|
||||||
|
|
||||||
|
def get_tables(self):
|
||||||
|
tables = super().get_tables()
|
||||||
|
|
||||||
|
tables[0].prefix = "all-"
|
||||||
|
tables[1].prefix = "upcoming-"
|
||||||
|
return tables
|
||||||
|
|
||||||
|
def get_tables_data(self):
|
||||||
|
# first table = all activities, second table = upcoming
|
||||||
|
return [
|
||||||
|
self.get_queryset().order_by("-date_start"),
|
||||||
|
Activity.objects.filter(date_end__gt=timezone.now())
|
||||||
|
.filter(PermissionBackend.filter_queryset(self.request, Activity, "view"))
|
||||||
|
.distinct()
|
||||||
|
.order_by("date_start")
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
upcoming_activities = Activity.objects.filter(date_end__gt=timezone.now())
|
tables = context["tables"]
|
||||||
context['upcoming'] = ActivityTable(
|
for name, table in zip(["table", "upcoming"], tables):
|
||||||
data=upcoming_activities.filter(PermissionBackend.filter_queryset(self.request, Activity, "view")),
|
context[name] = table
|
||||||
prefix='upcoming-',
|
|
||||||
order_by='date_start',
|
|
||||||
)
|
|
||||||
|
|
||||||
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
||||||
context["started_activities"] = started_activities
|
context["started_activities"] = started_activities
|
||||||
|
@ -400,37 +400,37 @@ msgstr "Inviter"
|
|||||||
msgid "Create new activity"
|
msgid "Create new activity"
|
||||||
msgstr "Créer une nouvelle activité"
|
msgstr "Créer une nouvelle activité"
|
||||||
|
|
||||||
#: apps/activity/views.py:67 note_kfet/templates/base.html:90
|
#: apps/activity/views.py:68 note_kfet/templates/base.html:90
|
||||||
msgid "Activities"
|
msgid "Activities"
|
||||||
msgstr "Activités"
|
msgstr "Activités"
|
||||||
|
|
||||||
#: apps/activity/views.py:93
|
#: apps/activity/views.py:108
|
||||||
msgid "Activity detail"
|
msgid "Activity detail"
|
||||||
msgstr "Détails de l'activité"
|
msgstr "Détails de l'activité"
|
||||||
|
|
||||||
#: apps/activity/views.py:113
|
#: apps/activity/views.py:128
|
||||||
msgid "Update activity"
|
msgid "Update activity"
|
||||||
msgstr "Modifier l'activité"
|
msgstr "Modifier l'activité"
|
||||||
|
|
||||||
#: apps/activity/views.py:140
|
#: apps/activity/views.py:155
|
||||||
msgid "Invite guest to the activity \"{}\""
|
msgid "Invite guest to the activity \"{}\""
|
||||||
msgstr "Invitation pour l'activité « {} »"
|
msgstr "Invitation pour l'activité « {} »"
|
||||||
|
|
||||||
#: apps/activity/views.py:178
|
#: apps/activity/views.py:193
|
||||||
msgid "You are not allowed to display the entry interface for this activity."
|
msgid "You are not allowed to display the entry interface for this activity."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Vous n'êtes pas autorisé·e à afficher l'interface des entrées pour cette "
|
"Vous n'êtes pas autorisé·e à afficher l'interface des entrées pour cette "
|
||||||
"activité."
|
"activité."
|
||||||
|
|
||||||
#: apps/activity/views.py:181
|
#: apps/activity/views.py:196
|
||||||
msgid "This activity does not support activity entries."
|
msgid "This activity does not support activity entries."
|
||||||
msgstr "Cette activité ne requiert pas d'entrées."
|
msgstr "Cette activité ne requiert pas d'entrées."
|
||||||
|
|
||||||
#: apps/activity/views.py:184
|
#: apps/activity/views.py:199
|
||||||
msgid "This activity is closed."
|
msgid "This activity is closed."
|
||||||
msgstr "Cette activité est fermée."
|
msgstr "Cette activité est fermée."
|
||||||
|
|
||||||
#: apps/activity/views.py:280
|
#: apps/activity/views.py:295
|
||||||
msgid "Entry for activity \"{}\""
|
msgid "Entry for activity \"{}\""
|
||||||
msgstr "Entrées pour l'activité « {} »"
|
msgstr "Entrées pour l'activité « {} »"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user