mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-06-22 22:19:03 +01:00
Initial spin-off of bambu-run from my private project separation
This commit is contained in:
55
bambu_run/conf.py
Normal file
55
bambu_run/conf.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
App-level settings with sensible defaults.
|
||||
|
||||
Override in your Django settings.py:
|
||||
BAMBU_RUN_TIMEZONE = 'Australia/Melbourne'
|
||||
BAMBU_RUN_BASE_TEMPLATE = 'base/base.html'
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def get_setting(name, default):
|
||||
return getattr(settings, name, default)
|
||||
|
||||
|
||||
# Timezone for all timestamp display and queries
|
||||
BAMBU_RUN_TIMEZONE = property(lambda self: get_setting("BAMBU_RUN_TIMEZONE", "UTC"))
|
||||
|
||||
# Base template that all bambu_run templates extend
|
||||
BAMBU_RUN_BASE_TEMPLATE = property(
|
||||
lambda self: get_setting("BAMBU_RUN_BASE_TEMPLATE", "bambu_run/base.html")
|
||||
)
|
||||
|
||||
# Login URL for @login_required redirects
|
||||
BAMBU_RUN_LOGIN_URL = property(
|
||||
lambda self: get_setting("BAMBU_RUN_LOGIN_URL", "/accounts/login/")
|
||||
)
|
||||
|
||||
# Default brand for auto-created filaments from MQTT
|
||||
BAMBU_RUN_AUTO_CREATE_BRAND = property(
|
||||
lambda self: get_setting("BAMBU_RUN_AUTO_CREATE_BRAND", "Bambu Lab")
|
||||
)
|
||||
|
||||
|
||||
class _Settings:
|
||||
"""Lazy settings object that reads from Django settings with defaults."""
|
||||
|
||||
@property
|
||||
def TIMEZONE(self):
|
||||
return get_setting("BAMBU_RUN_TIMEZONE", "UTC")
|
||||
|
||||
@property
|
||||
def BASE_TEMPLATE(self):
|
||||
return get_setting("BAMBU_RUN_BASE_TEMPLATE", "bambu_run/base.html")
|
||||
|
||||
@property
|
||||
def LOGIN_URL(self):
|
||||
return get_setting("BAMBU_RUN_LOGIN_URL", "/accounts/login/")
|
||||
|
||||
@property
|
||||
def AUTO_CREATE_BRAND(self):
|
||||
return get_setting("BAMBU_RUN_AUTO_CREATE_BRAND", "Bambu Lab")
|
||||
|
||||
|
||||
app_settings = _Settings()
|
||||
Reference in New Issue
Block a user