Ticket #4362: preview.diff

File preview.diff, 1.2 KB (added by Indy, 17 years ago)
  • django/contrib/formtools/preview.py

     
    101101        f = self.form(request.POST, auto_id=AUTO_ID)
    102102        context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}
    103103        if f.is_valid():
     104            self.edit_field = self.unused_name('edit')
     105            context['edit_field'] = self.edit_field
    104106            context['hash_field'] = self.unused_name('hash')
    105107            context['hash_value'] = self.security_hash(request, f)
    106108            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
     
    110112    def post_post(self, request):
    111113        "Validates the POST data. If valid, calls done(). Else, redisplays form."
    112114        f = self.form(request.POST, auto_id=AUTO_ID)
    113         if f.is_valid():
     115        if not request.has_key(self.edit_field) and f.is_valid():
    114116            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
    115117                return self.failed_hash(request) # Security hash failed.
    116118            return self.done(request, f.cleaned_data)
Back to Top