예제 #1
0
    def _match(self, value, cs=1, exact=1, accent_sensitive=True):
        # if match is exact, retrieve directly from index
        if exact == 1 and cs == 1 and accent_sensitive:
            if value in self._words and len(self._words[value]) != 0:
                if '' in self._words[value]:
                    self._words[value].remove('')
                return self._words[value]
            else:
                return None
        else:
            result = []
            cmpValue = value
            if not accent_sensitive:
                cmpValue = remove_accents(cmpValue)
            if cs == 0:
                cmpValue = cmpValue.lower()

            for key in self._words.iterkeys():
                if len(self._words[key]) != 0:
                    cmpKey = key
                    if not accent_sensitive:
                        cmpKey = remove_accents(cmpKey)
                    if cs == 0:
                        cmpKey = cmpKey.lower()
                    if (exact == 0 and cmpKey.find(cmpValue) != -1) or (exact == 1 and cmpKey == cmpValue):
                        if '' in self._words[key]:
                            self._words[key].remove('')
                        result = result + self._words[key]
            return result
예제 #2
0
def build_access_request_data(registration, event, generate_code):
    """Return a dictionary with data required by ADaMS API."""
    from indico_cern_access.plugin import CERNAccessPlugin
    start_dt, end_dt = get_access_dates(get_last_request(event))
    tz = timezone('Europe/Zurich')
    title = do_truncate(None,
                        unicode_to_ascii(remove_accents(event.title)),
                        100,
                        leeway=0)
    if generate_code:
        reservation_code = get_random_reservation_code()
    else:
        reservation_code = registration.cern_access_request.reservation_code
    data = {
        '$id': generate_access_id(registration.id),
        '$rc': reservation_code,
        '$gn': title,
        '$fn': unicode_to_ascii(remove_accents(registration.first_name)),
        '$ln': unicode_to_ascii(remove_accents(registration.last_name)),
        '$sd': start_dt.astimezone(tz).strftime('%Y-%m-%dT%H:%M'),
        '$ed': end_dt.astimezone(tz).strftime('%Y-%m-%dT%H:%M')
    }

    if registration.cern_access_request and registration.cern_access_request.license_plate:
        data['$lp'] = registration.cern_access_request.license_plate

    checksum = ';;'.join('{}:{}'.format(key, value)
                         for key, value in sorted(data.viewitems()))
    signature = hmac.new(str(CERNAccessPlugin.settings.get('secret_key')),
                         checksum, hashlib.sha256)
    data['$si'] = signature.hexdigest()
    return data
예제 #3
0
    def _match(self, value, cs=1, exact=1, accent_sensitive=True):
        # if match is exact, retrieve directly from index
        if exact == 1 and cs == 1 and accent_sensitive:
            if value in self._words and len(self._words[value]) != 0:
                if '' in self._words[value]:
                    self._words[value].remove('')
                return self._words[value]
            else:
                return None
        else:
            result = []
            cmpValue = value
            if not accent_sensitive:
                cmpValue = remove_accents(cmpValue)
            if cs == 0:
                cmpValue = cmpValue.lower()

            for key in self._words.iterkeys():
                if len(self._words[key]) != 0:
                    cmpKey = key
                    if not accent_sensitive:
                        cmpKey = remove_accents(cmpKey)
                    if cs == 0:
                        cmpKey = cmpKey.lower()
                    if (exact == 0 and cmpKey.find(cmpValue) != -1) or (
                            exact == 1 and cmpKey == cmpValue):
                        if '' in self._words[key]:
                            self._words[key].remove('')
                        result = result + self._words[key]
            return result
예제 #4
0
 def adjust_payment_form_data(self, data):
     event = data['event']
     registration = data['registration']
     data['item_name'] = '{}: registration for {}'.format(remove_accents(registration.full_name),
                                                          remove_accents(event.getTitle()))
     data['return_url'] = url_for_plugin('payment_paypal.success', registration.locator.uuid, _external=True)
     data['cancel_url'] = url_for_plugin('payment_paypal.cancel', registration.locator.uuid, _external=True)
     data['notify_url'] = url_for_plugin('payment_paypal.notify', registration.locator.uuid, _external=True)
예제 #5
0
 def adjust_payment_form_data(self, data):
     event = data['event']
     registration = data['registration']
     data['item_name'] = '{}: registration for {}'.format(
         unicode_to_ascii(remove_accents(registration.full_name, reencode=False)),
         unicode_to_ascii(remove_accents(event.title, reencode=False))
     )
     data['return_url'] = url_for_plugin('payment_touchnet.success', registration.locator.uuid, _external=True)
     data['cancel_url'] = url_for_plugin('payment_touchnet.cancel', registration.locator.uuid, _external=True)
     data['notify_url'] = url_for_plugin('payment_touchnet.notify', registration.locator.uuid, _external=True)
예제 #6
0
    def matchFirstLetter(self, letter, accent_sensitive=True):
        result = []

        cmpLetter = letter.lower()
        if not accent_sensitive:
            cmpLetter = remove_accents(cmpLetter)

        for key in self.getKeys():
            uletter = key.decode('utf8')[0].lower()
            if not accent_sensitive:
                uletter = remove_accents(uletter)
            if uletter == cmpLetter:
                result += self._words[key]

        return result
