Beispiel #1
0
 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})
Beispiel #2
0
    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})
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 def _create_form(self):
     form_user = session.user or self.abstract.submitter
     abstract_form_cls = make_abstract_form(self.event, form_user)
     custom_field_values = {
         'custom_{}'.format(x.contribution_field_id): x.data
         for x in self.abstract.field_values
     }
     form_defaults = FormDefaults(self.abstract, **custom_field_values)
     return abstract_form_cls(obj=form_defaults,
                              event=self.event,
                              abstract=self.abstract)
Beispiel #6
0
 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})
Beispiel #7
0
 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})
Beispiel #8
0
 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})