Switch to unified view

a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
...
...
364
                for obj in project_template['groups']:
364
                for obj in project_template['groups']:
365
                    name = obj.get('name')
365
                    name = obj.get('name')
366
                    permissions = set(obj.get('permissions', [])) & \
366
                    permissions = set(obj.get('permissions', [])) & \
367
                                  set(p.permissions)
367
                                  set(p.permissions)
368
                    usernames = obj.get('usernames', [])
368
                    usernames = obj.get('usernames', [])
369
                    # Must provide a group name
370
                    if not name: continue
371
                    # If the group already exists, we'll add users to it,
372
                    # but we won't change permissions on the group
373
                    group = M.ProjectRole.by_name(name, project=p)
374
                    if not group:
375
                        # If creating a new group, *must* specify permissions
369
                    if not (name and permissions): continue
376
                        if not permissions: continue
370
                    if M.ProjectRole.by_name(name): continue
371
                    group = M.ProjectRole(project_id=p._id, name=name)
377
                        group = M.ProjectRole(project_id=p._id, name=name)
372
                    p.acl += [M.ACE.allow(group._id, perm)
378
                        p.acl += [M.ACE.allow(group._id, perm)
373
                              for perm in permissions]
379
                                for perm in permissions]
374
                    for username in usernames:
380
                    for username in usernames:
375
                        user = M.User.by_username(username)
381
                        user = M.User.by_username(username)
376
                        if not (user and user._id): continue
382
                        if not (user and user._id): continue
377
                        user.project_role(project=p).roles.append(group._id)
383
                        pr = user.project_role(project=p)
384
                        if group._id not in pr.roles:
385
                            pr.roles.append(group._id)
378
            if 'tools' in project_template:
386
            if 'tools' in project_template:
379
                for i, tool in enumerate(project_template['tools'].keys()):
387
                for i, tool in enumerate(project_template['tools'].keys()):
380
                    tool_config = project_template['tools'][tool]
388
                    tool_config = project_template['tools'][tool]
381
                    app = p.install_app(tool,
389
                    app = p.install_app(tool,
382
                        mount_label=tool_config['label'],
390
                        mount_label=tool_config['label'],
383
                        mount_point=tool_config['mount_point'],
391
                        mount_point=tool_config['mount_point'],
384
                        ordinal=i+offset)
392
                        ordinal=i+offset)
385
                    if 'options' in tool_config:
393
                    if 'options' in tool_config:
394
                        from string import Template
386
                        for option in tool_config['options']:
395
                        for option in tool_config['options']:
387
                            app.config.options[option] = tool_config['options'][option]
396
                            s = Template(str(tool_config['options'][option]))
397
                            app.config.options[option] = s.safe_substitute(
398
                                    p.__dict__.get('root_project', {}))
388
                    if tool == 'wiki':
399
                    if tool == 'wiki':
389
                        from forgewiki import model as WM
400
                        from forgewiki import model as WM
390
                        text = tool_config.get('home_text',
401
                        text = tool_config.get('home_text',
391
                            '[[project_admins]]\n[[download_button]]')
402
                            '[[project_admins]]\n[[download_button]]')
392
                        WM.Page.query.get(app_config_id=app.config._id).text = text
403
                        WM.Page.query.get(app_config_id=app.config._id).text = text