-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_processors.py
More file actions
42 lines (36 loc) · 1.26 KB
/
context_processors.py
File metadata and controls
42 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Context processors to be added to templates."""
# =============================================================================
# IMPORTS
# =============================================================================
# Python
from typing import Any
# Django
from django.conf import settings
from django.http import HttpRequest
# App
from project_manager.constants import (
DOWNLOAD_URL,
FORUM_URL,
GITHUB_URL,
WIKI_URL,
)
# =============================================================================
# ALL DECLARATION
# =============================================================================
__all__ = (
"add_common_context_processors",
)
# =============================================================================
# FUNCTIONS
# =============================================================================
def add_common_context_processors(request: HttpRequest) -> dict[str, Any]:
"""Expose some settings and other information to all contexts."""
return {
"DOWNLOAD_URL": DOWNLOAD_URL,
"FORUM_URL": FORUM_URL,
"GITHUB_URL": GITHUB_URL,
"MEDIA_URL": settings.MEDIA_URL,
"WIKI_URL": WIKI_URL,
"username": str(request.user),
"user_authenticated": request.user.is_authenticated,
}