Coverage for website/events/signals.py: 84.62%

11 statements  

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

1from django.db import transaction 

2from django.db.models.signals import post_save 

3from django.dispatch import Signal 

4 

5from events.models import EventRegistration 

6from events.tasks import send_registration_confirmation_email 

7from utils.models.signals import suspendingreceiver 

8 

9 

10@suspendingreceiver( 

11 post_save, 

12 sender=EventRegistration, 

13 dispatch_uid="send_event_registration_confirmation", 

14) 

15def send_event_registration_confirmation( 

16 sender, instance: EventRegistration, created: bool, **kwargs 

17): 

18 """Send an email notifying the registered person that they are registered.""" 

19 if ( 19 ↛ 30line 19 didn't jump to line 30

20 created 

21 and instance.is_registered 

22 and instance.email 

23 and instance.event.registration_required 

24 and ( # Don't send email to users who don't want it. 

25 instance.member is None 

26 or instance.member.profile.receive_registration_confirmation 

27 ) 

28 ): 

29 # Start a celery task to email the user in the background. 

30 transaction.on_commit( 

31 lambda: send_registration_confirmation_email.apply_async( 

32 (instance.pk,), expires=600 

33 ) 

34 ) 

35 

36 

37user_left_queue = Signal()