Update web/core/context_processors.py
This commit is contained in:
parent
4e8dc63603
commit
6dc6b07f67
@ -1,5 +1,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .models_ann import Announcement, AnnouncementDismissal
|
from .models_ann import Announcement, AnnouncementDismissal
|
||||||
|
from django.contrib.staticfiles import finders
|
||||||
|
import os
|
||||||
|
|
||||||
def app_version(request):
|
def app_version(request):
|
||||||
version_file = Path(__file__).resolve().parent.parent / "version.txt"
|
version_file = Path(__file__).resolve().parent.parent / "version.txt"
|
||||||
@ -10,7 +12,19 @@ def app_version(request):
|
|||||||
version = "v0.0.0"
|
version = "v0.0.0"
|
||||||
return {"APP_VERSION": version}
|
return {"APP_VERSION": version}
|
||||||
|
|
||||||
|
def available_themes(request):
|
||||||
|
"""Returns ['midnight','dawn','forest','sandstone', ...] by scanning /static/themes/*.css"""
|
||||||
|
names = []
|
||||||
|
# Find the absolute path for the 'themes' directory via staticfiles finders
|
||||||
|
# We look for any 'themes' folder that exists and aggregate CSS files.
|
||||||
|
for finder in finders.get_finders():
|
||||||
|
for path, storage in finder.list(['themes']):
|
||||||
|
if path.startswith('themes/') and path.endswith('.css'):
|
||||||
|
base = os.path.basename(path)[:-4] # strip .css
|
||||||
|
names.append(base)
|
||||||
|
# stable order
|
||||||
|
names = sorted(set(names))
|
||||||
|
return {'available_themes': names}
|
||||||
|
|
||||||
def pending_announcement(request):
|
def pending_announcement(request):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user