def handle(self, *args, **options): """ Loads all courses for the current and next terms with default priority, and updates all courses from previous term to priority none. """ for term in get_all_active_terms(): if term.bterm_last_day_add is not None: curr_last_date = term.bterm_last_day_add else: curr_last_date = term.last_day_add if sws_now().date() <= curr_last_date: Course.objects.add_all_courses_for_term(term) else: Course.objects.deprioritize_all_courses_for_term(term) self.update_job()
def process_events(self, event): self._previous_instructors = self._instructors_from_section_json( event['Previous']) self._current_instructors = self._instructors_from_section_json( event['Current']) self._last_modified = date_parse(event['EventDate']) section_data = event['Current'] if not section_data: section_data = event['Previous'] course_data = section_data['Course'] try: term = get_term_by_year_and_quarter( section_data['Term']['Year'], section_data['Term']['Quarter']) active_terms = get_all_active_terms(datetime.now()) except DataFailureException as err: self._log.info('%s ERROR get term: %s' % (log_prefix, err)) return if term not in active_terms: self._log.info( '%s IGNORE inactive section %s-%s-%s-%s' % ( log_prefix, term.canvas_sis_id(), course_data['CurriculumAbbreviation'], course_data['CourseNumber'], section_data['SectionID'])) return section = Section( term=term, course_campus=section_data['CourseCampus'], curriculum_abbr=course_data['CurriculumAbbreviation'], course_number=course_data['CourseNumber'], section_id=section_data['SectionID'], is_independent_study=section_data['IndependentStudy']) if is_time_schedule_construction(section): self._log_tsc_ignore(section.canvas_section_sis_id()) return sections = [] primary_section = section_data["PrimarySection"] if (primary_section is not None and primary_section["SectionID"] != section.section_id): section.is_primary_section = False self._set_primary_section(section, primary_section) sections.append(section) else: if len(section_data["LinkedSectionTypes"]): for linked_section_type in section_data["LinkedSectionTypes"]: for linked_section_data in \ linked_section_type["LinkedSections"]: lsd_data = linked_section_data['Section'] section = Section( term=term, curriculum_abbr=lsd_data['CurriculumAbbreviation'], course_number=lsd_data['CourseNumber'], section_id=lsd_data['SectionID'], is_primary_section=False, is_independent_study=section_data[ 'IndependentStudy']) self._set_primary_section(section, primary_section) sections.append(section) else: section.is_primary_section = True sections.append(section) for section in sections: self.load_instructors(section)