summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-24 15:05:13 -0700
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-24 15:05:13 -0700
commit36b62bd58801231533462ec40f3d77d921609b6b (patch)
treeead0d4a949168f7b6d6895ec3b138b9a8b88eefd
parent6485e805e110c6d3d9b2ea5fa48bb1760f8da55e (diff)
parent01968ef987a38bcc9579c41e09d49a4e60059571 (diff)
downloadaskbot-36b62bd58801231533462ec40f3d77d921609b6b.tar.gz
askbot-36b62bd58801231533462ec40f3d77d921609b6b.tar.bz2
askbot-36b62bd58801231533462ec40f3d77d921609b6b.zip
Merge pull request #133 from bobbydavid/slug
tweak slugify code to avoid double-unidecode
-rw-r--r--askbot/utils/slug.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/askbot/utils/slug.py b/askbot/utils/slug.py
index f9e30cbf..1c95e1d4 100644
--- a/askbot/utils/slug.py
+++ b/askbot/utils/slug.py
@@ -50,10 +50,13 @@ def slugify(input_text, max_length=150):
return input_text
allow_unicode_slugs = getattr(settings, 'ALLOW_UNICODE_SLUGS', False)
- if allow_unicode_slugs:
+ if isinstance(input_text, unicode) and not allow_unicode_slugs:
+ input_text = unidecode(input_text)
+
+ if isinstance(input_text, unicode):
slug = unicode_slugify(input_text)
else:
- slug = defaultfilters.slugify(unidecode(input_text))
+ slug = defaultfilters.slugify(input_text)
while len(slug) > max_length:
# try to shorten word by word until len(slug) <= max_length
temp = slug[:slug.rfind('-')]