Fix Carbasa header overrides cleanly
This commit is contained in:
@@ -9,6 +9,7 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
|
||||
"""
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -20,7 +21,11 @@ BASE_DIR = str(BASE_PATH)
|
||||
|
||||
setup_search_paths("/etc/ocyan/", str(_project_app_path))
|
||||
|
||||
from ocyan.main.settings import * # pylint:disable=W0401,W0614
|
||||
from ocyan.main.settings import * # noqa: F403,F405 # pylint:disable=W0401,W0614 # pyright: ignore[reportWildcardImportFromLibrary]
|
||||
from ocyan.core.fender import config as ocyan_config
|
||||
|
||||
# Keep existing database schemas stable across Django upgrades.
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"mandelblog_content_guard.apps.MandelblogContentGuardConfig",
|
||||
@@ -60,6 +65,25 @@ _ensure_required_app(
|
||||
"ocyan.plugin.coyote",
|
||||
)
|
||||
|
||||
def _ensure_installed_app(app_label: str, *, before: str | None = None) -> None:
|
||||
"""Ensure an app is present in INSTALLED_APPS with optional ordering."""
|
||||
if app_label in INSTALLED_APPS:
|
||||
INSTALLED_APPS.remove(app_label)
|
||||
if before and before in INSTALLED_APPS:
|
||||
INSTALLED_APPS.insert(INSTALLED_APPS.index(before), app_label)
|
||||
else:
|
||||
INSTALLED_APPS.append(app_label)
|
||||
|
||||
|
||||
# Production-clean: prefer the Carbasa webshop template package when Oscar is enabled.
|
||||
# This guarantees that `carbasa/headers/*` resolves to the webshop templates (search, user bar, cart, megamenu).
|
||||
_oscar_enabled = ocyan_config.is_webshop or any(
|
||||
app == "ocyan.plugin.oscar" or app.startswith("ocyan.plugin.oscar_")
|
||||
for app in INSTALLED_APPS
|
||||
)
|
||||
if _oscar_enabled and importlib.util.find_spec("ocyan.plugin.carbasa.webshop"):
|
||||
_ensure_installed_app("ocyan.plugin.carbasa.webshop", before="ocyan.plugin.carbasa")
|
||||
|
||||
# Keep Carbasa/Coyote defaults stable even when plugin settings are not
|
||||
# injected early enough during startup on this deployment.
|
||||
OXYAN_HEADER_OPTIONS = globals().get(
|
||||
@@ -121,6 +145,13 @@ ACTIVE_VERTICAL = "agency"
|
||||
# Wagtail content internationalization in admin
|
||||
WAGTAIL_I18N_ENABLED = True
|
||||
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES
|
||||
WAGTAILADMIN_BASE_URL = os.environ.get("WAGTAILADMIN_BASE_URL", "http://127.0.0.1:8001")
|
||||
|
||||
# Local dev convenience: allow Django's test client and common loopback hosts.
|
||||
ALLOWED_HOSTS = list(globals().get("ALLOWED_HOSTS", []))
|
||||
for _host in ("localhost", "127.0.0.1", "0.0.0.0", "testserver"):
|
||||
if _host not in ALLOWED_HOSTS:
|
||||
ALLOWED_HOSTS.append(_host)
|
||||
|
||||
CONTENT_GUARD_STRICT = True
|
||||
CONTENT_GUARD_BLOCK_MEDIUM = False
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
{% load i18n oxyan category_tags ocyan_main ocyanjson %}
|
||||
|
||||
{# Project override: add the language chooser to the Carbasa (non-webshop) header. #}
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg navbar-light header-inner">
|
||||
<div class="container">
|
||||
{% include 'partials/brand.html' with big=True %}
|
||||
|
||||
{% block nav %}
|
||||
{% ocyanjson "theme" "menu_depth" 1 as menu_depth %}
|
||||
<div class="collapse navbar-collapse menu-bar page-menu-bar" id="navbarSupportedContent">
|
||||
<div class="brand-wrapper">
|
||||
{% include 'partials/brand.html' with big=True %}
|
||||
</div>
|
||||
<ul class="navbar-nav">
|
||||
{% rootpage_as_category as page_tree_root %}
|
||||
{% category_tree 2 page_tree_root as page_tree_items %}
|
||||
{% include "partials/dropdown.html" with menu_items=page_tree_items limit=2 %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block append_header_block %}
|
||||
{% include "oxyan/partials/language_chooser.html" %}
|
||||
{% endblock %}
|
||||
|
||||
<a aria-label="Search">zoeken</a>
|
||||
<button class="navbar-toggler collapsed" aria-label="Navbar toggle" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
|
||||
<i class="fa fa-bars nav-icon"></i>
|
||||
<i class="fa fa-times nav-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
{% extends "carbasa/headers/header.html" %}
|
||||
|
||||
@@ -3,3 +3,7 @@
|
||||
{% block append_header_block %}
|
||||
{% include "oxyan/partials/language_chooser.html" %}
|
||||
{% endblock append_header_block %}
|
||||
|
||||
{% block language_chooser %}
|
||||
{% include "oxyan/partials/language_chooser.html" %}
|
||||
{% endblock language_chooser %}
|
||||
|
||||
@@ -3,3 +3,7 @@
|
||||
{% block append_header_block %}
|
||||
{% include "oxyan/partials/language_chooser.html" %}
|
||||
{% endblock append_header_block %}
|
||||
|
||||
{% block language_chooser %}
|
||||
{% include "oxyan/partials/language_chooser.html" %}
|
||||
{% endblock language_chooser %}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- MB OVERRIDE -->
|
||||
{% load i18n static ocyanjson mandelstudio_i18n %}
|
||||
|
||||
{% get_current_language as current_language %}
|
||||
|
||||
Reference in New Issue
Block a user