Skip to content

Commit 341edcb

Browse files
committed
spp_branding_kit: format controllers after import reorder
1 parent 26ce9f4 commit 341edcb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ docs/_build/
7676
#ruff
7777
.ruff_cache
7878
.aider*
79+
80+
# Local release planning files (ignored)
81+
.release/

spp_branding_kit/controllers/main.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,33 @@
88
from odoo import http
99
from odoo.http import request
1010

11+
from odoo.addons.portal.controllers.web import Home
12+
13+
14+
class OpenSPPHome(Home):
15+
"""Restrict debug mode to administrators when enabled via parameter."""
16+
17+
@http.route()
18+
def web_client(self, s_action=None, **kw):
19+
# Enforce optional debug restriction before rendering
20+
try:
21+
config_parameter = request.env["ir.config_parameter"].sudo()
22+
debug_admin_only = config_parameter.get_param("openspp.debug.admin_only", "True") == "True"
23+
except Exception: # pragma: no cover - defensive
24+
debug_admin_only = True
25+
26+
# Detect debug flag from kwargs or query string
27+
has_debug = bool(kw.get("debug")) or ("debug" in (request.httprequest.args or {}))
28+
if debug_admin_only and has_debug:
29+
uid = request.session.uid
30+
# If not logged in or not admin, strip debug and redirect
31+
if not uid or not request.env.user._is_admin():
32+
kw.pop("debug", None)
33+
args = {k: v for k, v in request.httprequest.args.items() if k != "debug"}
34+
return request.redirect("/web", query=args)
35+
36+
return super().web_client(s_action, **kw)
37+
1138

1239
class OpenSPPBrandingController(http.Controller):
1340
"""Custom routes for OpenSPP branding"""

0 commit comments

Comments
 (0)