This commit is contained in:
javad committed 2026-09-10 11:34:19 +03:30
commit fa9d154db9
260 files changed
+17643

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.db import connection
from django.http import JsonResponse
from django.shortcuts import render
from django.templatetags.static import static as static_url
from django.urls import include, path
from django.views.static import serve
from apps.core.models import SiteBranding
def healthz(request):
with connection.cursor() as cursor:
cursor.execute("SELECT 1")
cursor.fetchone()
response = JsonResponse({"status": "ok"})
response["Cache-Control"] = "no-store"
return response
def public_branding(request, path):
"""Serve only public branding uploads; all ticket files use authorized views."""
return serve(request, path, document_root=settings.MEDIA_ROOT / "branding")
def service_worker(request):
response = render(request, "pwa/service-worker.js", content_type="application/javascript")
response["Cache-Control"] = "no-cache, no-store, must-revalidate"
response["Service-Worker-Allowed"] = "/"
return response
def web_manifest(request):
branding = SiteBranding.load()
try:
icon_url = branding.pwa_icon.url if branding.pwa_icon else static_url("images/pwa-icon.png")
except (ValueError, OSError):
icon_url = static_url("images/pwa-icon.png")
response = JsonResponse({
"id": "/", "name": branding.pwa_name, "short_name": branding.pwa_title,
"description": branding.pwa_description, "start_url": "/tickets/", "scope": "/",
"display": "standalone", "background_color": "#eeeeee", "theme_color": "#08376b",
"lang": "fa", "dir": "rtl",
"icons": [{"src": icon_url, "sizes": "1024x1024", "type": "image/png", "purpose": "any maskable"}],
}, json_dumps_params={"ensure_ascii": False})
response["Cache-Control"] = "no-cache, no-store, must-revalidate"
return response
urlpatterns = [
path("healthz/", healthz, name="healthz"),
path("media/branding/<path:path>", public_branding, name="public_branding"),
path("service-worker.js", service_worker, name="service_worker"),
path("manifest.webmanifest", web_manifest, name="web_manifest"),
path("admin/", admin.site.urls),
path("", include("apps.accounts.urls")),
path("tickets/", include("apps.tickets.customer_urls")),
path("staff/", include("apps.tickets.staff_urls")),
path("messages/", include("apps.messaging.urls")),
path("files/", include("apps.attachments.urls")),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)