@treeio_login_required
@handle_response_format
def type_edit(request, type_id, response_format='html'):
    "ContactType edit"

    contact_type = get_object_or_404(ContactType, pk=type_id)
    if not request.user.profile.has_permission(contact_type, mode='w'):
        return user_denied(request, message="You don't have access to this Contact Type",
                           response_format=response_format)
    identities = Object.filter_by_request(request,
                                          Contact.objects.filter(contact_type=contact_type).order_by('name'))

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

    context = _get_default_context(request)
    context.update({'identities': identities,
                    'form': form,
                    'type': contact_type})

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