Skip to content
Snippets Groups Projects
  • Tanner Prestegard's avatar
    47a04356
    Group for RAVEN users · 47a04356
    Tanner Prestegard authored
    Create a group for the RAVEN pipeline, add users, and give the group
    specific permissions. Right now, they are just allowed to populate
    the Fermi, SNEWS, and Swift pipelines for uploading external events.
    47a04356
    History
    Group for RAVEN users
    Tanner Prestegard authored
    Create a group for the RAVEN pipeline, add users, and give the group
    specific permissions. Right now, they are just allowed to populate
    the Fermi, SNEWS, and Swift pipelines for uploading external events.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
0022_populate_raven_users_group.py 1.01 KiB
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-05-08 16:22
from __future__ import unicode_literals

from django.db import migrations

GROUP_NAME = 'raven_users'
USERS = [
    'brandon.piotrzkowski@LIGO.ORG',
]


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=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=USERS)

    # Remove users
    pg.user_set.remove(*users)


class Migration(migrations.Migration):

    dependencies = [
        ('auth', '0021_create_raven_users_group'),
    ]

    operations = [
        migrations.RunPython(add_users, remove_users),
    ]