Skip to content

actions

process_manager.views.actions

View functions for performing actions on DUNE processes.

Classes

Functions

process_action(request)

Perform an action on the selected processes.

Both the action and the selected processes are retrieved from the request.

Parameters:

Name Type Description Default
request HttpRequest

Django HttpRequest object.

required

Returns:

Type Description
HttpResponse

HttpResponse redirecting to the index page.

Source code in process_manager/views/actions.py
@login_required
@permission_required("main.can_modify_processes", raise_exception=True)
def process_action(request: HttpRequest) -> HttpResponse:
    """Perform an action on the selected processes.

    Both the action and the selected processes are retrieved from the request.

    Args:
        request: Django HttpRequest object.

    Returns:
        HttpResponse redirecting to the index page.
    """
    try:
        action = request.POST.get("action", "")
        action_enum = ProcessAction(action.lower())
    except ValueError:
        # action.lower() is not a valid enum value
        return HttpResponseRedirect(reverse("process_manager:index"))

    if uuids_ := request.POST.getlist("select"):
        process_call(uuids_, action_enum)
    return HttpResponseRedirect(reverse("process_manager:index"))