mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-25 08:41:54 +00:00
new slug-based identifiers
This commit is contained in:
parent
9458aad028
commit
99566fe519
@ -8,6 +8,8 @@ from datetime import date
|
||||
# re-run it every time you edit the folk.csv file to add someone you have forgotten
|
||||
# it needs to be run on the server too as the file produced is ignored by git
|
||||
|
||||
# updated to use slugs to recognise people instead of FirstnameSurname
|
||||
|
||||
headcount = 0
|
||||
pics = 0
|
||||
allyears = 0
|
||||
@ -20,6 +22,19 @@ headcounts_byyear = [0]*(len(lines[0].split(","))-5)
|
||||
|
||||
yearnow = date.today().year
|
||||
|
||||
slug_cache = {}
|
||||
def troggle_slugify(longname):
|
||||
"""Uniqueness enforcement too. Yes we have had two "Dave Johnson"s
|
||||
This function copied instact from troggle/parsers/people/py
|
||||
"""
|
||||
slug = longname.strip().lower().replace(" ","-")
|
||||
if len(slug) > 40: # slugfield is 50 chars
|
||||
slug = slug[:40]
|
||||
if slug in slug_cache:
|
||||
slug_cache[slug] += 1
|
||||
slug = f"{slug}_{slug_cache[slug]}"
|
||||
slug_cache[slug] = 1
|
||||
return slug
|
||||
|
||||
for r in lines[1:]:
|
||||
n +=1
|
||||
@ -52,6 +67,10 @@ for r in lines[1:]:
|
||||
nameurl = nameurl.replace(';', '%3B')
|
||||
nameurl = re.sub('<[^>]*>','',nameurl)
|
||||
nameurl = re.sub('\([^\)]*\)','',nameurl) # mostly not needed, but is for Wookey
|
||||
|
||||
# new url using slug
|
||||
nameurl = re.sub('\([^\)]*\)','',name)
|
||||
nameurl = troggle_slugify(nameurl)
|
||||
namelink= "<a href='/person/" + nameurl + "'>" + namevis + "</a>"
|
||||
output += namelink
|
||||
#output += name.replace('""', '"')
|
||||
|
Loading…
Reference in New Issue
Block a user