added config.py

This commit is contained in:
2025-02-23 21:43:50 +01:00
parent c090b611e2
commit 9156142c04
9 changed files with 137 additions and 13 deletions

3
TimeDispatcher/config.py Normal file
View File

@ -0,0 +1,3 @@
class Config:
# Number of hours in an off-day
WORKING_HOURS_PER_OFF_DAY = 8.2

View File

@ -0,0 +1,27 @@
from TimeDispatcher.config import Config
from TimeDispatcher.settings import APP_VERSION, DEBUG
def version(request):
return {
"debug": DEBUG,
"version": APP_VERSION
}
def navbar_links(request):
return {
"nav_links": [
{'view': 'dashboard', 'label': 'Dashboard'},
{'view': 'table', 'label': 'Table'},
{'view': 'projects', 'label': 'Projects'},
{'view': 'parents', 'label': 'Parents'},
{'view': 'import', 'label': 'Import'},
]
}
def app_config(request):
return {
"config": {
"WORKING_HOURS_PER_OFF_DAY": Config.WORKING_HOURS_PER_OFF_DAY
}
}

View File

@ -19,7 +19,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
APP_VERSION = "0.1.0"
load_dotenv(BASE_DIR / ".env")
load_dotenv(BASE_DIR / ".env", override=True)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
@ -68,8 +68,9 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'context_processors.version',
'context_processors.navbar_links'
'TimeDispatcher.context_processors.app_config',
'TimeDispatcher.context_processors.version',
'TimeDispatcher.context_processors.navbar_links'
],
},
},