@handle_response_format
@treeio_login_required
def contact_edit(request, contact_id, response_format='html'):
    "Contact edit"

    contact = get_object_or_404(Contact, pk=contact_id)
    if not request.user.profile.has_permission(contact, mode='w'):
        return user_denied(request, message="You don't have write access to this Contact")

    if request.POST:
        if 'cancel' not in request.POST:
            form = ContactForm(request.user.profile, contact.contact_type, request.POST,
                               files=request.FILES, instance=contact)
            if form.is_valid():
                contact = form.save(request)
                return HttpResponseRedirect(reverse('identities_contact_view', args=[contact.id]))
        else:
            return HttpResponseRedirect(reverse('identities_contact_view', args=[contact.id]))
    else:
        form = ContactForm(
            request.user.profile, contact.contact_type, instance=contact)

    types = Object.filter_by_request(
        request, ContactType.objects.order_by('name'))

    return render_to_response('identities/contact_edit',
                              {'contact': contact,
                               'types': types,
                               'form': form},
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/contact_edit/original