예제 #7
0
 def adjust_payment_form_data(self, data):
     event = data['event']
     registration = data['registration']
     data['item_name'] = '{}: registration for {}'.format(
         remove_accents(registration.full_name),
         remove_accents(event.title))
     data['return_url'] = url_for_plugin('payment_paypal.success',
                                         registration.locator.uuid,
                                         _external=True)
     data['cancel_url'] = url_for_plugin('payment_paypal.cancel',
                                         registration.locator.uuid,
                                         _external=True)
     data['notify_url'] = url_for_plugin('payment_paypal.notify',
                                         registration.locator.uuid,
                                         _external=True)
예제 #8
0
    def matchFirstLetter(self, letter, accent_sensitive=True):
        result = []

        cmpLetter = letter.lower()
        if not accent_sensitive:
            cmpLetter = remove_accents(cmpLetter)

        for key in self.getKeys():
            uletter = key.decode('utf8')[0].lower()
            if not accent_sensitive:
                uletter = remove_accents(uletter)
            if uletter == cmpLetter:
                result += self._words[key]

        return result
예제 #9
0
파일: plugins.py 프로젝트: pmart123/indico
 def get_vc_room_form_defaults(self, event):
     return {
         'name': re.sub(r'[^\w_-]', '_', remove_accents(event.title, reencode=False)),
         'show': True,
         'linking': 'event',
         'contribution': '',
         'block': ''
     }
예제 #10
0
파일: util.py 프로젝트: tobiashuste/indico
def _build_name_search(name_list):
    text = remove_accents('%{}%'.format('%'.join(
        escape_like(name) for name in name_list)))
    return db.or_(
        db.func.indico.indico_unaccent(
            db.func.concat(User.first_name, ' ', User.last_name)).ilike(text),
        db.func.indico.indico_unaccent(
            db.func.concat(User.last_name, ' ', User.first_name)).ilike(text))
예제 #11
0
파일: plugins.py 프로젝트: k3njiy/indico
 def get_vc_room_form_defaults(self, event):
     return {
         "name": re.sub(r"[^\w_-]", "_", remove_accents(event.getTitle(), reencode=False)),
         "show": True,
         "linking": "event",
         "contribution": "",
         "block": "",
     }
예제 #12
0
 def getBrowseIndex( self ):
     letters = []
     words = self.getKeys()
     for word in words:
         uletter = remove_accents(word.decode('utf-8').lower()[0])
         if not uletter in letters:
             letters.append(uletter)
     letters.sort()
     return letters
예제 #13
0
 def getBrowseIndex(self):
     letters = []
     words = self.getKeys()
     for word in words:
         uletter = remove_accents(word.decode('utf-8').lower()[0])
         if not uletter in letters:
             letters.append(uletter)
     letters.sort()
     return letters
예제 #14
0
def get_order_id(registration, prefix):
    """Generates the order ID specific to a registration.

    Note: The format of the payment id in the end MUST NOT change
    as the finance department uses it to associate payments with
    events.  This is done manually using the event id, but any
    change to the format of the order ID should be checked with them
    beforehand.
    """
    payment_id = 'c{}r{}'.format(registration.event_id, registration.id)
    order_id_extra_len = 30 - len(payment_id)
    order_id = prefix + remove_non_alpha(remove_accents(registration.last_name + registration.first_name))
    return order_id[:order_id_extra_len].upper().strip() + payment_id
예제 #15
0
    def _generate_form_data(self, amount, data):
        if amount is None:
            return {}
        registration = data['registration']
        personal_data = registration.get_personal_data()
        event = data['event']
        currency = data['currency']
        seed = data['settings']['hash_seed_{}'.format(currency.lower())]
        shop_id = data['settings']['shop_id_{}'.format(currency.lower())]
        method = get_payment_method(event, currency, data['selected_method'])
        if method is None:
            raise UserValueError(_('Invalid currency'))
        template_page = ''  # yes, apparently it's supposed to be empty..
        template_hash = sha512((seed + template_page).encode('utf-8')).hexdigest()
        order_id = self._get_order_id(data)
        locator = registration.locator.uuid

        address = re.sub(r'(\r?\n)+', ', ', personal_data.get('address', ''))
        form_data = {
            'PSPID': shop_id,
            'ORDERID': order_id,
            'AMOUNT': int(amount * 100),
            'CURRENCY': currency,
            'LANGUAGE': session.lang,
            'CN': unicode_to_ascii(remove_accents(registration.full_name[:35], False)),
            'EMAIL': registration.email[:50],
            'OWNERADDRESS': address[:35],
            'OWNERTELNO': personal_data.get('phone', '')[:30],
            'TP': template_page + '&hash=' + template_hash,
            'PM': method['type'],
            'BRAND': method['name'],
            'PARAMVAR': data['settings']['server_url_suffix'],
            'HOMEURL': url_for('event_registration.display_regform', locator, _external=True),
            'ACCEPTURL': url_for_plugin('payment_cern.success', locator, _external=True),
            'CANCELURL': url_for_plugin('payment_cern.cancel', locator, _external=True),
            'DECLINEURL': url_for_plugin('payment_cern.decline', locator, _external=True),
            'EXCEPTIONURL': url_for_plugin('payment_cern.uncertain', locator, _external=True),
            'BACKURL': url_for('payment.event_payment', locator, _external=True)
        }

        form_data['SHASIGN'] = create_hash(seed, form_data)
        return form_data
예제 #16
0
파일: util.py 프로젝트: jas01/indico
def _build_name_search(name_list):
    text = remove_accents('%{}%'.format('%'.join(escape_like(name) for name in name_list)))
    return db.or_(db.func.indico.indico_unaccent(db.func.concat(User.first_name, ' ', User.last_name)).ilike(text),
                  db.func.indico.indico_unaccent(db.func.concat(User.last_name, ' ', User.first_name)).ilike(text))