Skip to content

Commit

Permalink
Pass form to get_context_data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Kaskel committed Jun 9, 2011
1 parent fcb83ae commit 0a8244c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cbv_formpreview/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def unused_name(self, name):

def _get_context_data(self, form):
""" For backwards compatiblity. """
context = self.get_context_data()
context = self.get_context_data(form=form)
context.update(self.get_context(self.request, form))
return context

Expand Down
6 changes: 3 additions & 3 deletions cbv_formpreview/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_context(self, request, form):

def get_context_data(self, **kwargs):
context = super(TestFormPreview, self).get_context_data(**kwargs)
context['more_custom_context'] = True
context['is_bound_form'] = context['form'].is_bound
return context

def get_initial(self, request):
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_form_get(self):
stage = self.input % 1
self.assertContains(response, stage, 1)
self.assertEqual(response.context['custom_context'], True)
self.assertEqual(response.context['more_custom_context'], True)
self.assertEqual(response.context['is_bound_form'], False)
self.assertEqual(response.context['form'].initial, {'field1': 'Works!'})

def test_form_preview(self):
Expand All @@ -92,7 +92,7 @@ def test_form_preview(self):

# Check that the correct context was passed to the template
self.assertEqual(response.context['custom_context'], True)
self.assertEqual(response.context['more_custom_context'], True)
self.assertEqual(response.context['is_bound_form'], True)

def test_form_submit(self):
"""
Expand Down

0 comments on commit 0a8244c

Please sign in to comment.