Skip to content

context_processors.py

maintainance_banner(request)

Generates the maintainance banner for the web server if a message has been set in the Django settings.

Parameters:

Name Type Description Default
request HttpRequest

The web server request.

required

Returns:

Type Description
Dict[str, Optional[str]]

Dictionary representing the JSON object with the maintainance message.

Source code in vast_pipeline/context_processors.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def maintainance_banner(request: HttpRequest) -> Dict[str, Optional[str]]:
    """
    Generates the maintainance banner for the web server if a message has been
    set in the Django settings.

    Args:
        request (HttpRequest): The web server request.

    Returns:
        Dictionary representing the JSON object with the maintainance message.
    """
    if settings.PIPELINE_MAINTAINANCE_MESSAGE:
        return {"maintainance_message": settings.PIPELINE_MAINTAINANCE_MESSAGE}

    return {"maintainance_message": None}

pipeline_version(request)

Adds the pipeline version to the template context.

Parameters:

Name Type Description Default
request HttpRequest

The web server request.

required

Returns:

Type Description
Dict[str, Optional[str]]

Dict[str, str]: key-value pairs to add to the template context.

Source code in vast_pipeline/context_processors.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def pipeline_version(request: HttpRequest) -> Dict[str, Optional[str]]:
    """Adds the pipeline version to the template context.

    Args:
        request (HttpRequest): The web server request.

    Returns:
        Dict[str, str]: key-value pairs to add to the template context.
    """
    url: Optional[str] = None
    if not __version__.endswith("dev"):
        url = f"https://github.com/askap-vast/vast-pipeline/releases/tag/v{__version__}"

    return {
        "pipeline_version": __version__,
        "pipeline_version_url": url,
    }

Last update: March 2, 2022
Created: March 2, 2022