コード例 #1
0
 def _assert_schedule_is_obsolete(
         self,
         expect_obsolete_dates,
         expect_obsolete_times,
         meeting,
         override_days=None,
         override_end_date=None,
         override_end_time=None,
         override_start_date=None,
         override_start_time=None,
 ):
     with test_approvals_workflow(app):
         with override_config(app, 'CURRENT_TERM_RECORDINGS_BEGIN', meeting['startDate']):
             with override_config(app, 'CURRENT_TERM_RECORDINGS_END', meeting['endDate']):
                 mock_scheduled(
                     meeting=meeting,
                     override_days=override_days,
                     override_end_date=override_end_date,
                     override_end_time=override_end_time,
                     override_start_date=override_start_date,
                     override_start_time=override_start_time,
                     section_id=self.section_id,
                     term_id=self.term_id,
                 )
                 course = SisSection.get_course(section_id=self.section_id, term_id=self.term_id)
                 scheduled = course['scheduled']
                 assert are_scheduled_dates_obsolete(meeting=meeting, scheduled=scheduled) is expect_obsolete_dates
                 assert are_scheduled_times_obsolete(meeting=meeting, scheduled=scheduled) is expect_obsolete_times
コード例 #2
0
 def _date_change_alerts(self):
     template_type = 'admin_alert_date_change'
     for course in self._get_courses_except_notified(template_type):
         meetings = course.get('meetings', {}).get('eligible', [])
         if len(meetings):
             meeting = meetings[0]
             scheduled = course['scheduled']
             obsolete_dates = are_scheduled_dates_obsolete(
                 meeting=meeting, scheduled=scheduled)
             if obsolete_dates or are_scheduled_times_obsolete(
                     meeting=meeting, scheduled=scheduled):
                 self._notify(course=course, template_type=template_type)
コード例 #3
0
 def _schedule():
     mock_scheduled(
         meeting=meeting,
         override_end_time='16:59',
         override_start_time='08:00',
         section_id=section_id,
         term_id=term_id,
     )
     course = SisSection.get_course(
         section_id=section_id, term_id=term_id)
     scheduled = course['scheduled']
     assert are_scheduled_dates_obsolete(
         meeting=meeting, scheduled=scheduled) is False
     assert are_scheduled_times_obsolete(
         meeting=meeting, scheduled=scheduled) is True
コード例 #4
0
def _decorate_course_changes(course):
    meetings = course['meetings']['eligible'] + course['meetings']['ineligible']
    meeting = meetings[0] if meetings else None
    room_id = meeting.get('room', {}).get('id') if meeting else None

    scheduled = course['scheduled']
    if scheduled:
        instructor_uids = [i['uid'] for i in course['instructors']]
        scheduled.update({
            'hasObsoleteInstructors': set(instructor_uids) != set(scheduled.get('instructorUids')),
            'hasObsoleteDates': are_scheduled_dates_obsolete(meeting=meeting, scheduled=scheduled),
            'hasObsoleteTimes': are_scheduled_times_obsolete(meeting=meeting, scheduled=scheduled),
            'hasObsoleteRoom': room_id != scheduled.get('room', {}).get('id'),
        })

    for approval in course['approvals']:
        approval['hasObsoleteRoom'] = room_id != approval.get('room', {}).get('id')
コード例 #5
0
    def test_are_scheduled_dates_obsolete_handles_nulls(self):
        with test_approvals_workflow(app):
            meeting = _create_meeting(
                days='MO',
                end_date=_format(datetime.now() + timedelta(days=100)),
                end_time='10:59',
                start_date=_format(datetime.now() - timedelta(days=100)),
                start_time='10:00',
            )
            with override_config(app, 'CURRENT_TERM_RECORDINGS_BEGIN', meeting['startDate']):
                with override_config(app, 'CURRENT_TERM_RECORDINGS_END', meeting['endDate']):
                    mock_scheduled(meeting=meeting, section_id=self.section_id, term_id=self.term_id)
                    course = SisSection.get_course(section_id=self.section_id, term_id=self.term_id)
                    scheduled = course['scheduled']

                    meeting = _create_meeting(
                        days=None,
                        end_date=None,
                        end_time=None,
                        start_date=None,
                        start_time=None,
                    )
            assert are_scheduled_dates_obsolete(meeting, scheduled) is True