|
1 | 1 | # Copyright 2016 IETF Trust |
2 | 2 |
|
| 3 | +import sys |
| 4 | + |
3 | 5 | #from django.conf import settings |
4 | 6 | from django.core.management.base import BaseCommand, CommandError |
5 | 7 |
|
6 | 8 | import debug # pyflakes:ignore |
7 | 9 |
|
8 | 10 | from ietf.group.models import Role |
| 11 | +from ietf.name.models import GroupTypeName, RoleName |
9 | 12 |
|
10 | 13 | class Command(BaseCommand): |
11 | 14 | help = "Create apache permission stanzas for given roles." |
12 | 15 |
|
13 | 16 | def add_arguments(self, parser): |
14 | | - parser.add_argument('roles', nargs='+', |
| 17 | + parser.add_argument('roles', nargs='*', |
15 | 18 | help="One or more group:type:role specifications. Use '*' as wildcard. Use group acronyms " |
16 | 19 | "for groups and group type and role name slugs for type and role. " |
17 | 20 | "Examples: all ADs: *:*:ad, core chairs: core:*:chair, Directorate secretaries: *:dir:secr." |
18 | 21 | ) |
| 22 | + parser.add_argument('-l', '--list-slugs', action='store_true', default=False, |
| 23 | + help="List the group type and role slugs") |
19 | 24 |
|
20 | 25 | # -------------------------------------------------------------------- |
21 | 26 |
|
22 | 27 | def handle(self, *filenames, **options): |
23 | 28 | self.verbosity = options['verbosity'] |
24 | 29 | self.errors = [] |
25 | 30 |
|
| 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 | + |
26 | 40 | for role_spec in options["roles"]: |
27 | 41 | try: |
28 | 42 | group, type, name = role_spec.split(':') |
|
0 commit comments