示例#1
0
文件: legacy.py 项目: OmeGak/indico
 def _process(self):
     form = None
     parent_session_block = self.entry.parent.object if self.entry.parent else None
     if self.entry.contribution:
         contrib = self.entry.contribution
         tt_entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
         form = ContributionEntryForm(obj=FormDefaults(contrib, time=tt_entry_dt.time()),
                                      event=self.event_new, contrib=contrib, to_schedule=False,
                                      day=tt_entry_dt.date(), session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True, user=session.user) as changes:
                 with flash_if_unregistered(self.event_new, lambda: contrib.person_links):
                     update_contribution(contrib, *get_field_values(form.data))
             notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
             return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session),
                                 notifications=notifications)
         elif not form.is_submitted():
             handle_legacy_description(form.description, contrib)
         return jsonify_template('events/contributions/forms/contribution.html', form=form,
                                 fields=form._display_fields)
     elif self.entry.break_:
         break_ = self.entry.break_
         tt_entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
         form = BreakEntryForm(obj=FormDefaults(break_, time=tt_entry_dt.time()), event=self.event_new,
                               day=tt_entry_dt.date(), session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True, user=session.user) as changes:
                 update_break_entry(break_, form.data)
             notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
             return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session),
                                 notifications=notifications, flash=False)
     elif self.entry.session_block:
         if self.edit_session:
             session_ = self.entry.session_block.session
             form = SessionForm(obj=FormDefaults(session_), event=self.event_new)
             if form.validate_on_submit():
                 update_session(session_, form.data)
                 return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session), flash=False)
         else:
             block = self.entry.session_block
             tt_entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
             form = SessionBlockEntryForm(obj=FormDefaults(block, time=tt_entry_dt.time()),
                                          event=self.event_new, session_block=block, to_schedule=False,
                                          day=tt_entry_dt.date())
             if form.validate_on_submit():
                 with track_time_changes(auto_extend=True, user=session.user) as changes:
                     update_session_block(block, form.data)
                 notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.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, fields=getattr(form, '_display_fields', None))
示例#2
0
 def _process(self):
     form = None
     parent_session_block = self.entry.parent.object if self.entry.parent else None
     if self.entry.contribution:
         contrib = self.entry.contribution
         tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
         form = ContributionEntryForm(obj=FormDefaults(contrib, time=tt_entry_dt.time()),
                                      event=self.event, contrib=contrib, to_schedule=False,
                                      day=tt_entry_dt.date(), session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True, user=session.user) as changes:
                 with flash_if_unregistered(self.event, lambda: contrib.person_links):
                     update_contribution(contrib, *get_field_values(form.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)
         elif not form.is_submitted():
             handle_legacy_description(form.description, contrib)
         return jsonify_template('events/contributions/forms/contribution.html', form=form,
                                 fields=form._display_fields)
     elif self.entry.break_:
         break_ = self.entry.break_
         tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
         form = BreakEntryForm(obj=FormDefaults(break_, time=tt_entry_dt.time()), event=self.event,
                               day=tt_entry_dt.date(), session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True, user=session.user) as changes:
                 update_break_entry(break_, form.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)
     elif self.entry.session_block:
         if self.edit_session:
             session_ = self.entry.session_block.session
             form = SessionForm(obj=FormDefaults(session_), event=self.event)
             if form.validate_on_submit():
                 update_session(session_, form.data)
                 return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session), flash=False)
         else:
             block = self.entry.session_block
             tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
             form = SessionBlockEntryForm(obj=FormDefaults(block, time=tt_entry_dt.time()),
                                          event=self.event, session_block=block, to_schedule=False,
                                          day=tt_entry_dt.date())
             if form.validate_on_submit():
                 with track_time_changes(auto_extend=True, user=session.user) as changes:
                     update_session_block(block, form.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, fields=getattr(form, '_display_fields', None))
示例#3
0
 def _process_PATCH(self):
     RHSessionREST._process_PATCH(self)
     return jsonify_data(entries=[
         serialize_entry_update(block.timetable_entry)
         for block in self.session.blocks
     ],
                         flash=False)
