From bfb80cbe326b2ebbc77bb6d7be6823b4d08811a7 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 31 Jan 2023 09:28:41 +0100 Subject: [PATCH] live notify staff --- teleforma/views/core.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 06f42025..7b6c9e0d 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -975,6 +975,7 @@ class NotificationView(APIView): class LiveConferenceNotify(APIView): + def post(self, request): """ notify users a new live conference is starting @@ -986,6 +987,8 @@ class LiveConferenceNotify(APIView): students = Student.objects.filter(period=conference.period, platform_only=True) text = f"""Une conférence live "{conference.course.title}" commence""" url = reverse('teleforma-conference-detail', kwargs={'period_id': conference.period.id, 'pk': conference.id}) + + # notify students for student in students: try: if student.user: @@ -998,10 +1001,13 @@ class LiveConferenceNotify(APIView): except Exception as e: logger.warning("Student NOT notified: " + str(student.id)) logger.warning(e) - return Response({'status': 'ok'}) - - + continue + # notify staff + for user in User.objects.filter(is_staff=True): + notify(student.user, text, url) + + return Response({'status': 'ok'}) # class ConferenceRecordView(FormView): -- 2.39.5