-
Notifications
You must be signed in to change notification settings - Fork 1
/
djangocms_misc_add_groups.py
34 lines (29 loc) · 1.25 KB
/
djangocms_misc_add_groups.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
import os
import shutil
from django.contrib.auth.models import Group, Permission
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.db.models import Q
class Command(BaseCommand):
"""
"""
help = (
"Add an basic set of auth.Groups for cms usage (cms-base, cms-publisher, cms-superuser, plugin-permissions) that gives basic CMS Permissions. User --plugin or --cms to add additional perms."
"")
def add_arguments(self, parser):
parser.add_argument(
'--force',
action='store_const',
const=True,
required=False,
help="""
Force overwrite of existing group and it's permissions.""")
def handle(self, *args, **options):
args = []
if options.get('force'):
args = ['--force', ]
call_command('djangocms_misc_add_cms_group', '--cms-base', *args)
call_command('djangocms_misc_add_cms_group', '--cms-publish', '--name=cms_publisher', *args)
call_command('djangocms_misc_add_cms_group', '--cms-superuser', '--name=cms_superuser', *args)
call_command('djangocms_misc_add_cms_group', '--cms', '--plugin', '--name=cms_plugin_permissions', *args)