示例#4
0
 def _process_POST(self):
     self.serializer = TimetableSerializer(self.event, management=True)
     with track_time_changes(auto_extend=True, user=session.user) as changes:
         entry_data = self._move_entry(request.json)
     rv = serialize_entry_update(self.entry) | entry_data
     notifications = get_time_changes_notifications(changes, tzinfo=self.event.tzinfo, entry=self.entry)
     return jsonify_data(flash=False, entry=rv, notifications=notifications)
示例#5
0
 def _process_POST(self):
     self.serializer = TimetableSerializer(True)
     with track_time_changes(auto_extend=True, user=session.user) as changes:
         entry_data = self._move_entry(request.json)
     rv = dict(serialize_entry_update(self.entry), **entry_data)
     notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
     return jsonify_data(flash=False, entry=rv, notifications=notifications)
示例#6
0
 def _process(self):
     defaults = self._get_form_defaults(location_parent=self.session_block)
     form = ContributionEntryForm(obj=defaults,
                                  to_schedule=True,
                                  **self._get_form_params())
     if form.validate_on_submit():
         contrib = Contribution()
         with track_time_changes(auto_extend=True,
                                 user=session.user) as changes:
             with flash_if_unregistered(self.event_new,
                                        lambda: contrib.person_links):
                 contrib = create_contribution(
                     self.event_new,
                     form.data,
                     session_block=self.session_block,
                     extend_parent=True)
         entry = contrib.timetable_entry
         notifications = get_time_changes_notifications(
             changes, tzinfo=self.event_new.tzinfo, entry=entry)
         return jsonify_data(
             entries=[serialize_entry_update(entry, session_=self.session)],
             notifications=notifications)
     self.commit = False
     return jsonify_template('events/contributions/forms/contribution.html',
                             form=form,
                             fields=form._display_fields)
示例#7
0
    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)
示例#8
0
 def _process(self):
     data = request.json
     required_keys = {'contribution_ids', 'day'}
     allowed_keys = required_keys | {'session_block_id'}
     if set(data.viewkeys()) > allowed_keys:
         raise BadRequest('Invalid keys found')
     elif required_keys > set(data.viewkeys()):
         raise BadRequest('Required keys missing')
     entries = []
     day = dateutil.parser.parse(data['day']).date()
     query = Contribution.query.with_parent(self.event_new).filter(
         Contribution.id.in_(data['contribution_ids']))
     with track_time_changes(auto_extend='end',
                             user=session.user) as changes:
         for contribution in query:
             start_dt = find_next_start_dt(
                 contribution.duration,
                 obj=self.session_block or self.event_new,
                 day=None if self.session_block else day,
                 force=True)
             entry = self._schedule(contribution, start_dt)
             if entry.end_dt.astimezone(
                     entry.event_new.tzinfo).date() > day:
                 raise UserValueError(
                     _("Contribution '{}' could not be scheduled since it doesn't fit on this day."
                       ).format(contribution.title))
             entries.append(entry)
     notifications = get_time_changes_notifications(
         changes, tzinfo=self.event_new.tzinfo)
     return jsonify_data(update=serialize_entry_update(
         entries[0], session_=self.session) if entries else None,
                         notifications=notifications,
                         flash=False)
示例#9
0
 def _process(self):
     direction = request.form['direction']
     with track_time_changes():
         swap_timetable_entry(self.entry, direction, session_=self.session)
     return jsonify_data(flash=False,
                         update=serialize_entry_update(
                             self.entry, session_=self.session))
示例#10
0
文件: legacy.py 项目: florv/indico
 def _process(self):
     data = request.json
     required_keys = {'contribution_ids', 'day'}
     allowed_keys = required_keys | {'session_block_id'}
     if data.viewkeys() > allowed_keys:
         raise BadRequest('Invalid keys found')
     elif required_keys > data.viewkeys():
         raise BadRequest('Required keys missing')
     entries = []
     day = dateutil.parser.parse(data['day']).date()
     query = Contribution.query.with_parent(self.event_new).filter(Contribution.id.in_(data['contribution_ids']))
     with track_time_changes(auto_extend='end', user=session.user) as changes:
         for contribution in query:
             start_dt = find_next_start_dt(contribution.duration,
                                           obj=self.session_block or self.event_new,
                                           day=None if self.session_block else day,
                                           force=True)
             entry = self._schedule(contribution, start_dt)
             if entry.end_dt.astimezone(entry.event_new.tzinfo).date() > day:
                 raise UserValueError(_("Contribution '{}' could not be scheduled since it doesn't fit on this day.")
                                      .format(contribution.title))
             entries.append(entry)
     notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo)
     return jsonify_data(update=serialize_entry_update(entries[0], session_=self.session) if entries else None,
                         notifications=notifications, flash=False)
示例#11
0
    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)
示例#12
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)
示例#13
0
 def _process_PATCH(self):
     RHSessionREST._process_PATCH(self)
     entries = [
         serialize_entry_update(
             block.timetable_entry,
             session_=(self.session if self.is_session_timetable else None))
         for block in self.session.blocks
     ]
     return jsonify_data(entries=entries, flash=False)
示例#14
0
 def _process(self):
     defaults = self._get_form_defaults(location_parent=self.session)
     form = SessionBlockEntryForm(obj=defaults, **self._get_form_params())
     if form.validate_on_submit():
         with track_time_changes(auto_extend=True, user=session.user) as changes:
             entry = create_session_block_entry(self.session, form.data)
         notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=entry)
         return jsonify_data(entry=serialize_entry_update(entry), notifications=notifications, flash=False)
     self.commit = False
     return jsonify_form(form, fields=form._display_fields, disabled_until_change=False)
示例#15
0
文件: legacy.py 项目: florv/indico
 def _process(self):
     new_start_dt = (self.event_new.tzinfo.localize(dateutil.parser.parse(request.form.get('startDate')))
                     .astimezone(utc))
     shift = new_start_dt - self.entry.start_dt
     with track_time_changes(auto_extend=True, user=session.user) as changes:
         shift_following_entries(self.entry, shift, session_=self.session)
         self.entry.move(new_start_dt)
     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)
示例#16
0
 def _process(self):
     colors = self._get_default_colors()
     defaults = self._get_form_defaults(colors=colors, location_parent=self.session_block)
     form = BreakEntryForm(obj=defaults, **self._get_form_params())
     if form.validate_on_submit():
         with track_time_changes(auto_extend=True, user=session.user) as changes:
             entry = create_break_entry(self.event_new, form.data, session_block=self.session_block)
         notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=entry)
         return jsonify_data(entry=serialize_entry_update(entry), notifications=notifications, flash=False)
     return jsonify_form(form, fields=form._display_fields)
示例#17
0
 def _process(self):
     new_start_dt = (self.event.tzinfo.localize(dateutil.parser.parse(request.form.get('startDate')))
                     .astimezone(utc))
     shift = new_start_dt - self.entry.start_dt
     with track_time_changes(auto_extend=True, user=session.user) as changes:
         shift_following_entries(self.entry, shift, session_=self.session)
         self.entry.move(new_start_dt)
     notifications = get_time_changes_notifications(changes, tzinfo=self.event.tzinfo, entry=self.entry)
     return jsonify_data(flash=False, update=serialize_entry_update(self.entry, session_=self.session),
                         notifications=notifications)
示例#18
0
 def _process(self):
     colors = self._get_default_colors()
     defaults = self._get_form_defaults(colors=colors, location_parent=self.session_block)
     form = BreakEntryForm(obj=defaults, **self._get_form_params())
     if form.validate_on_submit():
         with track_time_changes(auto_extend=True, user=session.user) as changes:
             entry = create_break_entry(self.event, form.data, session_block=self.session_block)
         notifications = get_time_changes_notifications(changes, tzinfo=self.event.tzinfo, entry=entry)
         return jsonify_data(update=serialize_entry_update(entry, session_=self.session),
                             notifications=notifications, flash=False)
     return jsonify_form(form, fields=form._display_fields)
