Skip to content

Commit

Permalink
refactor: consolidate add_perm calls (⚠️ untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Nov 15, 2024
1 parent 42190a7 commit e3762f6
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 151 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_grid,
let_add_and_delete_grid
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Grid Editor (Advanced)'
)

add_perm(group, 'cms', 'page', 'Can change page')
add_perm(group, 'cms', 'page', 'Can view page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can add bootstrap4 grid container')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can change bootstrap4 grid container')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can delete bootstrap4 grid container')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can view bootstrap4 grid container')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can add bootstrap4 grid column')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can change bootstrap4 grid column')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can delete bootstrap4 grid column')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can view bootstrap4 grid column')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can add bootstrap4 grid row')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can change bootstrap4 grid row')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can delete bootstrap4 grid row')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can view bootstrap4 grid row')
let_edit_page_content(group)
let_view_and_change_grid(group)
let_add_and_delete_grid(group)
20 changes: 6 additions & 14 deletions taccsite_cms/management/commands/group_perms/grid_editor_basic.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_grid
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Grid Editor (Basic)'
)

add_perm(group, 'cms', 'page', 'Can change page')
add_perm(group, 'cms', 'page', 'Can view page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can change bootstrap4 grid container')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid container', 'Can view bootstrap4 grid container')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can change bootstrap4 grid column')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid column', 'Can view bootstrap4 grid column')

add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can change bootstrap4 grid row')
add_perm(group, 'bootstrap4_grid', 'bootstrap4 grid row', 'Can view bootstrap4 grid row')
let_edit_page_content(group)
let_view_and_change_grid(group)
Original file line number Diff line number Diff line change
@@ -1,54 +1,22 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_media_plugins,
let_add_and_delete_media_plugins,
let_view_thumbnail_option,
let_view_and_change_folder,
let_view_and_change_image_file,
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Media Editor (Advanced)'
)

add_perm(group, 'cms', 'page', 'Can change page')
add_perm(group, 'cms', 'page', 'Can view page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can add bootstrap4 picture')
add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can change bootstrap4 picture')
add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can delete bootstrap4 picture')
add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can view bootstrap4 picture')

add_perm(group, 'djangocms_picture', 'picture', 'Can add picture')
add_perm(group, 'djangocms_picture', 'picture', 'Can change picture')
add_perm(group, 'djangocms_picture', 'picture', 'Can delete picture')
add_perm(group, 'djangocms_picture', 'picture', 'Can view picture')

add_perm(group, 'djangocms_video', 'video player', 'Can add video player')
add_perm(group, 'djangocms_video', 'video player', 'Can change video player')
add_perm(group, 'djangocms_video', 'video player', 'Can delete video player')
add_perm(group, 'djangocms_video', 'video player', 'Can view video player')
add_perm(group, 'djangocms_video', 'video source', 'Can add video source')
add_perm(group, 'djangocms_video', 'video source', 'Can change video source')
add_perm(group, 'djangocms_video', 'video source', 'Can delete video source')
add_perm(group, 'djangocms_video', 'video source', 'Can view video source')
add_perm(group, 'djangocms_video', 'video track', 'Can add video track')
add_perm(group, 'djangocms_video', 'video track', 'Can change video track')
add_perm(group, 'djangocms_video', 'video track', 'Can delete video track')
add_perm(group, 'djangocms_video', 'video track', 'Can view video track')

add_perm(group, 'filer', 'Folder', 'Can add Folder')
add_perm(group, 'filer', 'Folder', 'Can change Folder')
add_perm(group, 'filer', 'Folder', 'Can view Folder')
add_perm(group, 'filer', 'Folder', 'Can delete Folder')

add_perm(group, 'filer', 'file', 'Can add file')
add_perm(group, 'filer', 'file', 'Can change file')
add_perm(group, 'filer', 'file', 'Can view file')
add_perm(group, 'filer', 'file', 'Can delete file')

add_perm(group, 'filer', 'Folder', 'Can use directory listing')
add_perm(group, 'filer', 'Folder', 'Can view Folder')

add_perm(group, 'filer', 'image', 'Can change image')
add_perm(group, 'filer', 'image', 'Can view image')

add_perm(group, 'filer', 'thumbnail option', 'Can view thumbnail option')
let_edit_page_content(group)
let_view_and_change_media_plugins(group)
let_add_and_delete_media_plugins(group)
let_view_thumbnail_option(group)
let_view_and_change_folder(group)
let_view_and_change_image_file(group)
40 changes: 12 additions & 28 deletions taccsite_cms/management/commands/group_perms/media_editor_basic.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_media_plugins,
let_view_thumbnail_option,
let_view_folder,
let_view_and_change_image_file,
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Media Editor (Basic)'
)

