1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 05:18:26 +02:00

Add payments table page

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-02-23 22:58:23 +01:00
parent 5cbc72b41f
commit 2c54f315f6
7 changed files with 218 additions and 80 deletions

View File

@ -496,6 +496,24 @@ class VolunteerRegistration(Registration):
'content': content,
})
payments = Payment.objects.filter(registrations__team__participation__tournament=tournament).all()
valid = payments.filter(valid=True).count()
pending = payments.filter(valid=None).count()
invalid = payments.filter(valid=False).count()
if pending + invalid > 0:
text = _("There are {valid} validated payments, {pending} pending and {invalid} invalid for the "
"tournament of {tournament}. You can check the status of the payments on the "
"<a href=\"{url}\">payments list</a>.")
url = reverse_lazy("participation:tournament_payments", args=(tournament.id,))
content = format_lazy(text, valid=valid, pending=pending, invalid=invalid, tournament=tournament.name,
url=url)
informations.append({
'title': _("Payments"),
'type': "info",
'priority': 5,
'content': content,
})
return informations
class Meta:

View File

@ -1,10 +1,11 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables
from .models import Registration
from participation.models import Team
from .models import Payment, Registration
class RegistrationTable(tables.Table):
@ -28,3 +29,41 @@ class RegistrationTable(tables.Table):
model = Registration
fields = ('last_name', 'user__first_name', 'user__email', 'type',)
order_by = ('type', 'last_name', 'first_name',)
class PaymentTable(tables.Table):
"""
Table of all payments.
"""
team_id = tables.Column(
verbose_name=_("team").capitalize,
)
update_payment = tables.LinkColumn(
'registration:update_payment',
accessor='id',
args=[tables.A("id")],
verbose_name=_("Update"),
orderable=False,
)
def render_team_id(self, value):
return Team.objects.get(id=value).trigram
def render_amount(self, value):
return f"{value}"
def render_update_payment(self, record):
return mark_safe(f"<button class='btn btn-secondary'><i class='fas fa-money-bill-wave'></i> {_('Update')}</button>")
class Meta:
attrs = {
'class': 'table table-condensed table-striped',
}
row_attrs = {
'class': lambda record: ('table-success' if record.valid else
'table-danger' if record.valid is False else 'table-warning'),
}
model = Payment
fields = ('registrations', 'team_id', 'type', 'amount', 'valid', 'update_payment',)
empty_text = _("No payment yet.")