示例#19
0
 def _process(self):
     defaults = self._get_form_defaults(location_parent=self.parent_session)
     form = SessionBlockEntryForm(obj=defaults, **self._get_form_params())
     if form.validate_on_submit():
         with track_time_changes(auto_extend=True, user=session.user) as changes:
             entry = create_session_block_entry(self.parent_session, form.data)
         notifications = get_time_changes_notifications(changes, tzinfo=self.event.tzinfo, entry=entry)
         return jsonify_data(update=serialize_entry_update(entry, session_=self.session),
                             notifications=notifications, flash=False)
     self.commit = False
     return jsonify_form(form, fields=form._display_fields, disabled_until_change=False)
示例#20
0
 def _process(self):
     defaults = self._get_form_defaults(location_parent=self.session_block)
     form = ContributionEntryForm(obj=defaults, to_schedule=True, **self._get_form_params())
     if form.validate_on_submit():
         with track_time_changes(auto_extend=True, user=session.user) as changes:
             contrib = create_contribution(self.event_new, form.data, session_block=self.session_block,
                                           extend_parent=True)
         entry = contrib.timetable_entry
         notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=entry)
         return jsonify_data(entries=[serialize_entry_update(entry)], notifications=notifications, flash=False)
     self.commit = False
     return jsonify_template('events/contributions/forms/contribution.html', form=form, fields=form._display_fields)
示例#21
0
 def _process(self):
     data = request.json
     required_keys = {'contribution_ids', 'day'}
     allowed_keys = required_keys | {'session_block_id'}
     if data.viewkeys() > allowed_keys:
         raise BadRequest('Invalid keys found')
     elif required_keys > data.viewkeys():
         raise BadRequest('Required keys missing')
     entries = []
     day = dateutil.parser.parse(data['day']).date()
     query = Contribution.query.with_parent(self.event_new).filter(Contribution.id.in_(data['contribution_ids']))
     for contribution in query:
         start_dt = find_next_start_dt(contribution.duration,
                                       obj=self.session_block or self.event_new,
                                       day=None if self.session_block else day)
         # TODO: handle scheduling not-fitting contributions
         #       can only happen within session blocks that are shorter than contribution's duration
         if start_dt:
             entries.append(self._schedule(contribution, start_dt))
     return jsonify(entries=[serialize_entry_update(x) for x in entries])
示例#22
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)
示例#23
0
 def _process(self):
     data = request.json
     required_keys = {'contribution_ids', 'day'}
     allowed_keys = required_keys | {'session_block_id'}
     if data.viewkeys() > allowed_keys:
         raise BadRequest('Invalid keys found')
     elif required_keys > data.viewkeys():
         raise BadRequest('Required keys missing')
     entries = []
     day = dateutil.parser.parse(data['day']).date()
     query = Contribution.query.with_parent(self.event_new).filter(
         Contribution.id.in_(data['contribution_ids']))
     for contribution in query:
         start_dt = find_next_start_dt(
             contribution.duration,
             obj=self.session_block or self.event_new,
             day=None if self.session_block else day)
         # TODO: handle scheduling not-fitting contributions
         #       can only happen within session blocks that are shorter than contribution's duration
         if start_dt:
             entries.append(self._schedule(contribution, start_dt))
     return jsonify(entries=[serialize_entry_update(x) for x in entries])
示例#24
0
 def _process_PATCH(self):
     RHBreakREST._process_PATCH(self)
     return jsonify_data(entries=[serialize_entry_update(self.entry)], flash=False)
示例#25
0
文件: legacy.py 项目: florv/indico
 def _process(self):
     direction = request.form['direction']
     with track_time_changes():
         swap_timetable_entry(self.entry, direction, session_=self.session)
     return jsonify_data(flash=False, update=serialize_entry_update(self.entry, session_=self.session))
示例#26
0
 def _process(self):
     form = None
     parent_session_block = self.entry.parent.object if self.entry.parent else None
     if self.entry.contribution:
         contrib = self.entry.contribution
         tt_entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
         form = ContributionEntryForm(obj=FormDefaults(
             contrib, time=tt_entry_dt.time()),
                                      event=self.event_new,
                                      contrib=contrib,
                                      to_schedule=False,
                                      day=tt_entry_dt.date(),
                                      session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True,
                                     user=session.user) as changes:
                 update_contribution(contrib, *_get_field_values(form.data))
             notifications = get_time_changes_notifications(
                 changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
             return jsonify_data(
                 entries=[serialize_entry_update(contrib.timetable_entry)],
                 notifications=notifications,
                 flash=False)
         return jsonify_template(
             'events/contributions/forms/contribution.html',
             form=form,
             fields=form._display_fields)
     elif self.entry.break_:
         break_ = self.entry.break_
         tt_entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
         form = BreakEntryForm(obj=FormDefaults(break_,
                                                time=tt_entry_dt.time()),
                               event=self.event_new,
                               day=tt_entry_dt.date(),
                               session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True,
                                     user=session.user) as changes:
                 update_break_entry(break_, form.data)
             notifications = get_time_changes_notifications(
                 changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
             return jsonify_data(
                 entries=[serialize_entry_update(break_.timetable_entry)],
                 notifications=notifications,
                 flash=False)
     elif self.entry.session_block:
         if self.edit_session:
             session_ = self.entry.session_block.session
             form = SessionForm(obj=FormDefaults(session_),
                                event=self.event_new)
             if form.validate_on_submit():
                 update_session(session_, form.data)
                 return jsonify_data(entries=[
                     serialize_entry_update(x.timetable_entry)
                     for x in session_.blocks
                 ],
                                     flash=False)
         else:
             block = self.entry.session_block
             tt_entry_dt = self.entry.start_dt.astimezone(
                 self.event_new.tzinfo)
             form = SessionBlockEntryForm(obj=FormDefaults(
                 block, time=tt_entry_dt.time()),
                                          event=self.event_new,
                                          session_block=block,
                                          to_schedule=False,
                                          day=tt_entry_dt.date())
             if form.validate_on_submit():
                 with track_time_changes(auto_extend=True,
                                         user=session.user) as changes:
                     update_session_block(block, form.data)
                 notifications = get_time_changes_notifications(
                     changes,
                     tzinfo=self.event_new.tzinfo,
                     entry=self.entry)
                 return jsonify_data(entries=[
                     serialize_entry_update(block.timetable_entry)
                 ],
                                     notifications=notifications,
                                     flash=False)
     self.commit = False
     return jsonify_form(form,
                         fields=getattr(form, '_display_fields', None))
示例#27
0
 def _process_PATCH(self):
     RHSessionREST._process_PATCH(self)
     return jsonify_data(entries=[serialize_entry_update(block.timetable_entry) for block in self.session.blocks],
                         flash=False)
示例#28
0
 def _process(self):
     contrib = ContributionCloner.clone_single_contribution(self.contrib, preserve_session=True)
     return jsonify_data(update=serialize_entry_update(contrib.timetable_entry, session_=contrib.session))
示例#29
0
 def _process(self):
     contrib = ContributionCloner.clone_single_contribution(
         self.contrib, preserve_session=True)
     return jsonify_data(update=serialize_entry_update(
         contrib.timetable_entry, session_=contrib.session))
示例#30
0
 def _process_PATCH(self):
     RHBreakREST._process_PATCH(self)
     return jsonify_data(entries=[serialize_entry_update(self.entry)],
                         flash=False)
示例#31
0
文件: legacy.py 项目: jas01/indico
 def _process_PATCH(self):
     RHSessionREST._process_PATCH(self)
     entries = [serialize_entry_update(block.timetable_entry,
                                       session_=(self.session if self.is_session_timetable else None))
                for block in self.session.blocks]
     return jsonify_data(entries=entries, flash=False)