From: Magnus Hagander Date: Wed, 17 Sep 2025 12:47:47 +0000 (+0200) Subject: Include slugified sponsor display name in token data X-Git-Url: http://git.postgresql.org/gitweb/delmail?a=commitdiff_plain;h=e2d5b68eb04a3349ae2068828c5bcdd266edafe7;p=pgeu-system.git Include slugified sponsor display name in token data Commit a7ca59dc added to the dashboard for human consumption but it makes sense to also have it in the json/yaml data downloads. This also makes it possible to simplify the fetch_sponsorfiles.py script since it no longer needs a copy of the django slugify function. --- diff --git a/postgresqleu/confsponsor/util.py b/postgresqleu/confsponsor/util.py index 9e87617d..4907816b 100644 --- a/postgresqleu/confsponsor/util.py +++ b/postgresqleu/confsponsor/util.py @@ -2,6 +2,7 @@ from django.db.models import Q from django.shortcuts import get_object_or_404 from django.conf import settings from django.utils import timezone +from django.template.defaultfilters import slugify from postgresqleu.util.db import exec_to_list from postgresqleu.util.currency import format_currency @@ -82,6 +83,7 @@ def sponsorclaimsdata(conference): 'sponsors': [ { 'name': s.displayname, + 'slugname': slugify(s.displayname), 'confirmedat': s.confirmedat, 'signedupat': s.signupat } for s in lvl.sponsor_set.filter(confirmed=True).order_by('signupat') @@ -90,6 +92,7 @@ def sponsorclaimsdata(conference): 'sponsors': { s.displayname: { 'name': s.displayname, + 'slugname': slugify(s.displayname), 'url': s.url, 'social': s.social, 'level': s.level.levelname, diff --git a/tools/deploystatic/fetch_sponsorfiles.py b/tools/deploystatic/fetch_sponsorfiles.py index 86a7e7fd..e43bd4ed 100755 --- a/tools/deploystatic/fetch_sponsorfiles.py +++ b/tools/deploystatic/fetch_sponsorfiles.py @@ -16,15 +16,6 @@ import unicodedata import urllib.request -# Slugify the names - needs to be compatible with django/jinja/deploystatic -def slugify(value): - if not value: - return '' - value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') - value = re.sub(r'[^\w\s-]', '', value).strip().lower() - return re.sub(r'[-\s]+', '-', value) - - if __name__ == "__main__": parser = argparse.ArgumentParser(description='Fetch pgeu-system sponsor files from token URLs') parser.add_argument('tokenurl', type=str, help='Base URL including the token value, but not including the type of dta') @@ -46,7 +37,7 @@ if __name__ == "__main__": for name, sponsorinfo in data['sponsors']['sponsors'].items(): for benefit in sponsorinfo['benefits']: if benefit['name'] == args.benefitname: - filename = os.path.join(args.directory, '{}.png'.format(slugify(name))) + filename = os.path.join(args.directory, '{}.png'.format(sponsorinfo['slugname'])) if os.path.isfile(filename): # Check if this file is unchanged with open(filename, 'rb') as f: