Esempio n. 1
0
 def _process(self):
     form = SessionForm(obj=self.session, event=self.event)
     if form.validate_on_submit():
         with track_location_changes():
             update_session(self.session, form.data)
         return jsonify_data(html=_render_session_list(self.event))
     return jsonify_form(form)
Esempio n. 2
0
 def _process(self):
     inherited_location = self.event.location_data
     inherited_location['inheriting'] = True
     form = SessionForm(obj=FormDefaults(colors=get_random_color(self.event), location_data=inherited_location),
                        event=self.event)
     if form.validate_on_submit():
         new_session = create_session(self.event, form.data)
         return self._get_response(new_session)
     return jsonify_form(form)
Esempio n. 3
0
 def _process(self):
     inherited_location = self.event.location_data
     inherited_location['inheriting'] = True
     form = SessionForm(obj=FormDefaults(colors=get_random_color(self.event), location_data=inherited_location),
                        event=self.event)
     if form.validate_on_submit():
         new_session = create_session(self.event, form.data)
         return self._get_response(new_session)
     return jsonify_form(form)
Esempio n. 4
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))
Esempio n. 5
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))
Esempio n. 6
0
 def _process(self):
     form = SessionForm(obj=self.session, event=self.event_new)
     if form.validate_on_submit():
         update_session(self.session, form.data)
         return jsonify_data(html=_render_session_list(self.event_new))
     return jsonify_form(form)
Esempio n. 7
0
 def _process(self):
     form = SessionForm(obj=self.session, event=self.event)
     if form.validate_on_submit():
         update_session(self.session, form.data)
         return jsonify_data(html=_render_session_list(self.event))
     return jsonify_form(form)