Skip to content
Snippets Groups Projects
Commit 7923dc72 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Adding new groups for managing permissions

Created the 'access_managers' and 'superevent_managers' groups. These
groups will be given appropriate permissions for managing external
access to gracedb and creating/updating superevents, respectively.
parent 32d36d5e
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-08-02 18:33
# Create new groups for managing external access to superevents
# and for allowing non-Test superevent creation and update. We
# also add users to those groups
from __future__ import unicode_literals
from django.db import migrations
GROUPS = {
'access_managers': [],
'superevent_managers': ['emfollow'],
}
def add_groups(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
User = apps.get_model('auth', 'User')
for group_name, usernames in GROUPS.iteritems():
g, _ = Group.objects.get_or_create(name=group_name)
users = User.objects.filter(username__in=usernames)
g.user_set.add(*users)
def remove_groups(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
User = apps.get_model('auth', 'User')
for group_name in GROUPS:
g = Group.objects.get(name=group_name)
g.delete()
class Migration(migrations.Migration):
dependencies = [
('auth', '0015_update_emfollow_accounts'),
]
operations = [
migrations.RunPython(add_groups, remove_groups),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment