Пример #1
0
    def get(self, schedule_id):
        # Get schedule by id
        schedule = Schedule.get_by_id(schedule_id)
        if schedule is None:
            abort(404)

        # Return user
        return schedule
Пример #2
0
    def put(self, schedule_id):
        # Get schedule by id
        schedule = Schedule.get_by_id(schedule_id)
        if schedule is None:
            abort(404)

        # Update schedule fields
        args = self.parser.parse_args()
        schedule.year = assign(args['year'], schedule.year)
        schedule.week = assign(args['week'], schedule.week)
        schedule.day_of_week = assign(args['day_of_week'],
                                      schedule.day_of_week)
        schedule.start_time = assign(args['start_time'], schedule.start_time)
        schedule.end_time = assign(args['end_time'], schedule.end_time)

        # Persist changes and return schedule
        schedule.persist()
        return schedule