Code

Ticket #4362: preview.2.diff

File preview.2.diff, 1.3 KB (added by Indy, 7 years ago)

Done a minor correction

Line 
1Index: django/contrib/formtools/preview.py
2===================================================================
3--- django/contrib/formtools/preview.py (revision 5319)
4+++ django/contrib/formtools/preview.py (working copy)
5@@ -101,6 +101,8 @@
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.edit_field = self.unused_name('edit')
10+            context['edit_field'] = self.edit_field
11             context['hash_field'] = self.unused_name('hash')
12             context['hash_value'] = self.security_hash(request, f)
13             return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
14@@ -110,7 +112,7 @@
15     def post_post(self, request):
16         "Validates the POST data. If valid, calls done(). Else, redisplays form."
17         f = self.form(request.POST, auto_id=AUTO_ID)
18-        if f.is_valid():
19+        if hasattr(self, 'edit_field') and not request.has_key(self.edit_field) and f.is_valid():
20             if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
21                 return self.failed_hash(request) # Security hash failed.
22             return self.done(request, f.cleaned_data)