Display payment status

This commit is contained in:
Yohann D'ANELLO 2021-01-18 18:13:58 +01:00
parent d5ba7a08a9
commit 53a55ee898
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
6 changed files with 98 additions and 30 deletions

View File

@ -12,12 +12,12 @@ class RegistrationConfig(AppConfig):
name = 'registration'
def ready(self):
from registration.signals import create_admin_registration, invite_to_public_rooms, \
from registration.signals import create_admin_registration, create_payment, \
set_username, send_email_link
pre_save.connect(set_username, "auth.User")
pre_save.connect(send_email_link, "auth.User")
post_save.connect(create_admin_registration, "auth.User")
post_save.connect(invite_to_public_rooms, "registration.Registration")
post_save.connect(invite_to_public_rooms, "registration.StudentRegistration")
post_save.connect(invite_to_public_rooms, "registration.CoachRegistration")
post_save.connect(invite_to_public_rooms, "registration.AdminRegistration")
post_save.connect(create_payment, "registration.Registration")
post_save.connect(create_payment, "registration.StudentRegistration")
post_save.connect(create_payment, "registration.CoachRegistration")
post_save.connect(create_payment, "registration.AdminRegistration")

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.11 on 2021-01-18 16:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('registration', '0002_payment'),
]
operations = [
migrations.AlterModelOptions(
name='payment',
options={'verbose_name': 'payment', 'verbose_name_plural': 'payments'},
),
migrations.AlterField(
model_name='payment',
name='registration',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='payment', to='registration.ParticipantRegistration', verbose_name='registration'),
),
]

View File

@ -298,7 +298,7 @@ class Payment(models.Model):
registration = models.OneToOneField(
ParticipantRegistration,
on_delete=models.CASCADE,
related_name="registration",
related_name="payment",
verbose_name=_("registration"),
)
@ -337,3 +337,7 @@ class Payment(models.Model):
null=True,
default=False,
)
class Meta:
verbose_name = _("payment")
verbose_name_plural = _("payments")

View File

