mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 04:22:14 +01:00 
			
		
		
		
	Add payment interface tests
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -12,8 +12,8 @@ class RegistrationConfig(AppConfig):
 | 
			
		||||
    name = 'registration'
 | 
			
		||||
 | 
			
		||||
    def ready(self):
 | 
			
		||||
        from registration.signals import create_admin_registration, \
 | 
			
		||||
            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")
 | 
			
		||||
        from registration import signals
 | 
			
		||||
        pre_save.connect(signals.set_username, 'auth.User')
 | 
			
		||||
        pre_save.connect(signals.send_email_link, 'auth.User')
 | 
			
		||||
        pre_save.connect(signals.update_payment_amount, 'registration.Payment')
 | 
			
		||||
        post_save.connect(signals.create_admin_registration, 'auth.User')
 | 
			
		||||
 
 | 
			
		||||
@@ -226,6 +226,9 @@ class PaymentAdminForm(forms.ModelForm):
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        self.fields["valid"].widget.choices[0] = ('unknown', _("Pending"))
 | 
			
		||||
        payment_type = kwargs.get('data', {}).get('type', "")
 | 
			
		||||
        self.fields['receipt'].required = payment_type in ["scholarship", "bank_transfer"]
 | 
			
		||||
        self.fields['additional_information'].required = payment_type in ["other"]
 | 
			
		||||
 | 
			
		||||
    def clean_receipt(self):
 | 
			
		||||
        if "receipt" in self.files:
 | 
			
		||||
 
 | 
			
		||||
@@ -387,7 +387,7 @@ class StudentRegistration(ParticipantRegistration):
 | 
			
		||||
                        'priority': 3,
 | 
			
		||||
                        'content': content,
 | 
			
		||||
                    })
 | 
			
		||||
                elif self.payment.valid is None:
 | 
			
		||||
                elif payment.valid is None:
 | 
			
		||||
                    text = _("Your payment is under approval.")
 | 
			
		||||
                    content = text
 | 
			
		||||
                    informations.append({
 | 
			
		||||
 
 | 
			
		||||
@@ -41,3 +41,13 @@ def create_admin_registration(instance, **_):
 | 
			
		||||
    """
 | 
			
		||||
    if instance.is_superuser:
 | 
			
		||||
        VolunteerRegistration.objects.get_or_create(user=instance, admin=True)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def update_payment_amount(instance, **_):
 | 
			
		||||
    """
 | 
			
		||||
    When a payment got created, ensure that the amount is set.
 | 
			
		||||
    """
 | 
			
		||||
    if instance.type == 'free' or instance.type == 'scholarship':
 | 
			
		||||
        instance.amount = 0
 | 
			
		||||
    elif instance.pk:
 | 
			
		||||
        instance.amount = instance.registrations.count() * instance.tournament.price
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user