Created
May 27, 2019 11:32
-
-
Save dirkcuys/3d24a3426abc3a7fa4a8a00868f9bdfc to your computer and use it in GitHub Desktop.
Revisions
-
dirkcuys created this gist
May 27, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # ... def send_facilitator_survey(study_group): """ send survey to all facilitators two days before their second to last meeting """ now = timezone.now() end_of_window = now.replace(minute=0, second=0, microsecond=0) start_of_window = end_of_window - datetime.timedelta(hours=1) last_two_meetings = study_group.meeting_set.active().order_by('-meeting_date', '-meeting_time')[:2] time_to_send = None if last_two_meetings.count() == 2: penultimate_meeting = last_two_meetings[1] time_to_send = penultimate_meeting.meeting_datetime() - datetime.timedelta(days=2, hours=1) if time_to_send and time_to_send > start_of_window and time_to_send <= end_of_window: facilitator_name = study_group.facilitator.first_name path = reverse('studygroups_facilitator_survey', kwargs={'study_group_id': study_group.id}) base_url = f'{settings.PROTOCOL}://{settings.DOMAIN}' survey_url = base_url + path # ...