mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 09:02:11 +01:00 
			
		
		
		
	Display payment status
This commit is contained in:
		@@ -12,12 +12,12 @@ class RegistrationConfig(AppConfig):
 | 
				
			|||||||
    name = 'registration'
 | 
					    name = 'registration'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def ready(self):
 | 
					    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
 | 
					            set_username, send_email_link
 | 
				
			||||||
        pre_save.connect(set_username, "auth.User")
 | 
					        pre_save.connect(set_username, "auth.User")
 | 
				
			||||||
        pre_save.connect(send_email_link, "auth.User")
 | 
					        pre_save.connect(send_email_link, "auth.User")
 | 
				
			||||||
        post_save.connect(create_admin_registration, "auth.User")
 | 
					        post_save.connect(create_admin_registration, "auth.User")
 | 
				
			||||||
        post_save.connect(invite_to_public_rooms, "registration.Registration")
 | 
					        post_save.connect(create_payment, "registration.Registration")
 | 
				
			||||||
        post_save.connect(invite_to_public_rooms, "registration.StudentRegistration")
 | 
					        post_save.connect(create_payment, "registration.StudentRegistration")
 | 
				
			||||||
        post_save.connect(invite_to_public_rooms, "registration.CoachRegistration")
 | 
					        post_save.connect(create_payment, "registration.CoachRegistration")
 | 
				
			||||||
        post_save.connect(invite_to_public_rooms, "registration.AdminRegistration")
 | 
					        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(
 | 
					    registration = models.OneToOneField(
 | 
				
			||||||
        ParticipantRegistration,
 | 
					        ParticipantRegistration,
 | 
				
			||||||
        on_delete=models.CASCADE,
 | 
					        on_delete=models.CASCADE,
 | 
				
			||||||
        related_name="registration",
 | 
					        related_name="payment",
 | 
				
			||||||
        verbose_name=_("registration"),
 | 
					        verbose_name=_("registration"),
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -337,3 +337,7 @@ class Payment(models.Model):
 | 
				
			|||||||
        null=True,
 | 
					        null=True,
 | 
				
			||||||
        default=False,
 | 
					        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.lists import get_sympa_client
 | 
				
			||||||
from tfjm.matrix import Matrix
 | 
					from tfjm.matrix import Matrix
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import AdminRegistration, Registration
 | 
					from .models import AdminRegistration, Payment, Registration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def set_username(instance, **_):
 | 
					def set_username(instance, **_):
 | 
				
			||||||
@@ -44,13 +44,14 @@ def create_admin_registration(instance, **_):
 | 
				
			|||||||
        AdminRegistration.objects.get_or_create(user=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:
 | 
					    if instance.participates:
 | 
				
			||||||
        Matrix.invite("#annonces:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
 | 
					        payment = Payment.objects.get_or_create(registration=instance)[0]
 | 
				
			||||||
        Matrix.invite("#faq:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
 | 
					        if instance.team and instance.team.participation.valid and instance.team.participation.tournament.price == 0:
 | 
				
			||||||
        Matrix.invite("#je-cherche-une-equip:tfjm.org",
 | 
					            payment.valid = True
 | 
				
			||||||
                      f"@{instance.matrix_username}:tfjm.org")
 | 
					            payment.type = "free"
 | 
				
			||||||
        Matrix.invite("#flood:tfjm.org", f"@{instance.matrix_username}:tfjm.org")
 | 
					            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>
 | 
					            <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>
 | 
					            <dd class="col-sm-6">{{ user_object.registration.give_contact_to_animath|yesno }}</dd>
 | 
				
			||||||
        </dl>
 | 
					        </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>
 | 
					    </div>
 | 
				
			||||||
    {% if user.pk == user_object.pk or user.registration.is_admin %}
 | 
					    {% if user.pk == user_object.pk or user.registration.is_admin %}
 | 
				
			||||||
        <div class="card-footer text-center">
 | 
					        <div class="card-footer text-center">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ msgid ""
 | 
				
			|||||||
msgstr ""
 | 
					msgstr ""
 | 
				
			||||||
"Project-Id-Version: TFJM\n"
 | 
					"Project-Id-Version: TFJM\n"
 | 
				
			||||||
"Report-Msgid-Bugs-To: \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"
 | 
					"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 | 
				
			||||||
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
 | 
					"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
 | 
				
			||||||
"Language-Team: LANGUAGE <LL@li.org>\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/tournament_form.html:12
 | 
				
			||||||
#: apps/participation/templates/participation/update_team.html:12
 | 
					#: apps/participation/templates/participation/update_team.html:12
 | 
				
			||||||
#: apps/registration/templates/registration/update_user.html:16
 | 
					#: apps/registration/templates/registration/update_user.html:16
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:115
 | 
					#: apps/registration/templates/registration/user_detail.html:127
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:124
 | 
					#: apps/registration/templates/registration/user_detail.html:136
 | 
				
			||||||
msgid "Update"
 | 
					msgid "Update"
 | 
				
			||||||
msgstr "Modifier"
 | 
					msgstr "Modifier"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -541,9 +541,9 @@ msgstr "Envoyer une solution"
 | 
				
			|||||||
#: apps/registration/templates/registration/upload_health_sheet.html:17
 | 
					#: apps/registration/templates/registration/upload_health_sheet.html:17
 | 
				
			||||||
#: apps/registration/templates/registration/upload_parental_authorization.html:17
 | 
					#: apps/registration/templates/registration/upload_parental_authorization.html:17
 | 
				
			||||||
#: apps/registration/templates/registration/upload_photo_authorization.html:18
 | 
					#: apps/registration/templates/registration/upload_photo_authorization.html:18
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:129
 | 
					#: apps/registration/templates/registration/user_detail.html:141
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:134
 | 
					#: apps/registration/templates/registration/user_detail.html:146
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:139
 | 
					#: apps/registration/templates/registration/user_detail.html:151
 | 
				
			||||||
msgid "Upload"
 | 
					msgid "Upload"
 | 
				
			||||||
msgstr "Téléverser"
 | 
					msgstr "Téléverser"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -651,7 +651,7 @@ msgid "Defended solutions:"
 | 
				
			|||||||
msgstr "Solutions défendues :"
 | 
					msgstr "Solutions défendues :"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/participation/templates/participation/pool_detail.html:38
 | 
					#: 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"
 | 
					msgid "Ranking"
 | 
				
			||||||
msgstr "Classement"
 | 
					msgstr "Classement"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -670,7 +670,7 @@ msgid "Passages"
 | 
				
			|||||||
msgstr "Passages"
 | 
					msgstr "Passages"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/participation/templates/participation/pool_detail.html:65
 | 
					#: 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"
 | 
					msgid "Add"
 | 
				
			||||||
msgstr "Ajouter"
 | 
					msgstr "Ajouter"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -848,15 +848,15 @@ msgstr "Modifier le tournoi"
 | 
				
			|||||||
msgid "Teams"
 | 
					msgid "Teams"
 | 
				
			||||||
msgstr "Équipes"
 | 
					msgstr "Équipes"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/participation/templates/participation/tournament_detail.html:66
 | 
					#: apps/participation/templates/participation/tournament_detail.html:67
 | 
				
			||||||
msgid "Pools"
 | 
					msgid "Pools"
 | 
				
			||||||
msgstr "Poules"
 | 
					msgstr "Poules"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/participation/templates/participation/tournament_detail.html:72
 | 
					#: apps/participation/templates/participation/tournament_detail.html:74
 | 
				
			||||||
msgid "Add new pool"
 | 
					msgid "Add new pool"
 | 
				
			||||||
msgstr "Ajouter une nouvelle poule"
 | 
					msgstr "Ajouter une nouvelle poule"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/participation/templates/participation/tournament_detail.html:90
 | 
					#: apps/participation/templates/participation/tournament_detail.html:95
 | 
				
			||||||
msgid "Add pool"
 | 
					msgid "Add pool"
 | 
				
			||||||
msgstr "Ajouter une poule"
 | 
					msgstr "Ajouter une poule"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1153,6 +1153,14 @@ msgstr "informations additionnelles"
 | 
				
			|||||||
msgid "To help us to find your payment."
 | 
					msgid "To help us to find your payment."
 | 
				
			||||||
msgstr "Pour nous aider à retrouver votre paiement, si nécessaire."
 | 
					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
 | 
					#: apps/registration/tables.py:17
 | 
				
			||||||
msgid "last name"
 | 
					msgid "last name"
 | 
				
			||||||
msgstr "nom de famille"
 | 
					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 :"
 | 
					msgstr "Autorise Animath à recontacter à propos d'autres actions :"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:117
 | 
					#: 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"
 | 
					msgid "Impersonate"
 | 
				
			||||||
msgstr "Impersonifier"
 | 
					msgstr "Impersonifier"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#: apps/registration/templates/registration/user_detail.html:123
 | 
					#: apps/registration/templates/registration/user_detail.html:135
 | 
				
			||||||
msgid "Update user"
 | 
					msgid "Update user"
 | 
				
			||||||
msgstr "Modifier l'utilisateur"
 | 
					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
 | 
					#: apps/registration/views.py:313
 | 
				
			||||||
msgid "Upload photo authorization"
 | 
					msgid "Upload photo authorization"
 | 
				
			||||||
msgstr "Téléverser l'autorisation de droit à l'image"
 | 
					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
 | 
					#: apps/registration/views.py:339
 | 
				
			||||||
msgid "Upload health sheet"
 | 
					msgid "Upload health sheet"
 | 
				
			||||||
msgstr "Téléverser la fiche sanitaire"
 | 
					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
 | 
					#: apps/registration/views.py:365
 | 
				
			||||||
msgid "Upload parental authorization"
 | 
					msgid "Upload parental authorization"
 | 
				
			||||||
msgstr "Téléverser l'autorisation parentale"
 | 
					msgstr "Téléverser l'autorisation parentale"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user