forked from DGNum/gestioCOF
07f1a53532
These permissions concern pages, images, documents and access to the wagtail admin site. Only appropriate elements can be selected: only the kfet root page and its descendants, same for the kfet root collection (for images and documents), and kfet snippets (MemberTeam). Add django-formset-js as dependency to help manipulate formsets. K-Fêt groups created from "devdata" commands get suitable permissions for the CMS.
35 lines
942 B
Python
35 lines
942 B
Python
from django.apps import apps
|
|
|
|
from wagtail.wagtailcore.models import Collection, Page
|
|
|
|
|
|
def get_kfet_root_page():
|
|
"""
|
|
Returns the K-Fêt root page, or 'None' if it does not exist.
|
|
"""
|
|
from .models import KFetPage
|
|
return KFetPage.objects.first()
|
|
|
|
|
|
def get_kfet_root_collection():
|
|
"""
|
|
Returns the K-Fêt root collection, or 'None' if it does not exist.
|
|
"""
|
|
return Collection.objects.filter(name='K-Fêt').first()
|
|
|
|
|
|
def get_page_model_names():
|
|
"""
|
|
Returns all model names of `Page` subclasses.
|
|
|
|
This uses the django apps registry (instead of `ContentType.objects.all()`)
|
|
in order to be usuable even before migrations are applied. E.g. this can be
|
|
used in `Field.__init__`.
|
|
|
|
Note these model names are the same in `model` attribute of `ContentType`
|
|
objects.
|
|
"""
|
|
return [
|
|
model._meta.model_name
|
|
for model in apps.get_models() if issubclass(model, Page)
|
|
]
|