| 63 | # Handle formsets |
| 64 | if issubclass(form.__class__,forms.formsets.BaseFormSet): |
| 65 | # checkhash for management form |
| 66 | if request.POST.get("hash_%d" % i, '') != self.security_hash(request, form.management_form): |
| 67 | return self.render_hash_failure(request, i) |
| 68 | for f in form.forms: |
| 69 | # check hash in every form |
| 70 | if request.POST.get("hash_%d_%s" % (i,f.prefix)) != self.security_hash(request,f): |
| 71 | return self.render_hash_failure(request,i) |
110 | | prev_fields.extend([bf.as_hidden() for bf in old_form]) |
111 | | prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form)))) |
| 117 | # handle formsets |
| 118 | if issubclass(old_form.__class__,forms.formsets.BaseFormSet): |
| 119 | # do management form and generate hash |
| 120 | prev_fields.extend([bf.as_hidden() for bf in old_form.management_form]) |
| 121 | prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form.management_form)))) |
| 122 | for f in old_form.forms: |
| 123 | # do each form and generate a hash for each |
| 124 | hash_name = 'hash_%s_%s' % (i,f.prefix) |
| 125 | prev_fields.extend([bf.as_hidden() for bf in f]) |
| 126 | prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, f)))) |
| 127 | else: |
| 128 | prev_fields.extend([bf.as_hidden() for bf in old_form]) |
| 129 | prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form)))) |
| 130 | |