瀏覽代碼

Updated template tag contect to allow CSRF to be used

master
David Winterbottom 14 年之前
父節點
當前提交
04daeeafea
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 5
    1
      oscar/apps/promotions/templatetags/promotions.py
  2. 1
    0
      oscar/core/validators.py

+ 5
- 1
oscar/apps/promotions/templatetags/promotions.py 查看文件

1
 from django.template import Library, Node, Variable, Context
1
 from django.template import Library, Node, Variable, Context
2
 from django.template.loader import select_template
2
 from django.template.loader import select_template
3
+from django.template import RequestContext
4
+
3
      
5
      
4
 register = Library()
6
 register = Library()
5
      
7
      
11
     def render(self, context):
13
     def render(self, context):
12
         promotion = self.promotion_var.resolve(context)
14
         promotion = self.promotion_var.resolve(context)
13
         template = select_template([promotion.template_name(), 'promotions/default.html'])
15
         template = select_template([promotion.template_name(), 'promotions/default.html'])
14
-        args = dict(promotion=promotion, **promotion.template_context(request=context['request']))
16
+        args = dict(promotion=promotion, 
17
+                    **promotion.template_context(request=context['request'])
18
+                    context_instance=RequestContext(context['request']))
15
         return template.render(Context(args))
19
         return template.render(Context(args))
16
  
20
  
17
 def get_promotion_html(parser, token):
21
 def get_promotion_html(parser, token):

+ 1
- 0
oscar/core/validators.py 查看文件

4
 from django.http import Http404
4
 from django.http import Http404
5
 from django.utils.translation import ugettext_lazy as _
5
 from django.utils.translation import ugettext_lazy as _
6
 
6
 
7
+
7
 class ExtendedURLValidator(validators.URLValidator):
8
 class ExtendedURLValidator(validators.URLValidator):
8
     def __call__(self, value):
9
     def __call__(self, value):
9
         try:
10
         try:

Loading…
取消
儲存