File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
spp_branding_kit/controllers Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -76,3 +76,6 @@ docs/_build/
76
76
# ruff
77
77
.ruff_cache
78
78
.aider *
79
+
80
+ # Local release planning files (ignored)
81
+ .release /
Original file line number Diff line number Diff line change 8
8
from odoo import http
9
9
from odoo .http import request
10
10
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
+
11
38
12
39
class OpenSPPBrandingController (http .Controller ):
13
40
"""Custom routes for OpenSPP branding"""
You can’t perform that action at this time.
0 commit comments