Code

Ticket #9147: preview_9070.diff

File preview_9070.diff, 1.1 KB (added by bthomas, 6 years ago)

Add a process_preview method to FormPreview

Line 
1Index: contrib/formtools/preview.py
2===================================================================
3--- contrib/formtools/preview.py        (revision 9070)
4+++ contrib/formtools/preview.py        (working copy)
5@@ -60,6 +60,7 @@
6         f = self.form(request.POST, auto_id=AUTO_ID)
7         context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}
8         if f.is_valid():
9+            self.process_preview(request, f, context)
10             context['hash_field'] = self.unused_name('hash')
11             context['hash_value'] = self.security_hash(request, f)
12             return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
13@@ -96,6 +97,13 @@
14         """
15         pass
16 
17+    def process_preview(self, request, form, context):
18+        """
19+        Given a validated form, performs any extra processing before displaying
20+        the preview page, and saves any extra data in context.
21+        """
22+        pass
23+
24     def security_hash(self, request, form):
25         """
26         Calculates the security hash for the given HttpRequest and Form instances.