Skip to content

Commit 6f5c0fd

Browse files
committed
Added a trac-admin role name, for help in assigning trac-admin rights to trac instances. Extended the create_group_wikis management command to create and update wikis for groups of type 'team','ag' and 'dir', in addition to 'wg','rg' and 'area'; and also add people with role trac-admin in the group or in the secretariat to those given TRAC_ADMIN permissions in a Trac instance.
- Legacy-Id: 12721
1 parent e2640f3 commit 6f5c0fd

3 files changed

Lines changed: 34 additions & 5 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations
5+
6+
def forwards(apps, schema_editor):
7+
RoleName = apps.get_model('name', 'RoleName')
8+
RoleName.objects.create(slug='trac-admin', name='Trac Admin',
9+
desc='Assigned permission TRAC_ADMIN in datatracker-managed Trac Wiki instances',
10+
used=True)
11+
12+
def backwards(apps, schema_editor):
13+
RoleName = apps.get_model('name', 'RoleName')
14+
RoleName.objects.filter(slug='trac-admin').delete()
15+
16+
class Migration(migrations.Migration):
17+
18+
dependencies = [
19+
('name', '0016_auto_20161013_1010'),
20+
]
21+
22+
operations = [
23+
migrations.RunPython(forwards, backwards),
24+
]

ietf/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,9 @@ def skip_unreadable_post(record):
705705
TRAC_ISSUE_URL_PATTERN = "https://trac.ietf.org/trac/%s/report/1"
706706
TRAC_SVN_DIR_PATTERN = "/a/svn/group/%s"
707707
TRAC_SVN_URL_PATTERN = "https://svn.ietf.org/svn/group/%s/"
708+
709+
TRAC_CREATE_GROUP_TYPES = ['wg', 'rg', 'area', 'team', 'dir', 'ag', ]
710+
708711
SVN_PACKAGES = [
709712
"/usr/lib/python2.7/dist-packages/svn",
710713
"/usr/lib/python2.7/dist-packages/libsvn",

ietf/utils/management/commands/create_group_wikis.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class Command(BaseCommand):
4141
make_option('--dummy-run', '-n', default=False, action='store_true', dest='dummy_run', help='Make no changes, just show what would be done'),
4242
)
4343

44+
secretariat = Group.objects.get(acronym='secretariat')
45+
4446
def note(self, msg):
4547
if self.verbosity > 1:
4648
self.stdout.write(msg)
@@ -171,7 +173,7 @@ def create_trac(self, group):
171173
self.maybe_add_group_url(group, 'Issue tracker', settings.TRAC_ISSUE_URL_PATTERN % group.acronym)
172174
# Use custom assets (if any) from the master setup
173175
self.symlink_to_master_assets(group, env)
174-
if group.type_id == 'wg':
176+
if group.type_id in ['wg', 'rg', ]:
175177
self.add_wg_draft_states(group, env)
176178
self.add_custom_wiki_pages(group, env)
177179
self.add_default_wiki_pages(group, env)
@@ -198,7 +200,8 @@ def update_trac_permissions(self, group, env):
198200
if not user in permissions:
199201
permissions[user] = []
200202
permissions[user].append(action)
201-
roles = group.role_set.filter(name_id__in=['chair', 'secr', 'ad'])
203+
roles = ( list( group.role_set.filter(name_id__in=set(['chair', 'secr', 'ad', 'trac-admin', ]+group.features.admin_roles)))
204+
+ list(self.secretariat.role_set.filter(name_id__in=['trac-admin', ]) ))
202205
users = []
203206
for role in roles:
204207
user = role.email.address.lower()
@@ -287,7 +290,7 @@ def handle(self, *filenames, **options):
287290
raise CommandError('The SVN base direcory specified for the SVN directories (%s) does not exist.' % os.path.dirname(self.svn_dir_pattern))
288291

289292
groups = Group.objects.filter(
290-
type__slug__in=['wg','rg','area'],
293+
type__slug__in=settings.TRAC_CREATE_GROUP_TYPES,
291294
state__slug='active',
292295
).order_by('acronym')
293296
if self.group_list:
@@ -309,8 +312,7 @@ def handle(self, *filenames, **options):
309312
if not trac_env:
310313
self.errors.append(msg)
311314
else:
312-
if not self.dummy_run:
313-
trac_env = Environment(group.trac_dir)
315+
trac_env = Environment(group.trac_dir)
314316

315317
if not trac_env and not self.dummy_run:
316318
continue

0 commit comments

Comments
 (0)