forked from DGNum/gestioCOF
CMS permissions can be managed from group views.
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.
This commit is contained in:
parent
82582866b4
commit
07f1a53532
19 changed files with 687 additions and 8 deletions
35
kfet/cms/utils.py
Normal file
35
kfet/cms/utils.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
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)
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue