mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 05:18:26 +02:00
Display payment status
This commit is contained in:
@ -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")
|
||||
|
23
apps/registration/migrations/0003_auto_20210118_1738.py
Normal file
23
apps/registration/migrations/0003_auto_20210118_1738.py
Normal 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'),
|
||||
),
|
||||
]
|
@ -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")
|
||||
|
@ -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()
|
||||
|
@ -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">
|
||||
|
Reference in New Issue
Block a user