mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-03 19:22:51 +02:00
Display payment status
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user