From 45b65340e18cc6ff4406cf677a26f4f0b69a62c4 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 27 Nov 2018 20:45:47 +1300 Subject: [PATCH] Add twitter_handle tag --- .../templates/symposion/schedule/presentation_detail.html | 2 +- pinaxcon/templatetags/lca2019_tags.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pinaxcon/templates/symposion/schedule/presentation_detail.html b/pinaxcon/templates/symposion/schedule/presentation_detail.html index 4a990cfa..4cbf5517 100644 --- a/pinaxcon/templates/symposion/schedule/presentation_detail.html +++ b/pinaxcon/templates/symposion/schedule/presentation_detail.html @@ -33,7 +33,7 @@

{{ speaker }}
{% if speaker.twitter_username %} - {{ speaker.twitter_username }}
+ {{ speaker.twitter_username|twitter_handle }}
{% endif %} {% if speaker.homepage %} {{ speaker.homepage }} diff --git a/pinaxcon/templatetags/lca2019_tags.py b/pinaxcon/templatetags/lca2019_tags.py index 9bad403d..cbb55050 100644 --- a/pinaxcon/templatetags/lca2019_tags.py +++ b/pinaxcon/templatetags/lca2019_tags.py @@ -36,4 +36,9 @@ def listlookup(lookup, target): @register.filter def clean_text(txt): # Remove double/triple/+ spaces from `txt` and replace with single space - return re.sub(r' {2,}' , ' ', txt) \ No newline at end of file + return re.sub(r' {2,}' , ' ', txt) + +@register.filter +def twitter_handle(txt): + # Add @ to twitter handle if not present + return txt if txt.startswith('@') else '@{}'.format(txt) \ No newline at end of file