From a3d1d5595d19275f641af3e0b110af7f40a00cfe Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 26 Jan 2018 22:40:48 +0000 Subject: [PATCH] Added an option to list the slugs that can be used with the generate_apache_perms management command. - Legacy-Id: 14576 --- .../management/commands/generate_apache_perms.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ietf/utils/management/commands/generate_apache_perms.py b/ietf/utils/management/commands/generate_apache_perms.py index 5e333a3ab..d07f5dba2 100644 --- a/ietf/utils/management/commands/generate_apache_perms.py +++ b/ietf/utils/management/commands/generate_apache_perms.py @@ -1,21 +1,26 @@ # Copyright 2016 IETF Trust +import sys + #from django.conf import settings from django.core.management.base import BaseCommand, CommandError import debug # pyflakes:ignore from ietf.group.models import Role +from ietf.name.models import GroupTypeName, RoleName class Command(BaseCommand): help = "Create apache permission stanzas for given roles." def add_arguments(self, parser): - parser.add_argument('roles', nargs='+', + parser.add_argument('roles', nargs='*', help="One or more group:type:role specifications. Use '*' as wildcard. Use group acronyms " "for groups and group type and role name slugs for type and role. " "Examples: all ADs: *:*:ad, core chairs: core:*:chair, Directorate secretaries: *:dir:secr." ) + parser.add_argument('-l', '--list-slugs', action='store_true', default=False, + help="List the group type and role slugs") # -------------------------------------------------------------------- @@ -23,6 +28,15 @@ class Command(BaseCommand): self.verbosity = options['verbosity'] self.errors = [] + if options['list_slugs']: + self.stdout.write("Group types:\n\n") + for t in GroupTypeName.objects.all().order_by('slug'): + self.stdout.write(" %-16s %s\n" % (t.slug, t.name)) + self.stdout.write("\nRoles:\n\n") + for r in RoleName.objects.all().order_by('slug'): + self.stdout.write(" %-16s %s\n" % (r.slug, r.name)) + sys.exit(0) + for role_spec in options["roles"]: try: group, type, name = role_spec.split(':')