示例#1
0
 def _process(self):
     new_start_dt = self.event_new.tzinfo.localize(
         dateutil.parser.parse(
             request.form.get('startDate'))).astimezone(utc)
     new_end_dt = self.event_new.tzinfo.localize(
         dateutil.parser.parse(request.form.get('endDate'))).astimezone(utc)
     new_duration = new_end_dt - new_start_dt
     is_session_block = self.entry.type == TimetableEntryType.SESSION_BLOCK
     tzinfo = self.event_new.tzinfo
     if is_session_block and new_end_dt.astimezone(tzinfo).date(
     ) != self.entry.start_dt.astimezone(tzinfo).date():
         raise UserValueError(
             _('Session block cannot span more than one day'))
     with track_time_changes(auto_extend=True,
                             user=session.user) as changes:
         update_timetable_entry_object(self.entry,
                                       {'duration': new_duration})
         if is_session_block:
             self.entry.move(new_start_dt)
         if not is_session_block:
             update_timetable_entry(self.entry, {'start_dt': new_start_dt})
     if is_session_block and self.entry.children:
         if new_end_dt < max(self.entry.children,
                             key=attrgetter('end_dt')).end_dt:
             raise UserValueError(
                 _("Session block cannot be shortened this much because contributions contained "
                   "wouldn't fit."))
     notifications = get_time_changes_notifications(
         changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
     return jsonify_data(flash=False,
                         update=serialize_entry_update(
                             self.entry, session_=self.session),
                         notifications=notifications)
示例#2
0
 def _process(self):
     new_start_dt = self.event_new.tzinfo.localize(
         dateutil.parser.parse(request.form.get('startDate'))).astimezone(utc)
     new_end_dt = self.event_new.tzinfo.localize(dateutil.parser.parse(request.form.get('endDate'))).astimezone(utc)
     new_duration = new_end_dt - new_start_dt
     is_session_block = self.entry.type == TimetableEntryType.SESSION_BLOCK
     tzinfo = self.event_new.tzinfo
     if is_session_block and new_end_dt.astimezone(tzinfo).date() != self.entry.start_dt.astimezone(tzinfo).date():
         raise UserValueError(_('Session block cannot span more than one day'))
     with track_time_changes(auto_extend=True, user=session.user) as changes:
         update_timetable_entry_object(self.entry, {'duration': new_duration})
         if is_session_block:
             self.entry.move(new_start_dt)
         if not is_session_block:
             update_timetable_entry(self.entry, {'start_dt': new_start_dt})
     if is_session_block and self.entry.children:
         if new_end_dt < max(self.entry.children, key=attrgetter('end_dt')).end_dt:
             raise UserValueError(_("Session block cannot be shortened this much because contributions contained "
                                    "wouldn't fit."))
     notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
     return jsonify_data(flash=False, entry=serialize_entry_update(self.entry), notifications=notifications)