X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..ad5acb886787871a70eee6385cddbb4238d3adb2:/src/funding/utils.py diff --git a/src/funding/utils.py b/src/funding/utils.py index c16c9d93d..e93d8161d 100644 --- a/src/funding/utils.py +++ b/src/funding/utils.py @@ -4,23 +4,25 @@ # import re import string -from fnpdjango.utils.text.slughifi import char_map +from fnpdjango.utils.text import char_map # PayU chokes on non-Polish diacritics. # Punctuation is handled correctly and escaped as needed, # with the notable exception of backslash. sane_in_payu_title = re.escape( - string.uppercase + - string.lowercase + + string.ascii_uppercase + + string.ascii_lowercase + u'ąćęłńóśźżĄĆĘŁŃÓŚŹŻ' + string.digits + ' ' + "".join(set(string.punctuation) - set('\\')) ) + def replace_char(m): char = m.group() return char_map.get(char, '') + def sanitize_payment_title(value): - return re.sub('[^%s]{1}' % sane_in_payu_title, replace_char, unicode(value)) + return re.sub('[^%s]' % sane_in_payu_title, replace_char, str(value))