Coverage for website/registrations/signals.py: 100.00%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2025-08-14 10:31 +0000

1from django.db.models.signals import post_save 

2 

3from registrations import services 

4from registrations.models import Registration, Renewal 

5from utils.models.signals import suspendingreceiver 

6 

7 

8@suspendingreceiver(post_save, sender=Registration) 

9def complete_paid_registration(sender, instance: Registration, **kwargs): 

10 """Complete a registration once a payment for it is made.""" 

11 if instance.status == Registration.STATUS_ACCEPTED and instance.payment is not None: 

12 services.complete_registration(instance) 

13 # If something goes wrong completing the registration, the exception is propagated. 

14 # Creating the payment will in turn fail, leaving the registration accepted but not paid. 

15 

16 

17@suspendingreceiver(post_save, sender=Renewal) 

18def complete_paid_renewal(sender, instance: Renewal, **kwargs): 

19 """Complete a renewal once a payment for it is made.""" 

20 if instance.status == Renewal.STATUS_ACCEPTED and instance.payment is not None: 

21 services.complete_renewal(instance) 

22 # If something goes wrong completing the renewal, the exception is propagated. 

23 # Creating the payment will in turn fail, leaving the renewal accepted but not paid.