Commit 4929dfae authored by Kaarle Ritvanen's avatar Kaarle Ritvanen
Browse files

main/py-django-oscar: fix render_promotion tag

parent cc29b853
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
From ed6b49d43870f316b099ef6076b5bd844aeb3708 Mon Sep 17 00:00:00 2001
From: Alexander Gaevsky <sasha@sasha0.ru>
Date: Mon, 13 Feb 2017 14:48:14 +0200
Subject: [PATCH 10/11] Syntax improvements, sort imports with isort.
---
src/oscar/apps/catalogue/reviews/admin.py | 1 +
src/oscar/apps/dashboard/catalogue/forms.py | 1 +
src/oscar/apps/dashboard/partners/forms.py | 1 +
src/oscar/templatetags/promotion_tags.py | 2 +-
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/oscar/apps/catalogue/reviews/admin.py b/src/oscar/apps/catalogue/reviews/admin.py
index 777a0ad..cfe987f 100644
--- a/src/oscar/apps/catalogue/reviews/admin.py
+++ b/src/oscar/apps/catalogue/reviews/admin.py
@@ -15,5 +15,6 @@ class ProductReviewAdmin(admin.ModelAdmin):
class VoteAdmin(admin.ModelAdmin):
list_display = ('review', 'user', 'delta', 'date_created')
+
admin.site.register(ProductReview, ProductReviewAdmin)
admin.site.register(Vote, VoteAdmin)
diff --git a/src/oscar/apps/dashboard/catalogue/forms.py b/src/oscar/apps/dashboard/catalogue/forms.py
index bc93f02..c6b28ce 100644
--- a/src/oscar/apps/dashboard/catalogue/forms.py
+++ b/src/oscar/apps/dashboard/catalogue/forms.py
@@ -472,6 +472,7 @@ class ProductAttributesForm(forms.ModelForm):
model = ProductAttribute
fields = ["name", "code", "type", "option_group", "required"]
+
ProductAttributesFormSet = inlineformset_factory(ProductClass,
ProductAttribute,
form=ProductAttributesForm,
diff --git a/src/oscar/apps/dashboard/partners/forms.py b/src/oscar/apps/dashboard/partners/forms.py
index c7f5583..d0ee31d 100644
--- a/src/oscar/apps/dashboard/partners/forms.py
+++ b/src/oscar/apps/dashboard/partners/forms.py
@@ -31,6 +31,7 @@ class PartnerCreateForm(forms.ModelForm):
model = Partner
fields = ('name',)
+
ROLE_CHOICES = (
('staff', _('Full dashboard access')),
('limited', _('Limited dashboard access')),
diff --git a/src/oscar/templatetags/promotion_tags.py b/src/oscar/templatetags/promotion_tags.py
index 95f9df6..471d508 100644
--- a/src/oscar/templatetags/promotion_tags.py
+++ b/src/oscar/templatetags/promotion_tags.py
@@ -1,4 +1,4 @@
-from django.template import Library, Node, RequestContext
+from django.template import Library, RequestContext
from django.template.loader import select_template
register = Library()
--
2.9.4
From 1709f673d74d1cd93c741111bd7f215c05a3f038 Mon Sep 17 00:00:00 2001
From: Samir Shah <samir@regulusweb.com>
Date: Sat, 18 Feb 2017 07:26:16 +0300
Subject: [PATCH 11/11] Fix deprecated use of RequestContext in
render_promotion tag.
---
src/oscar/templatetags/promotion_tags.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/oscar/templatetags/promotion_tags.py b/src/oscar/templatetags/promotion_tags.py
index 471d508..a067db2 100644
--- a/src/oscar/templatetags/promotion_tags.py
+++ b/src/oscar/templatetags/promotion_tags.py
@@ -1,4 +1,4 @@
-from django.template import Library, RequestContext
+from django.template import Library
from django.template.loader import select_template
register = Library()
@@ -8,12 +8,12 @@ register = Library()
def render_promotion(context, promotion):
template = select_template([
promotion.template_name(), 'promotions/default.html'])
+ request = context['request']
- args = {
- 'request': context['request'],
+ ctx = {
+ 'request': request,
'promotion': promotion
}
- args.update(**promotion.template_context(request=context['request']))
+ ctx.update(**promotion.template_context(request=request))
- ctx = RequestContext(context['request'], args)
- return template.render(ctx)
+ return template.render(ctx, request)
--
2.9.4
......@@ -2,7 +2,7 @@
# Maintainer: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
pkgname=py-django-oscar
pkgver=1.4
pkgrel=1
pkgrel=2
pkgdesc="Domain-driven e-commerce for Django"
url=http://oscarcommerce.com/
arch=noarch
......@@ -21,6 +21,9 @@ source="https://files.pythonhosted.org/packages/source/d/django-oscar/django-osc
0006-Fix-EmailBackend.authenticate-signature-for-Django-1.patch
0007-Fix-widgets.ImageInput-for-Django-1.11.patch
0008-Allow-latest-django-haystack-release-for-Django-1.11.patch
0009-Fix-the-render_promotion-template-tag.patch
0010-Syntax-improvements-sort-imports-with-isort.patch
0011-Fix-deprecated-use-of-RequestContext-in-render_promo.patch
"
_builddir=$srcdir/django-oscar-$pkgver
......@@ -52,4 +55,7 @@ bf8a5c004eff8a9494e693a3c7861d8ea68e887c4a3c03bd4083c28b8173cd8013d10cb8d09ffe24
92f32a9762faa49c4b3f474cc43ee72cc663c4324b1bd6798707f710ec184374a7a64da4aab9307da49b766386d7dcb641bb26a283323b102392a61da424c655 0005-Fix-RemoteSelect-widget-for-Django-1.10-1.11.patch
95773dda83edfe64b5da0c39935ea7c97483ba0b7088135f6e47c942d3bf3cab8bf1325ad26ea1a85f5c7b539115e6d13b668459ae55a8d5c376f0167cdee128 0006-Fix-EmailBackend.authenticate-signature-for-Django-1.patch
098defd75a2e6175ae6b0fe5ec0a5c6478581bc424a0cd7772f1f1afb80424cb0ec248d75d0ba3e401df5db1465dd6f9e6608f92f54f7b8631219165f04db133 0007-Fix-widgets.ImageInput-for-Django-1.11.patch
0e26d21f8f9e9cb0a60ed06f05d2445798ae90358893b3a061ff1cb7ce7a396c5efd47045a855752fd8505c3e64d9dd4b76464b65df0a26f897dba576e77398f 0008-Allow-latest-django-haystack-release-for-Django-1.11.patch"
0e26d21f8f9e9cb0a60ed06f05d2445798ae90358893b3a061ff1cb7ce7a396c5efd47045a855752fd8505c3e64d9dd4b76464b65df0a26f897dba576e77398f 0008-Allow-latest-django-haystack-release-for-Django-1.11.patch
58c562df7b4f96b58470098a6cafd36f741dbcbb2fc7510875ebec394af63da38ebbb3e70fd8a281548d31b74babd877211bbbd3df3bac9a4556b9907e0e9a65 0009-Fix-the-render_promotion-template-tag.patch
2c29ff5ef18bf5ed3d681ad155a4faf03c9e1e7248055d5d8bf5fb87c30d35bd28a14db0a0e5fc0e22dc418cbd54b5b54e492abc702bb6edaae2cf7b25c9e9e7 0010-Syntax-improvements-sort-imports-with-isort.patch
a9edb570f4039e2ec0b23b0b0d8dd07005434c3b303d3735897aeb7f458e57e25cd8fab14d4dff3d95c87798f7a57cfab5b2e99dc1a909fb3e58f7cac98a0df5 0011-Fix-deprecated-use-of-RequestContext-in-render_promo.patch"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment