Skip to content

pages

process_manager.views.pages

View functions for pages.

Classes

BootProcessView

Bases: PermissionRequiredMixin, FormView[BootProcessForm]

View for the BootProcess form.

Functions
form_valid(form)

Boot a Process when valid form data has been POSTed.

Parameters:

Name Type Description Default
form BootProcessForm

the form instance that has been validated.

required

Returns:

Type Description
HttpResponse

A redirect to the index page.

Source code in process_manager/views/pages.py
def form_valid(self, form: BootProcessForm) -> HttpResponse:
    """Boot a Process when valid form data has been POSTed.

    Args:
        form: the form instance that has been validated.

    Returns:
        A redirect to the index page.
    """
    boot_process("root", form.cleaned_data)
    return super().form_valid(form)

Functions

index(request)

View that renders the index/home page with process table.

Source code in process_manager/views/pages.py
@login_required
def index(request: HttpRequest) -> HttpResponse:
    """View that renders the index/home page with process table."""
    return render(request=request, template_name="process_manager/index.html")

logs(request, uuid)

Display the logs of a process.

Parameters:

Name Type Description Default
request HttpRequest

the triggering request.

required
uuid UUID

identifier for the process.

required

Returns:

Type Description
HttpResponse

The rendered page.

Source code in process_manager/views/pages.py
@login_required
@permission_required("main.can_view_process_logs", raise_exception=True)
def logs(request: HttpRequest, uuid: uuid.UUID) -> HttpResponse:
    """Display the logs of a process.

    Args:
      request: the triggering request.
      uuid: identifier for the process.

    Returns:
      The rendered page.
    """
    logs_response = get_process_logs(str(uuid))

    # Process the log text to exclude empty lines
    log_lines = [val.data.line for val in logs_response if val.data.line.strip()]

    context = {"log_lines": log_lines}
    return render(request, "process_manager/logs.html", context)