def _process(self): contrib_form_class = make_contribution_form(self.event) custom_field_values = { 'custom_{}'.format(x.contribution_field_id): x.data for x in self.contrib.field_values } parent_session_block = ( self.contrib.timetable_entry.parent.session_block if (self.contrib.timetable_entry and self.contrib.timetable_entry.parent) else None) form = contrib_form_class(obj=FormDefaults( self.contrib, start_date=self.contrib.start_dt, **custom_field_values), event=self.event, contrib=self.contrib, session_block=parent_session_block) if form.validate_on_submit(): with track_time_changes(), flash_if_unregistered( self.event, lambda: self.contrib.person_links): update_contribution(self.contrib, *get_field_values(form.data)) flash( _("Contribution '{}' successfully updated").format( self.contrib.title), 'success') tpl_components = self.list_generator.render_list(self.contrib) if tpl_components['hide_contrib']: self.list_generator.flash_info_message(self.contrib) return jsonify_data(flash=(request.args.get('flash') == '1'), **tpl_components) elif not form.is_submitted(): handle_legacy_description(form.description, self.contrib) self.commit = False return jsonify_template('events/contributions/forms/contribution.html', form=form)
def _process(self): inherited_location = self.event.location_data inherited_location['inheriting'] = True default_duration = contribution_settings.get(self.event, 'default_duration') contrib_form_class = make_contribution_form(self.event) form = contrib_form_class(obj=FormDefaults( location_data=inherited_location, duration=default_duration), event=self.event) if form.validate_on_submit(): # Create empty contribution so it can be compared to the new one in flash_if_unregistered contrib = Contribution() with flash_if_unregistered(self.event, lambda: contrib.person_links): contrib = create_contribution(self.event, *get_field_values(form.data)) flash( _("Contribution '{}' created successfully").format( contrib.title), 'success') tpl_components = self.list_generator.render_list(contrib) if tpl_components['hide_contrib']: self.list_generator.flash_info_message(contrib) return jsonify_data(**tpl_components) return jsonify_template('events/contributions/forms/contribution.html', form=form)
def _process(self): abstract_form_class = make_abstract_form(self.event, session.user, management=self.management) custom_field_values = { f'custom_{x.contribution_field_id}': x.data for x in self.abstract.field_values } defaults = FormDefaults(self.abstract, attachments=self.abstract.files, **custom_field_values) form = abstract_form_class( obj=defaults, abstract=self.abstract, event=self.event, management=self.management, invited=(self.abstract.state == AbstractState.invited)) if form.validate_on_submit(): fields, custom_fields = get_field_values(form.data) update_abstract(self.abstract, fields, custom_fields) flash(_("Abstract modified successfully"), 'success') return jsonify_data(flash=False) self.commit = False disabled_fields = ( 'submitted_for_tracks', ) if form.track_field_disabled else () return jsonify_form( form, disabled_fields=disabled_fields, form_header_kwargs={'action': request.relative_url})
def _process(self): is_invited = request.args.get('invited') == '1' abstract_form_class = make_abstract_form(self.event, session.user, notification_option=True, management=self.management, invited=is_invited) cloned_fields = self.clone_fields( self.abstract) if self.abstract else {} form = abstract_form_class(event=self.event, management=self.management, invited=is_invited, **cloned_fields) if is_invited: del form.submitted_contrib_type del form.attachments del form.send_notifications del form.person_links if form.validate_on_submit(): data = form.data submitter = None if is_invited: if form.users_with_no_account.data == 'existing': submitter = data['submitter'] else: submitter = User(first_name=data['first_name'], last_name=data['last_name'], email=data['email'], is_pending=True) db.session.add(submitter) db.session.flush() data.pop('first_name') data.pop('last_name') data.pop('email') data.pop('users_with_no_account') data.pop('submitter') send_notifications = data.pop('send_notifications', is_invited) abstract = create_abstract(self.event, *get_field_values(data), send_notifications=send_notifications, submitter=submitter, is_invited=is_invited) flash( _("Abstract '{}' created successfully").format(abstract.title), 'success') tpl_components = self.list_generator.render_list(abstract) if tpl_components.get('hide_abstract'): self.list_generator.flash_info_message(abstract) return jsonify_data(**tpl_components) return jsonify_form( form, back=_('Cancel'), disabled_until_change=(not self.abstract or is_invited), form_header_kwargs={'action': request.relative_url})
def _process_POST(self): form = self._create_form() if form.validate_on_submit(): fields, custom_fields = get_field_values(form.data) abstract_data = dict(fields, state=AbstractState.submitted, uuid=None) update_abstract(self.abstract, abstract_data, custom_fields) return jsonify_data(flash=False, redirect=url_for('.call_for_abstracts', self.event)) return jsonify_form(form, form_header_kwargs={'action': url_for('.submit_invited_abstract', self.abstract.locator.token)})
def _process(self): abstract_form_class = make_abstract_form(self.event, session.user, management=self.management) form = abstract_form_class(event=self.event) if form.validate_on_submit(): abstract = create_abstract(self.event, *get_field_values(form.data), send_notifications=True) flash(_("Your abstract '{}' has been successfully submitted. It is registered with the number " "#{}. You will be notified by email with the submission details.") .format(abstract.title, abstract.friendly_id), 'success') return jsonify_data(flash=False, redirect=url_for('.call_for_abstracts', self.event)) return jsonify_template('events/abstracts/display/submission.html', event=self.event, form=form)
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))
def _process(self): abstract_form_class = make_abstract_form(self.event, session.user, management=self.management) custom_field_values = {'custom_{}'.format(x.contribution_field_id): x.data for x in self.abstract.field_values} defaults = FormDefaults(self.abstract, attachments=self.abstract.files, **custom_field_values) form = abstract_form_class(obj=defaults, abstract=self.abstract, event=self.event, management=self.management) if form.validate_on_submit(): update_abstract(self.abstract, *get_field_values(form.data)) flash(_("Abstract modified successfully"), 'success') return jsonify_data(flash=False) self.commit = False disabled_fields = ('submitted_for_tracks',) if form.track_field_disabled else () return jsonify_form(form, disabled_fields=disabled_fields, form_header_kwargs={'action': request.relative_url})
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))
def _process(self): abstract_form_class = make_abstract_form(self.event_new, notification_option=True, management=self.management) form = abstract_form_class(event=self.event_new) if form.validate_on_submit(): data = form.data send_notifications = data.pop('send_notifications') abstract = create_abstract(self.event_new, *get_field_values(data), send_notifications=send_notifications) flash(_("Abstract '{}' created successfully").format(abstract.title), 'success') tpl_components = self.list_generator.render_list(abstract) if tpl_components.get('hide_abstract'): self.list_generator.flash_info_message(abstract) return jsonify_data(**tpl_components) return jsonify_form(form, back=_("Cancel"), form_header_kwargs={'action': request.relative_url})
def _process(self): inherited_location = self.event_new.location_data inherited_location['inheriting'] = True contrib_form_class = make_contribution_form(self.event_new) form = contrib_form_class(obj=FormDefaults(location_data=inherited_location), event=self.event_new) if form.validate_on_submit(): # Create empty contribution so it can be compared to the new one in flash_if_unregistered contrib = Contribution() with flash_if_unregistered(self.event_new, lambda: contrib.person_links): contrib = create_contribution(self.event_new, *get_field_values(form.data)) flash(_("Contribution '{}' created successfully").format(contrib.title), 'success') tpl_components = self.list_generator.render_list(contrib) if tpl_components['hide_contrib']: self.list_generator.flash_info_message(contrib) return jsonify_data(**tpl_components) return jsonify_template('events/contributions/forms/contribution.html', form=form)
def _process(self): contrib_form_class = make_contribution_form(self.event) custom_field_values = {'custom_{}'.format(x.contribution_field_id): x.data for x in self.contrib.field_values} parent_session_block = (self.contrib.timetable_entry.parent.session_block if (self.contrib.timetable_entry and self.contrib.timetable_entry.parent) else None) form = contrib_form_class(obj=FormDefaults(self.contrib, start_date=self.contrib.start_dt, **custom_field_values), event=self.event, contrib=self.contrib, session_block=parent_session_block) if form.validate_on_submit(): with track_time_changes(), flash_if_unregistered(self.event, lambda: self.contrib.person_links): update_contribution(self.contrib, *get_field_values(form.data)) flash(_("Contribution '{}' successfully updated").format(self.contrib.title), 'success') tpl_components = self.list_generator.render_list(self.contrib) if tpl_components['hide_contrib']: self.list_generator.flash_info_message(self.contrib) return jsonify_data(flash=(request.args.get('flash') == '1'), **tpl_components) elif not form.is_submitted(): handle_legacy_description(form.description, self.contrib) self.commit = False return jsonify_template('events/contributions/forms/contribution.html', form=form)