mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-08-16 20:50:04 +02:00
Add payments table page
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@@ -6,6 +6,7 @@ from io import BytesIO
|
||||
import os
|
||||
import subprocess
|
||||
from tempfile import mkdtemp
|
||||
from typing import Any, Dict
|
||||
from zipfile import ZipFile
|
||||
|
||||
from django.conf import settings
|
||||
@@ -15,6 +16,7 @@ from django.contrib.sites.models import Site
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.db.models import F
|
||||
from django.http import FileResponse, Http404, HttpResponse
|
||||
from django.shortcuts import redirect
|
||||
from django.template.loader import render_to_string
|
||||
@@ -24,13 +26,14 @@ 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 MultiTableMixin, SingleTableView
|
||||
from django_tables2 import MultiTableMixin, SingleTableMixin, SingleTableView
|
||||
from magic import Magic
|
||||
from odf.opendocument import OpenDocumentSpreadsheet
|
||||
from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties
|
||||
from odf.table import CoveredTableCell, Table, TableCell, TableColumn, TableRow
|
||||
from odf.text import P
|
||||
from registration.models import Payment, StudentRegistration, VolunteerRegistration
|
||||
from registration.tables import PaymentTable
|
||||
from tfjm.lists import get_sympa_client
|
||||
from tfjm.views import AdminMixin, VolunteerMixin
|
||||
|
||||
@@ -572,6 +575,31 @@ class TournamentDetailView(MultiTableMixin, DetailView):
|
||||
return context
|
||||
|
||||
|
||||
class TournamentPaymentsView(VolunteerMixin, SingleTableMixin, DetailView):
|
||||
"""
|
||||
Display the list of payments of a tournament.
|
||||
"""
|
||||
model = Tournament
|
||||
table_class = PaymentTable
|
||||
template_name = "participation/tournament_payments.html"
|
||||
|
||||
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["title"] = _("Payments of {tournament}").format(tournament=self.object)
|
||||
return context
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated or not self.request.user.registration.is_admin \
|
||||
and not (self.request.user.registration.is_volunteer
|
||||
and self.get_object() in self.request.user.registration.organized_tournaments.all()):
|
||||
return self.handle_no_permission()
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_table_data(self):
|
||||
return Payment.objects.filter(registrations__team__participation__tournament=self.get_object()) \
|
||||
.annotate(team_id=F('registrations__team')).order_by('-valid', 'registrations__team__trigram').all()
|
||||
|
||||
|
||||
class TournamentExportCSVView(VolunteerMixin, DetailView):
|
||||
"""
|
||||
Export team information in a CSV file.
|
||||
|
Reference in New Issue
Block a user