Login

Re-editable FormPreview

Author:
hdknr
Posted:
April 9, 2010
Language:
Python
Version:
1.1
Tags:
form preview
Score:
0 (after 0 ratings)

When checking a form preview, a user happens to change content of the form and "Re edit" again.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class EditableFormPreview(FormPreview):
    reedit_action= [u'ReEdit',]

    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        reedit = False
        if request.POST.has_key('action') and request.POST['action'] in self.reedit_action:
            reedit = True

        if f.is_valid() and reedit == False:
            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
                context_instance=RequestContext(request))

More like this

  1. Hidden Forms by insin 7 years, 10 months ago
  2. Image Preview on ImageField in admin by fyaconiello 4 years, 1 month ago
  3. Django Admin inline preview by timbroder 5 years, 3 months ago
  4. Preview tag for fields with choices by kmmbvnr 7 years, 1 month ago
  5. ClearableFileInput with image preview by pafa 3 years, 7 months ago

Comments

Please login first before commenting.