diff --git a/gracedb/ligoauth/migrations/0048_update_executives_membership.py b/gracedb/ligoauth/migrations/0048_update_executives_membership.py new file mode 100644 index 0000000000000000000000000000000000000000..066045ea1032f48f2ac926f91b8a69dfa865b439 --- /dev/null +++ b/gracedb/ligoauth/migrations/0048_update_executives_membership.py @@ -0,0 +1,43 @@ +# -*- 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), + ] diff --git a/gracedb/ligoauth/migrations/0049_update_access_managers_membership.py b/gracedb/ligoauth/migrations/0049_update_access_managers_membership.py new file mode 100644 index 0000000000000000000000000000000000000000..8d93214cfdd4922041e8f442e5034123a9d70571 --- /dev/null +++ b/gracedb/ligoauth/migrations/0049_update_access_managers_membership.py @@ -0,0 +1,46 @@ +# -*- 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), + ]