Skip to content
Snippets Groups Projects
Verified Commit dcc3ccbc authored by Tanner Prestegard's avatar Tanner Prestegard
Browse files

Add and populate group for priority users

parent c1052265
No related branches found
No related tags found
No related merge requests found
......@@ -104,6 +104,7 @@ LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
LVEM_GROUP = 'gw-astronomy:LV-EM'
LVEM_OBSERVERS_GROUP = 'gw-astronomy:LV-EM:Observers'
PUBLIC_GROUP = 'public_users'
PRIORITY_USERS_GROUP = 'priority_users'
# Group names
# Executives group name
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2018-12-05 02:41
from __future__ import unicode_literals
from django.db import migrations
GROUP_NAME = 'priority_users'
def create_group(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
Group.objects.create(name=GROUP_NAME)
def delete_group(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
g = Group.objects.get(name=GROUP_NAME)
g.delete()
class Migration(migrations.Migration):
dependencies = [
('auth', '0018_update_emfollow_groups'),
]
operations = [
migrations.RunPython(create_group, delete_group),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2018-12-05 02:47
from __future__ import unicode_literals
from django.db import migrations
GROUP_NAME = 'priority_users'
PRIORITY_USERS = [
'detchar',
'emfollow',
'gstlal-spiir',
'gstlalcbc',
'MbtaAlert',
'oLIB',
'pycbclive',
'virgo_detchar',
'waveburst', # cWB
]
def add_users(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
User = apps.get_model('auth', 'User')
# Get group
pg = Group.objects.get(name=GROUP_NAME)
# Get users
users = User.objects.filter(username__in=PRIORITY_USERS)
# Add users
pg.user_set.add(*users)
def remove_users(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
User = apps.get_model('auth', 'User')
# Get group
pg = Group.objects.get(name=GROUP_NAME)
# Get users
users = User.objects.filter(username__in=PRIORITY_USERS)
# Remove users
pg.user_set.remove(*users)
class Migration(migrations.Migration):
dependencies = [
('auth', '0019_create_priority_users_group'),
]
operations = [
migrations.RunPython(add_users, remove_users),
]
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