@handle_response_format
@treeio_login_required
def field_add(request, response_format='html'):
    "ContactField add"

    if not request.user.profile.is_admin('treeio.identities'):
        return user_denied(request,
                           message="You don't have administrator access to the Infrastructure module",
                           response_format=response_format)

    if request.POST:
        if 'cancel' not in request.POST:
            field = ContactField()
            form = ContactFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                field.set_user_from_request(request)
                return HttpResponseRedirect(reverse('identities_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(reverse('identities_settings_view'))
    else:
        form = ContactFieldForm()

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('identities/field_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/field_add/original