Ejemplo n.º 1
0
def get_request(edit=False):
    request = RequestFactory().get("/")
    request.session = {}
    if edit:
        request.user = SuperUser()
        set_edit_mode(request, True)
        assert is_edit_mode(request)
    else:
        request.user = AnonymousUser()
    return request
Ejemplo n.º 2
0
def test_edit_priv(rf):
    request = rf.get("/")
    request.user = SuperUser()
    request.session = {}
    assert could_edit(request)
    assert not is_edit_mode(request)
    set_edit_mode(request, True)
    assert is_edit_mode(request)
    set_edit_mode(request, False)
    assert not is_edit_mode(request)
Ejemplo n.º 3
0
def handle_command(request, command):
    """
    Internal dispatch function.

    :param request: A request
    :type request: django.http.HttpRequest
    :param command: Command string
    :type command: str
    :return: A response
    :rtype: django.http.HttpResponse
    """
    path = request.POST.get("path") or request.META.get("HTTP_REFERER") or "/"
    if command == "edit_on" or command == "edit_off":
        set_edit_mode(request, command.endswith("_on"))
        return HttpResponseRedirect(path)