@ -5,7 +5,7 @@ from django.contrib.auth.models import User
from tfjm.lists import get_sympa_client
from tfjm.matrix import Matrix
from .models import AdminRegistration, Registration
from .models import AdminRegistration, Payment, Registration
def set_username(instance, **_):
@ -44,13 +44,14 @@ def create_admin_registration(instance, **_):
AdminRegistration.objects.get_or_create(user=instance)
def invite_to_public_rooms(instance: Registration, created: bool, **_):
def create_payment(instance: Registration, **_):
"""
When a user got registered, automatically invite the Matrix user into public rooms.
When a user is saved, create the associated payment.
For a free tournament, the payment is valid.
"""
if not created:
Matrix.invite("#annonces:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
Matrix.invite("#faq:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
Matrix.invite("#je-cherche-une-equip:tfjm.org",
f"@{instance.matrix_username}:tfjm.org")
Matrix.invite("#flood:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
if instance.participates:
payment = Payment.objects.get_or_create(registration=instance)[0]
if instance.team and instance.team.participation.valid and instance.team.participation.tournament.price == 0:
payment.valid = True
payment.type = "free"
payment.save()

View File

@ -109,6 +109,26 @@
<dt class="col-sm-6 text-right">{% trans "Grant Animath to contact me in the future about other actions:" %}</dt>
<dd class="col-sm-6">{{ user_object.registration.give_contact_to_animath|yesno }}</dd>
</dl>
{% if user_object.registration.participates and user_object.registration.team.participation.valid %}
<hr>
<dl class="row">
<dt class="col-sm-6 text-right">{% trans "Payment information:" %}</dt>
<dd class="col-sm-6">
{% trans "yes,no,pending" as yesnodefault %}
{% with info=user_object.registration.payment.additional_information %}
{% if info %}
<abbr title="{{ info }}">
{{ user_object.registration.payment.get_type_display }}, {% trans "valid:" %} {{ user_object.registration.payment.valid|yesno:yesnodefault }}
</abbr>
{% else %}
{{ user_object.registration.payment.get_type_display }}, {% trans "valid:" %} {{ user_object.registration.payment.valid|yesno:yesnodefault }}
{% endif %}
{% endwith %}
</dd>
</dl>
{% endif %}
</div>
{% if user.pk == user_object.pk or user.registration.is_admin %}
<div class="card-footer text-center">

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-18 16:33+0100\n"
"POT-Creation-Date: 2021-01-18 17:59+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -486,8 +486,8 @@ msgstr "Rejoindre"
#: apps/participation/templates/participation/tournament_form.html:12
#: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/update_user.html:16
#: apps/registration/templates/registration/user_detail.html:115
#: apps/registration/templates/registration/user_detail.html:124
#: apps/registration/templates/registration/user_detail.html:127
#: apps/registration/templates/registration/user_detail.html:136
msgid "Update"
msgstr "Modifier"
@ -541,9 +541,9 @@ msgstr "Envoyer une solution"
#: apps/registration/templates/registration/upload_health_sheet.html:17
#: apps/registration/templates/registration/upload_parental_authorization.html:17
#: apps/registration/templates/registration/upload_photo_authorization.html:18
#: apps/registration/templates/registration/user_detail.html:129
#: apps/registration/templates/registration/user_detail.html:134
#: apps/registration/templates/registration/user_detail.html:139
#: apps/registration/templates/registration/user_detail.html:141
#: apps/registration/templates/registration/user_detail.html:146
#: apps/registration/templates/registration/user_detail.html:151
msgid "Upload"
msgstr "Téléverser"
@ -651,7 +651,7 @@ msgid "Defended solutions:"
msgstr "Solutions défendues :"
#: apps/participation/templates/participation/pool_detail.html:38
#: apps/participation/templates/participation/tournament_detail.html:79
#: apps/participation/templates/participation/tournament_detail.html:82
msgid "Ranking"
msgstr "Classement"
@ -670,7 +670,7 @@ msgid "Passages"
msgstr "Passages"
#: apps/participation/templates/participation/pool_detail.html:65
#: apps/participation/templates/participation/tournament_detail.html:91
#: apps/participation/templates/participation/tournament_detail.html:96
msgid "Add"
msgstr "Ajouter"
@ -848,15 +848,15 @@ msgstr "Modifier le tournoi"
msgid "Teams"
msgstr "Équipes"
#: apps/participation/templates/participation/tournament_detail.html:66
#: apps/participation/templates/participation/tournament_detail.html:67
msgid "Pools"
msgstr "Poules"
#: apps/participation/templates/participation/tournament_detail.html:72
#: apps/participation/templates/participation/tournament_detail.html:74
msgid "Add new pool"
msgstr "Ajouter une nouvelle poule"
#: apps/participation/templates/participation/tournament_detail.html:90
#: apps/participation/templates/participation/tournament_detail.html:95
msgid "Add pool"
msgstr "Ajouter une poule"
@ -1153,6 +1153,14 @@ msgstr "informations additionnelles"
msgid "To help us to find your payment."
msgstr "Pour nous aider à retrouver votre paiement, si nécessaire."
#: apps/registration/models.py:342
msgid "payment"
msgstr "paiement"
#: apps/registration/models.py:343
msgid "payments"
msgstr "paiements"
#: apps/registration/tables.py:17
msgid "last name"
msgstr "nom de famille"
@ -1441,24 +1449,36 @@ msgid "Grant Animath to contact me in the future about other actions:"
msgstr "Autorise Animath à recontacter à propos d'autres actions :"
#: apps/registration/templates/registration/user_detail.html:117
msgid "Payment information:"
msgstr "Informations de paiement :"
#: apps/registration/templates/registration/user_detail.html:119
msgid "yes,no,pending"
msgstr "oui,non,en attente"
#: apps/registration/templates/registration/user_detail.html:120
msgid "valid:"
msgstr "valide :"
#: apps/registration/templates/registration/user_detail.html:129
msgid "Impersonate"
msgstr "Impersonifier"
#: apps/registration/templates/registration/user_detail.html:123
#: apps/registration/templates/registration/user_detail.html:135
msgid "Update user"
msgstr "Modifier l'utilisateur"
#: apps/registration/templates/registration/user_detail.html:128
#: apps/registration/templates/registration/user_detail.html:140
#: apps/registration/views.py:313
msgid "Upload photo authorization"
msgstr "Téléverser l'autorisation de droit à l'image"
#: apps/registration/templates/registration/user_detail.html:133
#: apps/registration/templates/registration/user_detail.html:145
#: apps/registration/views.py:339
msgid "Upload health sheet"
msgstr "Téléverser la fiche sanitaire"
#: apps/registration/templates/registration/user_detail.html:138
#: apps/registration/templates/registration/user_detail.html:150
#: apps/registration/views.py:365
msgid "Upload parental authorization"
msgstr "Téléverser l'autorisation parentale"