changeset 1060:8a67a2008c13

Fix V3 bug that polluted template contexts.
author Brian Neal <bgneal@gmail.com>
date Mon, 21 Mar 2016 19:50:59 -0500
parents 9f4eb8f055ef
children f0febf8956eb
files contests/templatetags/contest_tags.py donations/templatetags/donations_tags.py irc/templatetags/irc_tags.py polls/templatetags/poll_tags.py potd/templatetags/potd_tags.py
diffstat 5 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/contests/templatetags/contest_tags.py	Thu Mar 17 21:16:03 2016 -0500
+++ b/contests/templatetags/contest_tags.py	Mon Mar 21 19:50:59 2016 -0500
@@ -13,9 +13,10 @@
 @register.simple_tag(takes_context=True)
 def latest_contests_block(context):
     contests = Contest.public_objects.get_current_contests()
-    context['contests'] = contests
-
     template_name = ('contests/v3/latest_contests_block_tag.html'
             if 'V3_DESIGN' in context else 'contests/latest_contests_block_tag.html')
     t = template.loader.get_template(template_name)
-    return t.render(context)
+
+    with context.push():
+        context['contests'] = contests
+        return t.render(context)
--- a/donations/templatetags/donations_tags.py	Thu Mar 17 21:16:03 2016 -0500
+++ b/donations/templatetags/donations_tags.py	Mon Mar 21 19:50:59 2016 -0500
@@ -12,12 +12,13 @@
 
 @register.simple_tag(takes_context=True)
 def monthly_goal(context):
-    context['pct'] = Donation.objects.monthly_goal_pct()
-
     template_name = ('donations/v3/monthly_goal_tag.html'
             if 'V3_DESIGN' in context else 'donations/monthly_goal_tag.html')
     t = template.loader.get_template(template_name)
-    return t.render(context)
+
+    with context.push():
+        context['pct'] = Donation.objects.monthly_goal_pct()
+        return t.render(context)
 
 
 @register.inclusion_tag('donations/top_donors_tag.html')
--- a/irc/templatetags/irc_tags.py	Thu Mar 17 21:16:03 2016 -0500
+++ b/irc/templatetags/irc_tags.py	Mon Mar 21 19:50:59 2016 -0500
@@ -10,6 +10,7 @@
 def irc_status(context):
     template_name = ('irc/v3/irc_block.html'
             if 'V3_DESIGN' in context else 'irc/irc_block.html')
-    context['nicks'] = get_users()
     t = template.loader.get_template(template_name)
-    return t.render(context)
+    with context.push():
+        context['nicks'] = get_users()
+        return t.render(context)
--- a/polls/templatetags/poll_tags.py	Thu Mar 17 21:16:03 2016 -0500
+++ b/polls/templatetags/poll_tags.py	Mon Mar 21 19:50:59 2016 -0500
@@ -21,8 +21,9 @@
 @register.simple_tag(takes_context=True)
 def latest_poll_block(context):
     polls = Poll.objects.get_current_polls()
-    context['polls'] = polls
     template_name = ('polls/v3/latest_poll_block_tag.html'
             if 'V3_DESIGN' in context else 'polls/latest_poll_block_tag.html')
     t = template.loader.get_template(template_name)
-    return t.render(context)
+    with context.push():
+        context['polls'] = polls
+        return t.render(context)
--- a/potd/templatetags/potd_tags.py	Thu Mar 17 21:16:03 2016 -0500
+++ b/potd/templatetags/potd_tags.py	Mon Mar 21 19:50:59 2016 -0500
@@ -9,9 +9,9 @@
 @register.simple_tag(takes_context=True)
 def photo_of_the_day(context):
     potd = Current.objects.get_current_photo()
-    context['potd'] = potd
     template_name = ('potd/v3/potd_block.html'
             if 'V3_DESIGN' in context else 'potd/potd_block.html')
-
     t = template.loader.get_template(template_name)
-    return t.render(context)
+    with context.push():
+        context['potd'] = potd
+        return t.render(context)