def migrate(self): if not hasattr(self.conf, '_registrationForm') or not hasattr( self.conf, '_modPay'): self.event_ns.misc_data['payment_currency'] = payment_settings.get( 'currency') self.event_ns.payment_messages.update({ 'register': '', 'success': '' }) self.print_info('Event has no legacy payment/registration data') return old_payment = self.conf._modPay default_conditions = payment_settings.get('conditions') conditions = (getattr(old_payment, 'paymentConditions', default_conditions) if (getattr(old_payment, 'paymentConditionsEnabled', False) and convert_to_unicode( getattr(old_payment, 'specificPaymentConditions', '')).strip() == '') else getattr(old_payment, 'specificPaymentConditions', '')) # Get rid of the most terrible part of the old default conditions conditions = convert_to_unicode(conditions).replace( 'CANCELLATION :', 'CANCELLATION:') payment_enabled = getattr(old_payment, 'activated', False) if payment_enabled: set_feature_enabled(self.event, 'payment', True) payment_event_settings.set(self.event, 'conditions', conditions) register_email = getattr(old_payment, 'receiptMsg', '') success_email = getattr(old_payment, 'successMsg', '') # The new messages are shown in an "additional info" section, so the old defaults can always go away if convert_to_unicode( register_email) == 'Please, see the summary of your order:': register_email = '' if convert_to_unicode( success_email ) == 'Congratulations, your payment was successful.': success_email = '' # save these messages for later, since the settings # are now part of the reg. form currency = getattr(self.conf._registrationForm, '_currency', '') if not re.match(r'^[A-Z]{3}$', currency): currency = '' self.event_ns.misc_data['payment_currency'] = currency self.event_ns.payment_messages['register'] = register_email self.event_ns.payment_messages['success'] = success_email self.print_success("Payment enabled={0}, currency={1}".format( payment_enabled, currency))
def migrate_regforms(self): try: self.old_participation = self.conf._participation except AttributeError: self.print_info('Event has no participation') return if not self.old_participation._participantList and not self.old_participation._pendingParticipantList: self.print_info('Participant lists are empty') return set_feature_enabled(self.event, 'registration', True) with db.session.no_autoflush: self.regform = RegistrationForm( event_id=self.event.id, title=PARTICIPATION_FORM_TITLE, is_participation=True, currency=payment_settings.get('currency')) if not self.quiet: self.print_success('%[cyan]{}'.format(self.regform.title)) self._migrate_settings() self._create_form() self._migrate_participants() db.session.add(self.regform) db.session.flush()
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)
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))
def migrate_event_settings(self): self.messages.append(cformat("%{magenta!} - Event Payment Settings:")) print cformat("%{white!}migrating event settings") count = 0 EventSetting.delete_all(payment_event_settings.module) for event in committing_iterator(self._iter_events()): old_payment = event._modPay default_conditions = payment_settings.get('conditions') default_register_email = payment_settings.get('register_email') default_success_email = payment_settings.get('success_email') register_email = getattr(old_payment, 'receiptMsg', default_register_email) success_email = getattr(old_payment, 'successMsg', default_success_email) conditions = (getattr(old_payment, 'paymentConditions', default_conditions) if (getattr(old_payment, 'paymentConditionsEnabled', False) and convert_to_unicode(getattr(old_payment, 'specificPaymentConditions', '')).strip() == '') else getattr(old_payment, 'specificPaymentConditions', '')) # The new messages are shown in an "additional info" section, so the old defaults can always go away if convert_to_unicode(register_email) == 'Please, see the summary of your order:': register_email = '' if convert_to_unicode(success_email) == 'Congratulations, your payment was successful.': success_email = '' # Get rid of the most terrible part of the old default conditions conditions = convert_to_unicode(conditions).replace('CANCELLATION :', 'CANCELLATION:') settings = { 'enabled': getattr(old_payment, 'activated', False), 'currency': event._registrationForm._currency, 'conditions': conditions, 'register_email': register_email, 'success_email': success_email, } payment_event_settings.set_multi(event, settings) count += 1 print cformat("%{cyan}<EventSettings(id={id:>6}, enabled={enabled}, " "currency={currency})>").format(id=event.id, **settings) msg = cformat("%{green!}migration of {0} event payment settings successful\n").format(count) self.messages.append(' ' + msg) print msg
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))
def _process_POST(self): regform = self.event.participation_regform set_feature_enabled(self.event, 'registration', True) if not regform: regform = RegistrationForm(event=self.event, 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.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))
def _process(self): form = RegistrationFormForm(event=self.event, currency=payment_settings.get('currency'), 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, 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_edit.html', self.event, form=form, regform=None)
def _migrate_participant(self, old_part): state = PARTICIPANT_STATUS_MAP.get(old_part._status, RegistrationState.complete) registration = Registration( first_name=convert_to_unicode(old_part._firstName), last_name=convert_to_unicode(old_part._familyName), email=self._fix_email(old_part._email), submitted_dt=self.event.created_dt, base_price=0, price_adjustment=0, checked_in=old_part._present, state=state, currency=payment_settings.get('currency')) self.print_info( '%[yellow]Registration%[reset] - %[cyan]{}%[reset] [{}]'.format( registration.full_name, state.title)) self._migrate_participant_user(old_part, registration) self._migrate_participant_data(old_part, registration) self._migrate_participant_status(old_part, registration) return registration
def _set_currencies(self): currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c)) for c in payment_settings.get('currencies')] self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())