def _process(self): item = self.entry.object entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo) form = BaseEntryForm(obj=FormDefaults(item, time=entry_dt.time()), day=entry_dt.date(), event=self.event, entry=self.entry, session_block=self.entry.parent.object if self.entry.parent else None) data = form.data shift_later = data.pop('shift_later') if form.validate_on_submit(): with track_time_changes(auto_extend=True, user=session.user) as changes: if shift_later: new_end_dt = form.start_dt.data + form.duration.data shift = new_end_dt - self.entry.end_dt shift_following_entries(self.entry, shift, session_=self.session) if self.entry.contribution: update_timetable_entry(self.entry, {'start_dt': form.start_dt.data}) update_contribution(item, {'duration': form.duration.data}) elif self.entry.break_: update_break_entry(item, data) elif self.entry.session_block: update_session_block(item, data) notifications = get_time_changes_notifications(changes, tzinfo=self.event.tzinfo, entry=self.entry) return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session), notifications=notifications, flash=False) self.commit = False return jsonify_form(form, back_button=False, disabled_until_change=True)
def _process(self): item = self.entry.object entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo) form = BaseEntryForm(obj=FormDefaults(item, time=entry_dt.time()), day=entry_dt.date(), event=self.event_new, entry=self.entry, session_block=self.entry.parent.object if self.entry.parent else None) data = form.data shift_later = data.pop('shift_later') updated_entries = [] if form.validate_on_submit(): with track_time_changes(auto_extend=True, user=session.user) as changes: if shift_later: new_end_dt = form.start_dt.data + form.duration.data shift = new_end_dt - self.entry.end_dt updated_entries += shift_following_entries(self.entry, shift, session_=self.session) if self.entry.contribution: update_timetable_entry(self.entry, {'start_dt': form.start_dt.data}) update_contribution(item, {'duration': form.duration.data}) elif self.entry.break_: update_break_entry(item, data) elif self.entry.session_block: update_session_block(item, data) notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry) updated_entries.append(item.timetable_entry) return jsonify_data(entries=[serialize_entry_update(entry) for entry in updated_entries], flash=False, shift_later=shift_later, notifications=notifications) self.commit = False return jsonify_form(form, back_button=False, disabled_until_change=True)