2021-03-08 08:49:10 -08:00
|
|
|
""" customize the info available in context for rendering templates """
|
2021-06-07 19:52:25 +02:00
|
|
|
from bookwyrm import models, settings
|
2020-12-11 12:31:02 -08:00
|
|
|
|
2021-03-08 08:49:10 -08:00
|
|
|
|
|
|
|
def site_settings(request): # pylint: disable=unused-argument
|
2021-04-26 09:15:42 -07:00
|
|
|
"""include the custom info about the site"""
|
2021-05-28 17:00:07 +02:00
|
|
|
request_protocol = "https://"
|
|
|
|
if not request.is_secure():
|
|
|
|
request_protocol = "http://"
|
2021-05-26 18:20:22 +02:00
|
|
|
|
2022-03-01 09:49:34 -08:00
|
|
|
site = models.SiteSettings.objects.get()
|
|
|
|
theme = "css/themes/bookwyrm-light.scss"
|
2022-03-01 11:39:08 -08:00
|
|
|
if (
|
|
|
|
hasattr(request, "user")
|
|
|
|
and request.user.is_authenticated
|
|
|
|
and request.user.theme
|
|
|
|
):
|
2022-03-01 09:49:34 -08:00
|
|
|
theme = request.user.theme.path
|
|
|
|
elif site.default_theme:
|
|
|
|
theme = site.default_theme.path
|
|
|
|
|
2021-05-19 13:56:00 -07:00
|
|
|
return {
|
2022-03-01 09:49:34 -08:00
|
|
|
"site": site,
|
|
|
|
"site_theme": theme,
|
2021-05-19 15:17:32 -07:00
|
|
|
"active_announcements": models.Announcement.active_announcements(),
|
2021-08-04 11:42:18 +02:00
|
|
|
"thumbnail_generation_enabled": settings.ENABLE_THUMBNAIL_GENERATION,
|
2021-06-19 17:09:53 +02:00
|
|
|
"media_full_url": settings.MEDIA_FULL_URL,
|
2021-05-28 17:00:07 +02:00
|
|
|
"preview_images_enabled": settings.ENABLE_PREVIEW_IMAGES,
|
2021-05-26 18:20:22 +02:00
|
|
|
"request_protocol": request_protocol,
|
2021-09-10 10:57:16 -07:00
|
|
|
"js_cache": settings.JS_CACHE,
|
2021-05-19 13:56:00 -07:00
|
|
|
}
|