@treeio_login_required
@handle_response_format
def location_add(request, response_format='html'):
    "New location form"

    if request.POST:
        if 'cancel' not in request.POST:
            location = Location()
            form = LocationForm(
                request.user.profile, None, request.POST, instance=location)
            if form.is_valid():
                location = form.save()
                location.set_user_from_request(request)
                return HttpResponseRedirect(reverse('identities_location_view', args=[location.id]))
        else:
            return HttpResponseRedirect(reverse('identities_index'))
    else:
        form = LocationForm(request.user.profile, None)

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

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