- if (getattr(form_class, 'disabled', False) and
- not (force_enabled and request.user.is_superuser)):
- template = getattr(form_class, 'disabled_template', None)
- if template:
- return render(request, template, {'title': form_class.form_title})
- raise Http404
+ if not (force_enabled and request.user.is_superuser):
+ if form_class.is_disabled():
+ template = form_class.disabled_template
+ if template:
+ return render(request, template, {'title': form_class.form_title})
+ raise Http404
+ if contact_id:
+ contact = get_object_or_404(Contact, id=contact_id, form_tag=form_tag)
+ if not form_class.updatable:
+ raise Http404
+ if key != contact.key:
+ raise Http404
+ else:
+ contact = None
+ if request.method == 'POST':
+ form = form_class(request.POST, request.FILES, instance=contact)
+ else:
+ form = form_class(initial=request.GET, instance=contact)