Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9147 -- Added `FormPreview.process_preview` customization hook…

…. Thanks, bthomas and thalin.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12486 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a9b2ac25d1760e1b8e01632544b7f503ccab8577 1 parent 9810178
Justin Bronn authored February 22, 2010
8  django/contrib/formtools/preview.py
@@ -60,6 +60,7 @@ def preview_post(self, request):
60 60
         f = self.form(request.POST, auto_id=AUTO_ID)
61 61
         context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}
62 62
         if f.is_valid():
  63
+            self.process_preview(request, f, context) 
63 64
             context['hash_field'] = self.unused_name('hash')
64 65
             context['hash_value'] = self.security_hash(request, f)
65 66
             return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
@@ -96,6 +97,13 @@ def parse_params(self, *args, **kwargs):
96 97
         """
97 98
         pass
98 99
 
  100
+    def process_preview(self, request, form, context):
  101
+        """
  102
+ 	Given a validated form, performs any extra processing before displaying
  103
+ 	the preview page, and saves any extra data in context.
  104
+ 	"""
  105
+ 	pass
  106
+
99 107
     def security_hash(self, request, form):
100 108
         """
101 109
         Calculates the security hash for the given HttpRequest and Form instances.
13  docs/ref/contrib/formtools/form-preview.txt
@@ -108,3 +108,16 @@ These values can be overridden for a particular form preview by setting
108 108
 :attr:`~django.contrib.formtools.FormPreview.form_template` attributes on the
109 109
 FormPreview subclass. See :file:`django/contrib/formtools/templates` for the
110 110
 default templates.
  111
+
  112
+Advanced ``FormPreview`` methods
  113
+================================
  114
+
  115
+.. versionadded:: 1.2
  116
+
  117
+.. method:: FormPreview.process_preview
  118
+
  119
+    Given a validated form, performs any extra processing before displaying the
  120
+    preview page, and saves any extra data in context.
  121
+
  122
+    By default, this method is empty.  It is called after the form is validated,
  123
+    but before the context is modified with hash information and rendered.
4  docs/ref/contrib/formtools/form-wizard.txt
@@ -199,8 +199,8 @@ wizard takes a list of your :class:`~django.forms.Form` objects as arguments::
199 199
         (r'^contact/$', ContactWizard([ContactForm1, ContactForm2])),
200 200
     )
201 201
 
202  
-Advanced FormWizard methods
203  
-===========================
  202
+Advanced ``FormWizard`` methods
  203
+===============================
204 204
 
205 205
 .. class:: FormWizard
206 206
 

0 notes on commit a9b2ac2

Please sign in to comment.
Something went wrong with that request. Please try again.