From 1b8bcd7000cfedf142e718aea56b865498ca5761 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 11 Oct 2011 18:25:21 +0530 Subject: [PATCH] bp guidelines link to new site --- itf/bestpractices/templatetags/guidelines.py | 15 +++++++++++++++ .../modules/bestpractices/guideline.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/itf/bestpractices/templatetags/guidelines.py b/itf/bestpractices/templatetags/guidelines.py index b7ffde3..ab86ce3 100755 --- a/itf/bestpractices/templatetags/guidelines.py +++ b/itf/bestpractices/templatetags/guidelines.py @@ -18,4 +18,19 @@ def link_bps(value): value = value.replace(match, '', 1) return value +def abs_link_bps(value): + r = r'BP\:[0-9][0-9]?' + matches = re.findall(r, value) + for match in matches: + id = int(match.replace("BP:", "").strip()) + try: + bp = BestPractice.objects.get(pk=id) + title = bp.title + html = "%s" % (bp.get_absolute_url(), title,) + value = value.replace(match, html, 1) + except: + value = value.replace(match, '', 1) + return value + +register.filter("abs_link_bps", abs_link_bps) register.filter("link_bps", link_bps) diff --git a/itf/templates/modules/bestpractices/guideline.html b/itf/templates/modules/bestpractices/guideline.html index 4dbcf0d..476769b 100755 --- a/itf/templates/modules/bestpractices/guideline.html +++ b/itf/templates/modules/bestpractices/guideline.html @@ -17,6 +17,6 @@
{% autoescape off %} - {{ text|linebreaksbr|link_bps }} + {{ text|linebreaksbr|abs_link_bps }} {% endautoescape %}