Skip to content

Commit a3d1d55

Browse files
committed
Added an option to list the slugs that can be used with the generate_apache_perms management command.
- Legacy-Id: 14576
1 parent fd01a61 commit a3d1d55

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

ietf/utils/management/commands/generate_apache_perms.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
11
# Copyright 2016 IETF Trust
22

3+
import sys
4+
35
#from django.conf import settings
46
from django.core.management.base import BaseCommand, CommandError
57

68
import debug # pyflakes:ignore
79

810
from ietf.group.models import Role
11+
from ietf.name.models import GroupTypeName, RoleName
912

1013
class Command(BaseCommand):
1114
help = "Create apache permission stanzas for given roles."
1215

1316
def add_arguments(self, parser):
14-
parser.add_argument('roles', nargs='+',
17+
parser.add_argument('roles', nargs='*',
1518
help="One or more group:type:role specifications. Use '*' as wildcard. Use group acronyms "
1619
"for groups and group type and role name slugs for type and role. "
1720
"Examples: all ADs: *:*:ad, core chairs: core:*:chair, Directorate secretaries: *:dir:secr."
1821
)
22+
parser.add_argument('-l', '--list-slugs', action='store_true', default=False,
23+
help="List the group type and role slugs")
1924

2025
# --------------------------------------------------------------------
2126

2227
def handle(self, *filenames, **options):
2328
self.verbosity = options['verbosity']
2429
self.errors = []
2530

31+
if options['list_slugs']:
32+
self.stdout.write("Group types:\n\n")
33+
for t in GroupTypeName.objects.all().order_by('slug'):
34+
self.stdout.write(" %-16s %s\n" % (t.slug, t.name))
35+
self.stdout.write("\nRoles:\n\n")
36+
for r in RoleName.objects.all().order_by('slug'):
37+
self.stdout.write(" %-16s %s\n" % (r.slug, r.name))
38+
sys.exit(0)
39+
2640
for role_spec in options["roles"]:
2741
try:
2842
group, type, name = role_spec.split(':')

0 commit comments

Comments
 (0)