Blame
|
1 | --- |
||||||
| 2 | category: reference |
|||||||
| 3 | tags: |
|||||||
| 4 | - p2 |
|||||||
| 5 | - otterwiki |
|||||||
| 6 | - platform-mode |
|||||||
| 7 | last_updated: 2026-03-13 |
|||||||
| 8 | --- |
|||||||
| 9 | ||||||||
| 10 | # P2-8: Admin Panel Hiding |
|||||||
| 11 | ||||||||
| 12 | ## Status: Complete |
|||||||
| 13 | ||||||||
| 14 | ## Acceptance Criteria |
|||||||
| 15 | ||||||||
| 16 | - [x] With `PLATFORM_MODE=True`: disabled sections hidden from nav, routes return 404 |
|||||||
| 17 | - [x] With `PLATFORM_MODE=false` (or unset): all sections visible (backward compatible) |
|||||||
| 18 | - [x] Enabled sections (Application Preferences, Sidebar Preferences, Content and Editing) work normally in both modes |
|||||||
| 19 | - [x] Existing test suite passes (325 tests + 8 new = 333 total) |
|||||||
| 20 | ||||||||
| 21 | ## Files Changed |
|||||||
| 22 | ||||||||
| 23 | | File | Change | |
|||||||
| 24 | |------|--------| |
|||||||
| 25 | | `otterwiki/server.py` | Added `PLATFORM_MODE=False` to default config | |
|||||||
| 26 | | `otterwiki/templates/settings.html` | Wrapped 4 disabled nav items in `{% if not config.PLATFORM_MODE %}` block | |
|||||||
| 27 | | `otterwiki/views.py` | Added `platform_mode_disabled` decorator; applied to 5 routes | |
|||||||
| 28 | | `tests/test_platform_mode.py` | New: 8 tests covering both modes | |
|||||||
| 29 | ||||||||
| 30 | ## Design Decisions |
|||||||
| 31 | ||||||||
| 32 | 1. **Decorator approach** — A `platform_mode_disabled` decorator on views.py routes returns `abort(404)` when `PLATFORM_MODE` is truthy. Placed after `@login_required` so auth still runs first. |
|||||||
| 33 | ||||||||
| 34 | 2. **Five routes disabled** — The 4 specified admin sections plus `/-/user/<uid>` (individual user editing), which is part of User Management and would be inconsistent to leave exposed. |
|||||||
| 35 | ||||||||
| 36 | 3. **Template conditional** — Single `{% if not config.PLATFORM_MODE %}` block wraps all 4 disabled nav links. The block is inside the existing `{% if has_permission("ADMIN") %}` guard, so it only affects admin users. |
|||||||
| 37 | ||||||||
| 38 | 4. **Config via `app.config`** — Reads from `app.config.get("PLATFORM_MODE")` so it can be set via environment variable, settings file, or programmatically in tests. |
|||||||
| 39 | ||||||||
| 40 | ## Test Results |
|||||||
| 41 | ||||||||
| 42 | - **Before**: 325 passed |
|||||||
| 43 | - **After**: 333 passed (8 new tests) |
|||||||
| 44 | - New tests cover: GET/POST 404 on disabled routes, 200 on enabled routes, nav item visibility in both modes, user edit route blocking |
|||||||
| 45 | ||||||||
| 46 | ## Branch |
|||||||
| 47 | ||||||||
| 48 | `feat/P2-8-admin-panel-hiding` based on `wikibot-io` — not pushed. |
|||||||