mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-23 19:06:37 +02:00
add table, add some translation
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2018-2024 by BDE ENS Paris-Saclay
|
||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import json
|
||||
@ -6,7 +6,8 @@ import json
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView
|
||||
from django_tables2.views import SingleTableView
|
||||
from django.views.generic.list import ListView
|
||||
from django_tables2.views import MultiTableMixin
|
||||
from permission.backends import PermissionBackend
|
||||
from permission.views import ProtectQuerysetMixin
|
||||
|
||||
@ -14,21 +15,29 @@ from .models import Wrapped
|
||||
from .tables import WrappedTable
|
||||
|
||||
|
||||
class WrappedListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||
class WrappedListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, ListView):
|
||||
"""
|
||||
Display all Wrapped, and classify by year
|
||||
"""
|
||||
model = Wrapped
|
||||
table_class = WrappedTable
|
||||
tables =[
|
||||
lambda data: WrappedTable(data, prefix="public-"),
|
||||
lambda data: WrappedTable(data, prefix="personnal-"),
|
||||
]
|
||||
template_name = 'wrapped/wrapped_list.html'
|
||||
extra_context = {'title': _("List of wrapped")}
|
||||
|
||||
def get_queryset(self, **kwargs):
|
||||
return super().get_queryset(**kwargs).distinct()
|
||||
|
||||
def get_table_data(self):
|
||||
return Wrapped.objects.filter(PermissionBackend.filter_queryset(
|
||||
self.request, Wrapped, "change", field='public')).distinct().order_by("-bde__date_start")
|
||||
def get_tables_data(self):
|
||||
return [
|
||||
Wrapped.objects.filter(public=True),
|
||||
Wrapped.objects
|
||||
.filter(PermissionBackend.filter_queryset(self.request, Wrapped, "change", field='public'))
|
||||
.distinct()
|
||||
.order_by("-bde__date_start")
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
Reference in New Issue
Block a user