def update_event_date(short_name, period, tag): survey = survey_controllers.get_survey_by_shortname(short_name) exercises = collection_exercise_controllers.get_collection_exercises_by_survey( survey['id']) exercise = get_collection_exercise_by_period(exercises, period) if not exercise: logger.error('Failed to find collection exercise by period', short_name=short_name, period=period) abort(404) events = collection_exercise_controllers.get_collection_exercise_events_by_id( exercise['id']) event_name = get_event_name(tag) formatted_events = convert_events_to_new_format(events) date_restriction_text = get_date_restriction_text(tag, formatted_events) try: event = formatted_events[tag] form = EventDateForm(day=event['date'][:2], month=event['month'], year=event['date'][-4:], hour=event['time'][:2], minute=event['time'][3:5]) except KeyError: form = EventDateForm() return render_template('update-event-date.html', form=form, ce=exercise, period=period, survey=survey, event_name=event_name, date_restriction_text=date_restriction_text)
def test_create_reminder3_with_reminder2(self): date_text = get_date_restriction_text( 'reminder3', self.generate_test_ce_events(reminder_one=False, reminder_two=True, reminder_three=False)) self.assertTrue('after Second Reminder' in date_text[0] and 'before Exercise end' in date_text[1])
def test_with_no_reminders(self): date_text = get_date_restriction_text( 'reminder', self.generate_test_ce_events(reminder_one=False, reminder_two=False, reminder_three=False)) self.assertTrue('after Go Live' in date_text[0] and 'before Exercise end' in date_text[1])
def test_change_reminder1_with_reminder2(self): date_text = get_date_restriction_text( 'reminder', self.generate_test_ce_events(reminder_one=True, reminder_two=True, reminder_three=False)) self.assertTrue('after Go Live' in date_text[0] and 'before Second Reminder' in date_text[1])
def test_change_reminder2_with_reminder1_and_reminder3(self): date_text = get_date_restriction_text( 'reminder2', self.generate_test_ce_events(reminder_one=True, reminder_two=False, reminder_three=True)) self.assertTrue('after First Reminder' in date_text[0] and 'before Third Reminder' in date_text[1])
def update_event_date(short_name, period, tag): survey = survey_controllers.get_survey_by_shortname(short_name) exercises = collection_exercise_controllers.get_collection_exercises_by_survey( survey["id"]) exercise = get_collection_exercise_by_period(exercises, period) if not exercise: logger.error("Failed to find collection exercise by period", short_name=short_name, period=period) abort(404) events = collection_exercise_controllers.get_collection_exercise_events_by_id( exercise["id"]) show = is_viewed_reminder_last_in_sequence(events, tag) event_name = get_event_name(tag) formatted_events = convert_events_to_new_format(events) date_restriction_text = get_date_restriction_text(tag, formatted_events) try: event = formatted_events[tag] form = EventDateForm( day=event["date"][:2], month=event["month"], year=event["date"][-4:], hour=event["time"][:2], minute=event["time"][3:5], ) except KeyError: form = EventDateForm() return render_template( "update-event-date.html", form=form, ce=exercise, period=period, survey=survey, event_name=event_name, date_restriction_text=date_restriction_text, show=show, tag=tag, )
def get_create_collection_event_form(short_name, period, ce_id, tag): logger.info( "Retrieving form for create collection exercise event", short_name=short_name, period=period, ce_id=ce_id, tag=tag, ) survey = survey_controllers.get_survey(short_name) exercises = collection_exercise_controllers.get_collection_exercises_by_survey(survey["id"]) exercise = get_collection_exercise_by_period(exercises, period) if not exercise: logger.error("Failed to find collection exercise by period", short_name=short_name, period=period) abort(404) events = collection_exercise_controllers.get_collection_exercise_events_by_id(exercise["id"]) form = EventDateForm() event_name = get_event_name(tag) formatted_events = convert_events_to_new_format(events) date_restriction_text = get_date_restriction_text(tag, formatted_events) logger.info( "Successfully retrieved form for create collection exercise event", short_name=short_name, period=period, ce_id=ce_id, tag=tag, ) return render_template( "create-ce-event.html", ce_id=ce_id, short_name=short_name, period=period, survey=survey, event_name=event_name, date_restriction_text=date_restriction_text, tag=tag, form=form, )
def test_mps_date_restriction(self): self.assertEqual(get_date_restriction_text("mps", self.events), self.restriction_texts["mps_restriction_text"])
def test_go_live_date_restriction(self): self.assertEqual( get_date_restriction_text("go_live", self.events), self.restriction_texts["go_live_restriction_text"] )
def test_exercise_end_date_restriction(self): self.assertEqual( get_date_restriction_text('exercise_end', self.events), self.restriction_texts['exercise_end_restriction_text'])
def test_nudge_email_4_date_restriction(self): self.assertEqual( get_date_restriction_text('nudge_email_4', self.events), self.restriction_texts['nudge_email_restriction_text'])
def test_reminder_date_restriction(self): self.assertEqual( get_date_restriction_text("reminder", self.events), self.restriction_texts["reminder_email_restriction_text"], )
def test_nudge_email_4_date_restriction(self): self.assertEqual( get_date_restriction_text("nudge_email_4", self.events), self.restriction_texts["nudge_email_restriction_text"], )
def test_mps_date_restriction(self): self.assertEqual(get_date_restriction_text('mps', self.events), self.restriction_texts['mps_restriction_text'])
def test_go_live_date_restriction(self): self.assertEqual(get_date_restriction_text('go_live', self.events), self.restriction_texts['go_live_restriction_text'])
def test_return_by_date_restriction(self): self.assertEqual(get_date_restriction_text('return_by', self.events), self.restriction_texts['return_by_restriction_text'])
def test_return_by_date_restriction(self): self.assertEqual( get_date_restriction_text("return_by", self.events), self.restriction_texts["return_by_restriction_text"] )
def test_exercise_end_date_restriction(self): self.assertEqual( get_date_restriction_text("exercise_end", self.events), self.restriction_texts["exercise_end_restriction_text"], )
def test_reminder_date_restriction(self): self.assertEqual( get_date_restriction_text('reminder', self.events), self.restriction_texts['reminder_email_restriction_text'])