예제 #1
0
 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)
예제 #2
0
 def _process(self):
     contrib_form_class = make_contribution_form(self.event_new)
     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_new,
                               contrib=self.contrib,
                               session_block=parent_session_block)
     if form.validate_on_submit():
         with track_time_changes():
             update_contribution(self.contrib,
                                 *_get_field_values(form.data))
         flash(
             _("Contribution '{}' successfully updated").format(
                 self.contrib.title), 'success')
         tpl_components = self.reporter.render_contrib_report(self.contrib)
         if tpl_components['hide_contrib']:
             self.reporter.flash_info_message(self.contrib)
         return jsonify_data(**tpl_components)
     self.commit = False
     return jsonify_template('events/contributions/forms/contribution.html',
                             form=form)
예제 #3
0
 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)
예제 #4
0
파일: management.py 프로젝트: fph/indico
 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():
         contrib = create_contribution(self.event_new, *_get_field_values(form.data))
         flash(_("Contribution '{}' created successfully").format(contrib.title), 'success')
         tpl_components = self.reporter.render_contrib_report(contrib)
         if tpl_components['hide_contrib']:
             self.reporter.flash_info_message(contrib)
         return jsonify_data(**tpl_components)
     return jsonify_template('events/contributions/forms/contribution.html', form=form)
예제 #5
0
 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)
예제 #6
0
파일: management.py 프로젝트: fph/indico
 def _process(self):
     contrib_form_class = make_contribution_form(self.event_new)
     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_new, contrib=self.contrib, session_block=parent_session_block)
     if form.validate_on_submit():
         with track_time_changes():
             update_contribution(self.contrib, *_get_field_values(form.data))
         flash(_("Contribution '{}' successfully updated").format(self.contrib.title), 'success')
         tpl_components = self.reporter.render_contrib_report(self.contrib)
         if tpl_components['hide_contrib']:
             self.reporter.flash_info_message(self.contrib)
         return jsonify_data(**tpl_components)
     self.commit = False
     return jsonify_template('events/contributions/forms/contribution.html', form=form)
예제 #7
0
 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():
         contrib = create_contribution(self.event_new,
                                       *_get_field_values(form.data))
         flash(
             _("Contribution '{}' created successfully").format(
                 contrib.title), 'success')
         tpl_components = self.reporter.render_contrib_report(contrib)
         if tpl_components['hide_contrib']:
             self.reporter.flash_info_message(contrib)
         return jsonify_data(**tpl_components)
     return jsonify_template('events/contributions/forms/contribution.html',
                             form=form)
예제 #8
0
파일: management.py 프로젝트: indico/indico
 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)