diff options
Diffstat (limited to 'main/py-django-oscar/0009-Fix-the-render_promotion-template-tag.patch')
-rw-r--r-- | main/py-django-oscar/0009-Fix-the-render_promotion-template-tag.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/main/py-django-oscar/0009-Fix-the-render_promotion-template-tag.patch b/main/py-django-oscar/0009-Fix-the-render_promotion-template-tag.patch new file mode 100644 index 0000000000..6ff74a8c4f --- /dev/null +++ b/main/py-django-oscar/0009-Fix-the-render_promotion-template-tag.patch @@ -0,0 +1,55 @@ +From e76a83621f6b099a33949304792adb4b6fe35a9d Mon Sep 17 00:00:00 2001 +From: Michael van Tellingen <michael@mvantellingen.nl> +Date: Tue, 7 Feb 2017 23:04:25 +0100 +Subject: [PATCH 09/11] Fix the render_promotion template-tag + +--- + src/oscar/templatetags/promotion_tags.py | 31 ++++++++++++------------------- + 1 file changed, 12 insertions(+), 19 deletions(-) + +diff --git a/src/oscar/templatetags/promotion_tags.py b/src/oscar/templatetags/promotion_tags.py +index a4d7f77..95f9df6 100644 +--- a/src/oscar/templatetags/promotion_tags.py ++++ b/src/oscar/templatetags/promotion_tags.py +@@ -1,26 +1,19 @@ +-from django.template import Library, Node, RequestContext, Variable ++from django.template import Library, Node, RequestContext + from django.template.loader import select_template + + register = Library() + + +-class PromotionNode(Node): +- def __init__(self, promotion): +- self.promotion_var = Variable(promotion) ++@register.simple_tag(takes_context=True) ++def render_promotion(context, promotion): ++ template = select_template([ ++ promotion.template_name(), 'promotions/default.html']) + +- def render(self, context): +- promotion = self.promotion_var.resolve(context) +- template = select_template([promotion.template_name(), +- 'promotions/default.html']) +- args = {'promotion': promotion} +- args.update(**promotion.template_context(request=context['request'])) +- ctx = RequestContext(context['request'], args) +- return template.render(ctx) ++ args = { ++ 'request': context['request'], ++ 'promotion': promotion ++ } ++ args.update(**promotion.template_context(request=context['request'])) + +- +-def get_promotion_html(parser, token): +- _, promotion = token.split_contents() +- return PromotionNode(promotion) +- +- +-register.tag('render_promotion', get_promotion_html) ++ ctx = RequestContext(context['request'], args) ++ return template.render(ctx) +-- +2.9.4 + |