@treeio_login_required
@handle_response_format
def location_edit(request, location_id, response_format='html'):
    "Location edit page"
    location = get_object_or_404(Location, pk=location_id)
    if not request.user.profile.has_permission(location, mode="w"):
        return user_denied(request, message="You don't have write access to this Location",
                           response_format=response_format)

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

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

    return render_to_response('identities/location_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/location_edit/swapped operands of `not in`