示例#1
0
    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 = global_settings.get('conditions')
            default_register_email = global_settings.get('register_email')
            default_success_email = global_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
示例#2
0
文件: forms.py 项目: NIIF/indico
 def _set_currencies(self):
     currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c)) for c in settings.get('currencies')]
     # In case the event's currency was deleted, we keep it here anyway.
     event_currency = self.currency.object_data
     if event_currency and not any(x[0] == event_currency for x in currencies):
         currencies.append((event_currency, event_currency))
     self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())
示例#3
0
 def _process(self):
     event = self._conf
     currencies = {c['code']: c['name'] for c in settings.get('currencies')}
     plugins = get_payment_plugins()
     enabled_plugins = [plugin for plugin in plugins.itervalues() if plugin.event_settings.get(event, 'enabled')]
     return WPPaymentEventManagement.render_template('event_settings.html', event, event=event,
                                                     settings=event_settings.get_all(event),
                                                     currencies=currencies, plugins=plugins.items(),
                                                     enabled_plugins=enabled_plugins)
示例#4
0
 def _set_currencies(self):
     currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c))
                   for c in settings.get('currencies')]
     # In case the event's currency was deleted, we keep it here anyway.
     event_currency = self.currency.object_data
     if event_currency and not any(x[0] == event_currency
                                   for x in currencies):
         currencies.append((event_currency, event_currency))
     self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())
示例#5
0
    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 = global_settings.get('conditions')
            default_register_email = global_settings.get('register_email')
            default_success_email = global_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
示例#6
0
 def _process(self):
     event = self._conf
     currencies = {c['code']: c['name'] for c in settings.get('currencies')}
     plugins = get_payment_plugins()
     enabled_plugins = [
         plugin for plugin in plugins.itervalues()
         if plugin.event_settings.get(event, 'enabled')
     ]
     return WPPaymentEventManagement.render_template(
         'event_settings.html',
         event,
         event=event,
         settings=event_settings.get_all(event),
         currencies=currencies,
         plugins=plugins.items(),
         enabled_plugins=enabled_plugins)
示例#7
0
 def _set_currencies(self):
     currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c))
                   for c in settings.get('currencies')]
     self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())
示例#8
0
文件: forms.py 项目: NIIF/indico
 def _set_currencies(self):
     currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c)) for c in settings.get('currencies')]
     self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())
示例#9
0
文件: forms.py 项目: hennogous/indico
 def _set_currencies(self):
     currencies = [(c["code"], "{0[code]} ({0[name]})".format(c)) for c in settings.get("currencies")]
     self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())