Code

Ticket #17148: 17148.diff

File 17148.diff, 3.6 KB (added by Bradley Ayers <bradley.ayers@…>, 2 years ago)
Line 
1Index: docs/ref/contrib/formtools/form-wizard.txt
2===================================================================
3--- docs/ref/contrib/formtools/form-wizard.txt  (revision 17068)
4+++ docs/ref/contrib/formtools/form-wizard.txt  (working copy)
5@@ -304,7 +304,7 @@
6     Example to add extra variables for a specific step::
7 
8         def get_context_data(self, form, **kwargs):
9-            context = super(MyWizard, self).get_context_data(form, **kwargs)
10+            context = super(MyWizard, self).get_context_data(form=form, **kwargs)
11             if self.steps.current == 'my_step_name':
12                 context.update({'another_var': True})
13             return context
14@@ -431,7 +431,7 @@
15 
16         def render(self, form=None, **kwargs):
17             form = form or self.get_form()
18-            context = self.get_context_data(form, **kwargs)
19+            context = self.get_context_data(form=form, **kwargs)
20             return self.render_to_response(context)
21 
22 Providing initial data for the forms
23Index: django/contrib/formtools/wizard/views.py
24===================================================================
25--- django/contrib/formtools/wizard/views.py    (revision 17068)
26+++ django/contrib/formtools/wizard/views.py    (working copy)
27@@ -535,7 +535,7 @@
28         Returns a ``HttpResponse`` containing all needed context data.
29         """
30         form = form or self.get_form()
31-        context = self.get_context_data(form, **kwargs)
32+        context = self.get_context_data(form=form, **kwargs)
33         return self.render_to_response(context)
34 
35     def done(self, form_list, **kwargs):
36@@ -683,4 +683,3 @@
37     A NamedUrlFormWizard with pre-configured CookieStorageBackend.
38     """
39     storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
40-
41Index: django/contrib/formtools/tests/wizard/wizardtests/tests.py
42===================================================================
43--- django/contrib/formtools/tests/wizard/wizardtests/tests.py  (revision 17068)
44+++ django/contrib/formtools/tests/wizard/wizardtests/tests.py  (working copy)
45@@ -1,9 +1,12 @@
46 from __future__ import with_statement
47 import os
48 
49+from django import forms
50 from django.test import TestCase
51+from django.test.client import RequestFactory
52 from django.conf import settings
53 from django.contrib.auth.models import User
54+from django.contrib.formtools.wizard.views import CookieWizardView
55 
56 
57 class WizardTests(object):
58@@ -280,3 +283,21 @@
59                 TEMPLATE_DIRS=list(settings.TEMPLATE_DIRS) + [templates]):
60             response = self.client.get(self.wizard_url)
61             self.assertTemplateUsed(response, 'other_wizard_form.html')
62+
63+
64+class WizardTestGenericViewInterface(TestCase):
65+
66+    def test_get_context_data(self):
67+        class TestWizard(CookieWizardView):
68+            """
69+            A subclass that implements ``get_context_data`` using the standard
70+            protocol for generic views (accept only **kwargs).
71+
72+            See ticket #17148.
73+            """
74+            def get_context_data(self, **kwargs):
75+                return super(TestWizard, self).get_context_data(**kwargs)
76+
77+        factory = RequestFactory()
78+        view = TestWizard.as_view([forms.Form])
79+        view(factory.get('/'))
80Index: django/contrib/formtools/tests/wizard/__init__.py
81===================================================================
82--- django/contrib/formtools/tests/wizard/__init__.py   (revision 17068)
83+++ django/contrib/formtools/tests/wizard/__init__.py   (working copy)
84@@ -14,4 +14,5 @@
85     SessionWizardTests,
86     CookieWizardTests,
87     WizardTestKwargs,
88+    WizardTestGenericViewInterface,
89 )