feat: scaffold Django multi-tenant project with 5 of 9 apps
Phase 1 scaffolding: config/, core/, base models, AES-256-GCM phone encryption, enums mirror apps.tenant: Tenant + Domain (django-tenants) apps.org: 11 models (OrgUnit hierarchy, Staff, audit logs) apps.account: 4 models (UserAccount as AUTH_USER_MODEL, login/password tracking) apps.permission: 7 models (RBAC + overrides + datascope + append-only changelog) apps.region: 5 models (District, BusinessArea, MetroLine, MetroStation, School) All migrations generated, manage.py check passes
This commit is contained in:
23
core/htmx.py
Normal file
23
core/htmx.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.http import HttpResponse
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
def htmx_response(request, template: str, context: dict | None = None, status: int = 200) -> HttpResponse:
|
||||
html = render_to_string(template, context or {}, request=request)
|
||||
return HttpResponse(html, status=status)
|
||||
|
||||
|
||||
def htmx_trigger(response: HttpResponse, event: str, detail: dict | None = None) -> HttpResponse:
|
||||
import json
|
||||
|
||||
payload = response.headers.get("HX-Trigger")
|
||||
triggers = json.loads(payload) if payload else {}
|
||||
triggers[event] = detail or {}
|
||||
response.headers["HX-Trigger"] = json.dumps(triggers)
|
||||
return response
|
||||
|
||||
|
||||
def htmx_redirect(url: str) -> HttpResponse:
|
||||
response = HttpResponse(status=204)
|
||||
response.headers["HX-Redirect"] = url
|
||||
return response
|
||||
Reference in New Issue
Block a user