Ejemplo n.º 1
0
 def _process(self):
     form = RegistrationFormForm(
         event=self.event,
         publish_registrations_enabled=(self.event.type_ !=
                                        EventType.conference))
     if form.validate_on_submit():
         regform = RegistrationForm(event=self.event)
         create_personal_data_fields(regform)
         form.populate_obj(regform)
         db.session.add(regform)
         db.session.flush()
         signals.event.registration_form_created.send(regform)
         flash(_('Registration form has been successfully created'),
               'success')
         self.event.log(
             EventLogRealm.management, EventLogKind.positive,
             'Registration',
             'Registration form "{}" has been created'.format(
                 regform.title), session.user)
         return redirect(url_for('.manage_regform', regform))
     return WPManageRegistration.render_template(
         'management/regform_edit.html',
         self.event,
         form=form,
         regform=None)
Ejemplo n.º 2
0
    def _create_form(self):
        create_personal_data_fields(self.regform)
        for item in self.regform.form_items:
            if not item.is_field:
                item.position = 1  # pd section
                continue
            # we have nothing but personal data fields right now. no need for extra checks!
            if item.personal_data_type != PersonalDataType.country:
                self.pd_field_map[item.personal_data_type] = item
            if item.personal_data_type == PersonalDataType.title:
                self.title_map = {v: k for k, v in item.data['captions'].iteritems()}

        # create administrative section for statuses
        if self.status_used:
            section = RegistrationFormSection(registration_form=self.regform, is_manager_only=True, title='Status',
                                              position=2)
            if self.status_used:
                choices = []
                for status in ('refused', 'excused', 'invited', 'accepted', 'rejected', 'declined'):
                    uuid = unicode(uuid4())
                    caption = status.title()
                    choices.append({'price': 0, 'is_billable': False, 'places_limit': 0, 'is_enabled': True,
                                    'caption': caption, 'id': uuid})
                    self.status_map[status] = {'uuid': uuid, 'caption': caption}
                field_data = {
                    'item_type': 'dropdown',
                    'with_extra_slots': False,
                    'default_item': None,
                    'choices': choices
                }
                self.status_field = field = RegistrationFormField(registration_form=self.regform, parent=section,
                                                                  input_type='single_choice', title='Status')
                field.data, field.versioned_data = field.field_impl.process_field_data(field_data)
Ejemplo n.º 3
0
 def _process(self):
     participant_visibility = (PublishRegistrationsMode.hide_all
                               if self.event.type_ == EventType.conference
                               else PublishRegistrationsMode.show_all)
     public_visibility = PublishRegistrationsMode.hide_all
     form = RegistrationFormCreateForm(event=self.event,
                                       visibility=[participant_visibility.name, public_visibility.name, None])
     if form.validate_on_submit():
         regform = RegistrationForm(event=self.event, currency=payment_settings.get('currency'))
         create_personal_data_fields(regform)
         form.populate_obj(regform, skip=['visibility'])
         participant_visibility, public_visibility, visibility_duration = form.visibility.data
         regform.publish_registrations_participants = PublishRegistrationsMode[participant_visibility]
         regform.publish_registrations_public = PublishRegistrationsMode[public_visibility]
         regform.publish_registrations_duration = (timedelta(days=visibility_duration*30)
                                                   if visibility_duration is not None else None)
         db.session.add(regform)
         db.session.flush()
         signals.event.registration_form_created.send(regform)
         flash(_('Registration form has been successfully created'), 'success')
         self.event.log(EventLogRealm.management, LogKind.positive, 'Registration',
                        f'Registration form "{regform.title}" has been created', session.user)
         return redirect(url_for('.manage_regform', regform))
     return WPManageRegistration.render_template('management/regform_create.html', self.event,
                                                 form=form, regform=None)
Ejemplo n.º 4
0
    def _process(self):
        regform = self.event.participation_regform
        registration_enabled = self.event.has_feature('registration')
        participant_visibility = (PublishRegistrationsMode.show_with_consent
                                  if self.event.type_ == EventType.lecture
                                  else PublishRegistrationsMode.show_all)
        public_visibility = (PublishRegistrationsMode.show_with_consent
                             if self.event.type_ == EventType.lecture
                             else PublishRegistrationsMode.show_all)
        form = RegistrationFormCreateForm(title='Participants',
                                          visibility=[participant_visibility.name, public_visibility.name, None])
        if form.validate_on_submit():
            set_feature_enabled(self.event, 'registration', True)
            if not regform:
                regform = RegistrationForm(event=self.event, is_participation=True,
                                           currency=payment_settings.get('currency'))
                create_personal_data_fields(regform)
                form.populate_obj(regform, skip=['visibility'])
                participant_visibility, public_visibility, visibility_duration = form.visibility.data
                regform.publish_registrations_participants = PublishRegistrationsMode[participant_visibility]
                regform.publish_registrations_public = PublishRegistrationsMode[public_visibility]
                regform.publish_registrations_duration = (timedelta(days=visibility_duration*30)
                                                          if visibility_duration is not None else None)
                db.session.add(regform)
                db.session.flush()
                signals.event.registration_form_created.send(regform)
                self.event.log(EventLogRealm.management, LogKind.positive, 'Registration',
                               f'Registration form "{regform.title}" has been created', session.user)
            return redirect(url_for('event_registration.manage_regform', regform))

        if not regform or not registration_enabled:
            return WPManageParticipants.render_template('management/participants.html', self.event, form=form,
                                                        regform=regform, registration_enabled=registration_enabled)
        return redirect(url_for('event_registration.manage_regform', regform))
