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

Add migrations for managing executives and access_managers membership

parent 16c9be60
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-08 20:30
from __future__ import unicode_literals
from django.db import migrations
# NOTE: membership in the 'executives' group has been managed by a script in a
# separate repo in the past, so this migration is the starting point for
# going away from that workflow. Also, the executives group will eventually
# be replaced by the 'access_managers' group, but until we update the
# permissions structure in the events app, we have to maintain it.
EXECUTIVES = [
'patrick.brady@LIGO.ORG',
'tanner.prestegard@LIGO.ORG',
'alexander.pace@LIGO.ORG',
]
def update_membership(apps, schema_editor):
User = apps.get_model('auth', 'User')
AuthGroup = apps.get_model('ligoauth', 'AuthGroup')
# Get executives group
execs = AuthGroup.objects.get(name='executives')
# Clear membership
execs.user_set.clear()
# Add users
for username in EXECUTIVES:
user, _ = User.objects.get_or_create(username=username)
execs.user_set.add(user)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0047_add_emfollow_cert'),
]
operations = [
migrations.RunPython(update_membership, migrations.RunPython.noop),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-08 20:37
from __future__ import unicode_literals
from django.db import migrations
ACCESS_MANAGERS = [
'alexander.pace@LIGO.ORG',
'brian.oreilly@LIGO.ORG',
'emfollow',
'erik.katsavounidis@LIGO.ORG'
'keita.kawabe@LIGO.ORG',
'leo.singer@LIGO.ORG',
'patrick.brady@LIGO.ORG',
'peter.shawhan@LIGO.ORG',
'sarah.antier@LIGO.ORG',
'shaon.ghosh@LIGO.ORG',
'tanner.prestegard@LIGO.ORG',
]
def update_membership(apps, schema_editor):
User = apps.get_model('auth', 'User')
AuthGroup = apps.get_model('ligoauth', 'AuthGroup')
# Get access_managers group
group = AuthGroup.objects.get(name='access_managers')
# Clear membership
group.user_set.clear()
# Add users
for username in ACCESS_MANAGERS:
user, _ = User.objects.get_or_create(username=username)
group.user_set.add(user)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0048_update_executives_membership'),
]
operations = [
migrations.RunPython(update_membership, migrations.RunPython.noop),
]
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