def __init__(self, entity_version, *args, **kwargs): entity_calendar_obj = entity_calendar.find_by_entity_and_reference( entity_version.entity.id, academic_calendar_type.SUMMARY_COURSE_SUBMISSION ) initial = {} if entity_calendar_obj else find_summary_course_submission_dates_for_entity_version(entity_version) super().__init__(*args, instance=entity_calendar_obj, initial=initial, **kwargs)
def __init__(self, entity_version, *args, **kwargs): entity_calendar_obj = entity_calendar.find_by_entity_and_reference( entity_version.entity.id, academic_calendar_type.SUMMARY_COURSE_SUBMISSION) initial = {} if entity_calendar_obj else find_summary_course_submission_dates_for_entity_version( entity_version) super().__init__(*args, instance=entity_calendar_obj, initial=initial, **kwargs)
def get_entity_calendar(an_entity_version, academic_yr): entity_cal = entity_calendar.find_by_entity_and_reference( an_entity_version.entity.id, academic_calendar_type.SUMMARY_COURSE_SUBMISSION, academic_yr) if entity_cal: return entity_cal else: if an_entity_version.parent: parent_entity_version = entity_version.find_latest_version_by_entity( an_entity_version.parent, timezone.now()) if parent_entity_version: return get_entity_calendar(parent_entity_version, academic_yr) return None
def get_entity_calendar(an_entity_version, academic_yr): entity_cal = entity_calendar.find_by_entity_and_reference( an_entity_version.entity.id, academic_calendar_type.SUMMARY_COURSE_SUBMISSION, academic_yr ) if entity_cal: return entity_cal else: if an_entity_version.parent: parent_entity_version = entity_version.find_latest_version_by_entity(an_entity_version.parent, timezone.now()) if parent_entity_version: return get_entity_calendar(parent_entity_version, academic_yr) return None
def test_find_for_current_academic_year(self): entity_calendar_obj = find_by_entity_and_reference( self.current_entity_calendar.entity.id, SUMMARY_COURSE_SUBMISSION) self.assertEqual(entity_calendar_obj, self.current_entity_calendar)
def test_when_no_data_match_criteria(self): entity_calendar_obj = find_by_entity_and_reference( self.current_entity_calendar.entity.id, EXAM_ENROLLMENTS) self.assertIsNone(entity_calendar_obj)