示例#1
0
文件: event_acls.py 项目: fph/indico
    def migrate_event_acls(self):
        self.print_step('migrating event ACLs')
        protection_mode_map = {-1: ProtectionMode.public, 0: ProtectionMode.inheriting, 1: ProtectionMode.protected}
        for legacy_event, event in committing_iterator(self._iter_events(), 5000):
            ac = legacy_event._Conference__ac
            self.print_success('', event_id=event.id)

            old_protection_mode = protection_mode_map[ac._accessProtection]
            if old_protection_mode == ProtectionMode.public and ac.requiredDomains:
                event.protection_mode = ProtectionMode.protected
                self._migrate_domains(event, ac.requiredDomains)
            else:
                event.protection_mode = old_protection_mode

            no_access_contact = convert_to_unicode(getattr(ac, 'contactInfo', ''))
            if no_access_contact != 'no contact info defined':
                event.own_no_access_contact = no_access_contact
            event.access_key = convert_to_unicode(getattr(legacy_event, '_accessKey', ''))
            if not self.quiet:
                self.print_success('Protection mode set to {}'.format(event.protection_mode.name, event_id=event.id))
            for legacy_acl in ac.allowed:
                event_acl = self.convert_acl(legacy_acl)
                if event_acl is None:
                    self.print_warning(cformat('%{red}ACL%{reset}%{yellow} does not exist:%{reset} {}')
                                       .format(legacy_acl), event_id=event.id)
                    continue
                event.update_principal(event_acl, read_access=True, quiet=True)
                if not self.quiet:
                    self.print_msg(cformat('%{green}[{}]%{reset} {}').format('Event ACL', event_acl))
示例#2
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
示例#3
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
示例#4
0
 def _migrate_domains(self, event, old_domains):
     for old_domain in old_domains:
         network = self.domains_map[convert_to_unicode(
             old_domain.name).lower()]
         event.update_principal(network, read_access=True, quiet=True)
         if not self.quiet:
             self.print_success(
                 'Adding {} IPNetworkGroup to the ACLs'.format(network),
                 event_id=event.id)
示例#5
0
    def migrate_event_acls(self):
        self.print_step('migrating event ACLs')
        protection_mode_map = {
            -1: ProtectionMode.public,
            0: ProtectionMode.inheriting,
            1: ProtectionMode.protected
        }
        for legacy_event, event in committing_iterator(self._iter_events(),
                                                       5000):
            ac = legacy_event._Conference__ac
            self.print_success('', event_id=event.id)

            old_protection_mode = protection_mode_map[ac._accessProtection]
            if old_protection_mode == ProtectionMode.public and ac.requiredDomains:
                event.protection_mode = ProtectionMode.protected
                self._migrate_domains(event, ac.requiredDomains)
            else:
                event.protection_mode = old_protection_mode

            no_access_contact = convert_to_unicode(
                getattr(ac, 'contactInfo', ''))
            if no_access_contact != 'no contact info defined':
                event.own_no_access_contact = no_access_contact
            event.access_key = convert_to_unicode(
                getattr(legacy_event, '_accessKey', ''))
            if not self.quiet:
                self.print_success('Protection mode set to {}'.format(
                    event.protection_mode.name, event_id=event.id))
            for legacy_acl in ac.allowed:
                event_acl = self.convert_acl(legacy_acl)
                if event_acl is None:
                    self.print_warning(cformat(
                        '%{red}ACL%{reset}%{yellow} does not exist:%{reset} {}'
                    ).format(legacy_acl),
                                       event_id=event.id)
                    continue
                event.update_principal(event_acl, read_access=True, quiet=True)
                if not self.quiet:
                    self.print_msg(
                        cformat('%{green}[{}]%{reset} {}').format(
                            'Event ACL', event_acl))
示例#6
0
文件: event_acls.py 项目: fph/indico
 def _migrate_domains(self, event, old_domains):
     for old_domain in old_domains:
         network = self.domains_map[convert_to_unicode(old_domain.name).lower()]
         event.update_principal(network, read_access=True, quiet=True)
         if not self.quiet:
             self.print_success('Adding {} IPNetworkGroup to the ACLs'.format(network), event_id=event.id)