add_perm(group, 'cms', 'page', 'Can change page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can change bootstrap4 picture')
add_perm(group, 'bootstrap4_picture', 'bootstrap4 picture', 'Can view bootstrap4 picture')

add_perm(group, 'djangocms_picture', 'picture', 'Can change picture')
add_perm(group, 'djangocms_picture', 'picture', 'Can view picture')

add_perm(group, 'djangocms_video', 'video player', 'Can change video player')
add_perm(group, 'djangocms_video', 'video player', 'Can view video player')
add_perm(group, 'djangocms_video', 'video source', 'Can change video source')
add_perm(group, 'djangocms_video', 'video source', 'Can view video source')
add_perm(group, 'djangocms_video', 'video track', 'Can change video track')
add_perm(group, 'djangocms_video', 'video track', 'Can view video track')

add_perm(group, 'filer', 'file', 'Can change file')
add_perm(group, 'filer', 'file', 'Can view file')

add_perm(group, 'filer', 'Folder', 'Can use directory listing')
add_perm(group, 'filer', 'Folder', 'Can view Folder')

add_perm(group, 'filer', 'image', 'Can change image')
add_perm(group, 'filer', 'image', 'Can view image')

add_perm(group, 'filer', 'thumbnail option', 'Can view thumbnail option')
let_edit_page_content(group)
let_view_and_change_media_plugins(group)
let_view_folder(group)
let_view_and_change_image_file(group)
let_view_thumbnail_option(group)
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_text,
let_add_and_delete_text,
let_view_and_change_folder,
let_add_and_delete_folder,
let_view_and_change_file,
let_add_and_delete_file,
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Text Editor (Advanced)'
)

add_perm(group, 'cms', 'page', 'Can change page')
add_perm(group, 'cms', 'page', 'Can view page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'djangocms_link', 'link', 'Can add link')
add_perm(group, 'djangocms_link', 'link', 'Can change link')
add_perm(group, 'djangocms_link', 'link', 'Can delete link')
add_perm(group, 'djangocms_link', 'link', 'Can view link')

add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can add text')
add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can change text')
add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can delete text')
add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can view text')

add_perm(group, 'filer', 'Folder', 'Can use directory listing')
add_perm(group, 'filer', 'Folder', 'Can add Folder')
add_perm(group, 'filer', 'Folder', 'Can change Folder')
add_perm(group, 'filer', 'Folder', 'Can view Folder')
add_perm(group, 'filer', 'Folder', 'Can delete Folder')

add_perm(group, 'filer', 'file', 'Can add file')
add_perm(group, 'filer', 'file', 'Can change file')
add_perm(group, 'filer', 'file', 'Can delete file')
add_perm(group, 'filer', 'file', 'Can view file')
let_edit_page_content(group)
let_view_and_change_text(group)
let_add_and_delete_text(group)
let_view_and_change_folder(group)
let_add_and_delete_folder(group)
let_view_and_change_file(group)
let_add_and_delete_file(group)
27 changes: 10 additions & 17 deletions taccsite_cms/management/commands/group_perms/text_editor_basic.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
from django.contrib.auth.models import Group

from .util import add_perm
from .util import (
let_edit_page_content,
let_view_and_change_text,
let_view_folder,
let_view_and_change_file,
)

def set_group_perms():
group, was_created = Group.objects.get_or_create(
name='Text Editor (Basic)'
)

add_perm(group, 'cms', 'page', 'Can change page')

add_perm(group, 'cms', 'placeholder', 'Can use Structure mode')

add_perm(group, 'djangocms_link', 'link', 'Can change link')
add_perm(group, 'djangocms_link', 'link', 'Can view link')

add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can change text')
add_perm(group, 'djangocms_text_ckeditor', 'text', 'Can view text')

add_perm(group, 'filer', 'Folder', 'Can use directory listing')
add_perm(group, 'filer', 'Folder', 'Can change Folder')
add_perm(group, 'filer', 'Folder', 'Can view Folder')

add_perm(group, 'filer', 'file', 'Can change file')
add_perm(group, 'filer', 'file', 'Can view file')
let_edit_page_content(group)
let_view_and_change_text(group)
let_view_and_change_folder(group)
let_view_and_change_file(group)
Loading

0 comments on commit e3762f6

Please sign in to comment.