Commit 6566a230 authored by Pierre Arnaud's avatar Pierre Arnaud

Change slugify method

parent d8eee59a
......@@ -25,8 +25,9 @@
import logging
import random
import re
import string
import unicodedata
import unidecode
log = logging.getLogger(__name__)
......@@ -41,5 +42,8 @@ def randstr(self, length=10):
)
def slugify(data):
return ''.join(x for x in unicodedata.normalize('NFKD', data) if x in string.ascii_letters or x in string.digits or x == "-" or x == "'" or x == " " or x == ".").lower().replace("'", "-").replace(" ", "-").replace('---', "-").replace("--", "-")
def slugify(s, separator='-'):
slug = unidecode.unidecode(s).lower()
slug = re.sub(r'[{} ]'.format(string.punctuation), separator, slug)
slug = re.sub(r'\{0}\{0}+'.format(separator), separator, slug).rstrip(separator)
return slug
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment