Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     event = kwargs['event']
     self.track_field_disabled = (
         kwargs.get('abstract')
         and kwargs['abstract'].edit_track_mode != EditTrackMode.both)
     if abstracts_settings.get(
             event, 'tracks_required') and not self.track_field_disabled:
         inject_validators(self, 'submitted_for_tracks', [DataRequired()])
     super(SingleTrackMixin, self).__init__(*args, **kwargs)
     if not abstracts_settings.get(event, 'tracks_required'):
         self.submitted_for_tracks.blank_text = _('No track selected')
     self.submitted_for_tracks.query = Track.query.with_parent(
         event).order_by(Track.position)
Ejemplo n.º 2
0
 def _process(self):
     description_settings = abstracts_settings.get(self.event,
                                                   'description_settings')
     form = AbstractContentSettingsForm(
         obj=FormDefaults(description_settings))
     if form.validate_on_submit():
         abstracts_settings.set(self.event, 'description_settings',
                                form.data)
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     self.event = kwargs.pop('event')
     self.abstract = kwargs.pop('abstract', None)
     description_settings = abstracts_settings.get(self.event,
                                                   'description_settings')
     description_validators = self._get_description_validators(
         description_settings)
     if description_validators:
         inject_validators(self, 'description', description_validators)
     if abstracts_settings.get(self.event, 'contrib_type_required'):
         inject_validators(self, 'submitted_contrib_type', [DataRequired()])
     super(AbstractForm, self).__init__(*args, **kwargs)
     self.submitted_contrib_type.query = self.event.contribution_types
     if not self.submitted_contrib_type.query.count():
         del self.submitted_contrib_type
     if not self.event.cfa.allow_attachments:
         del self.attachments
     if not description_settings['is_active']:
         del self.description
     self.person_links.require_speaker_author = abstracts_settings.get(
         self.event, 'speakers_required')
     self.person_links.allow_speakers = abstracts_settings.get(
         self.event, 'allow_speakers')
Ejemplo n.º 4
0
def make_abstract_form(event, notification_option=False, management=False):
    """Extends the abstract WTForm to add the extra fields.

    Each extra field will use a field named ``custom_ID``.

    :param event: The `Event` for which to create the abstract form.
    :param notification_option: Whether to add a field to the form to
                                disable triggering notifications for
                                the abstract submission.
    :param management Whether it's a manager using the abstract form
    :return: An `AbstractForm` subclass.
    """
    from fossir.modules.events.abstracts.forms import (AbstractForm,
                                                       MultiTrackMixin,
                                                       SingleTrackMixin,
                                                       NoTrackMixin,
                                                       SendNotificationsMixin)

    mixins = []
    if not event.tracks:
        mixins.append(NoTrackMixin)
    elif abstracts_settings.get(event, 'allow_multiple_tracks'):
        mixins.append(MultiTrackMixin)
    else:
        mixins.append(SingleTrackMixin)
    if notification_option:
        mixins.append(SendNotificationsMixin)
    form_class = type(b'_AbstractForm', tuple(mixins) + (AbstractForm, ), {})
    for custom_field in event.contribution_fields:
        field_impl = custom_field.mgmt_field if management else custom_field.field
        if field_impl is None:
            # field definition is not available anymore
            continue
        name = 'custom_{}'.format(custom_field.id)
        setattr(form_class, name, field_impl.create_wtf_field())
    return form_class
Ejemplo n.º 5
0
 def announcement(self):
     announcement = abstracts_settings.get(self.event, 'announcement')
     render_mode = abstracts_settings.get(self.event,
                                          'announcement_render_mode')
     return RENDER_MODE_WRAPPER_MAP[render_mode](announcement)