Ejemplo n.º 5
0
def dummy_regform(dummy_event, db):
    # event has to be in the future (badge request)
    dummy_event.start_dt += timedelta(days=1)
    dummy_event.end_dt += timedelta(days=1)
    regform = RegistrationForm(event=dummy_event, title="Dummy Registration Form", currency="CHF")
    create_personal_data_fields(regform)
    db.session.flush()
    return regform
Ejemplo n.º 6
0
def dummy_regform(db, dummy_event):
    regform = RegistrationForm(event=dummy_event, title='Registration Form', currency='USD')
    create_personal_data_fields(regform)

    # enable all fields
    for field in regform.sections[0].fields:
        field.is_enabled = True
    db.session.add(regform)
    db.session.flush()
    return regform
Ejemplo n.º 7
0
def dummy_regform(db, dummy_event):
    regform = RegistrationForm(event=dummy_event, title='Registration Form', currency='USD')
    create_personal_data_fields(regform)

    # enable all fields
    for field in regform.sections[0].fields:
        field.is_enabled = True
    db.session.add(regform)
    db.session.flush()
    return regform
Ejemplo n.º 8
0
 def _process_POST(self):
     regform = self.event_new.participation_regform
     set_feature_enabled(self.event, 'registration', True)
     if not regform:
         regform = RegistrationForm(event_new=self.event_new, title="Participants", is_participation=True)
         create_personal_data_fields(regform)
         db.session.add(regform)
         db.session.flush()
         self.event.log(EventLogRealm.management, EventLogKind.positive, 'Registration',
                        'Registration form "{}" has been created'.format(regform.title), session.user)
     return redirect(url_for('event_registration.manage_regform', regform))
Ejemplo n.º 9
0
    def _create_form(self):
        create_personal_data_fields(self.regform)
        for item in self.regform.form_items:
            if not item.is_field:
                item.position = 1  # pd section
                continue
            # we have nothing but personal data fields right now. no need for extra checks!
            if item.personal_data_type != PersonalDataType.country:
                self.pd_field_map[item.personal_data_type] = item
            if item.personal_data_type == PersonalDataType.title:
                self.title_map = {
                    v: k
                    for k, v in item.data['captions'].iteritems()
                }

        # create administrative section for statuses
        if self.status_used:
            section = RegistrationFormSection(registration_form=self.regform,
                                              is_manager_only=True,
                                              title='Status',
                                              position=2)
            if self.status_used:
                choices = []
                for status in ('refused', 'excused', 'invited', 'accepted',
                               'rejected', 'declined'):
                    uuid = unicode(uuid4())
                    caption = status.title()
                    choices.append({
                        'price': 0,
                        'is_billable': False,
                        'places_limit': 0,
                        'is_enabled': True,
                        'caption': caption,
                        'id': uuid
                    })
                    self.status_map[status] = {
                        'uuid': uuid,
                        'caption': caption
                    }
                field_data = {
                    'item_type': 'dropdown',
                    'with_extra_slots': False,
                    'default_item': None,
                    'choices': choices
                }
                self.status_field = field = RegistrationFormField(
                    registration_form=self.regform,
                    parent=section,
                    input_type='single_choice',
                    title='Status')
                field.data, field.versioned_data = field.field_impl.process_field_data(
                    field_data)
Ejemplo n.º 10
0
 def _process_POST(self):
     regform = self.event_new.participation_regform
     set_feature_enabled(self.event_new, 'registration', True)
     if not regform:
         regform = RegistrationForm(event_new=self.event_new, title="Participants", is_participation=True,
                                    currency=payment_settings.get('currency'))
         create_personal_data_fields(regform)
         db.session.add(regform)
         db.session.flush()
         signals.event.registration_form_created.send(regform)
         self.event_new.log(EventLogRealm.management, EventLogKind.positive, 'Registration',
                            'Registration form "{}" has been created'.format(regform.title), session.user)
     return redirect(url_for('event_registration.manage_regform', regform))
Ejemplo n.º 11
0
 def _process(self):
     form = RegistrationFormForm(event=self.event,
                                 publish_registrations_enabled=(self.event.getType() != 'conference'))
     if form.validate_on_submit():
         regform = RegistrationForm(event_new=self.event_new)
         create_personal_data_fields(regform)
         form.populate_obj(regform)
         db.session.add(regform)
         db.session.flush()
         flash(_('Registration form has been successfully created'), 'success')
         self.event.log(EventLogRealm.management, EventLogKind.positive, 'Registration',
                        'Registration form "{}" has been created'.format(regform.title), session.user)
         return redirect(url_for('.manage_regform', regform))
     return WPManageRegistration.render_template('management/regform_edit.html', self.event, event=self.event,
                                                 form=form)
Ejemplo n.º 12
0
 def _process_POST(self):
     regform = self.event_new.participation_regform
     set_feature_enabled(self.event, "registration", True)
     if not regform:
         regform = RegistrationForm(
             event_new=self.event_new,
             title="Participants",
             is_participation=True,
             currency=payment_global_settings.get("currency"),
         )
         create_personal_data_fields(regform)
         db.session.add(regform)
         db.session.flush()
         signals.event.registration_form_created.send(regform)
         self.event.log(
             EventLogRealm.management,
             EventLogKind.positive,
             "Registration",
             'Registration form "{}" has been created'.format(regform.title),
             session.user,
         )
     return redirect(url_for("event_registration.manage_regform", regform))