clone cms with menus, make menus standalone app

This commit is contained in:
bruks 2026-09-30 15:27:04 +01:00
commit afb096b7a3
1153 changed files with 318897 additions and 37 deletions

29
cms/utils/admin.py Normal file
View file

@ -0,0 +1,29 @@
from django.contrib.sites.models import Site
from django.forms import IntegerField, ValidationError
from django.http import JsonResponse
from django.utils.encoding import smart_str
from cms.utils import get_current_site
NOT_FOUND_RESPONSE = "NotFound"
def jsonify_request(response):
""" Turn any response in a 200 response to let jQuery code handle it nicely.
Response contains a json object with the following attributes:
* status: original response status code
* content: original response content
"""
content = {'status': response.status_code, 'content': smart_str(response.content, response.charset)}
return JsonResponse(content)
def get_site_from_request(request):
try:
site_id = request.GET.get("site") or request.POST.get("site")
site_id = IntegerField().clean(site_id)
site = Site.objects.get(pk=site_id)
except (ValidationError, Site.DoesNotExist):
site = get_current_site(request)
return site