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

Create and populate group for robot accounts

parent 5461963c
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-06-18 16:33
from __future__ import unicode_literals
from django.db import migrations
AUTHGROUP_INFO = {
'name': 'robot_accounts',
'description': ('Shared robot accounts for LIGO/Virgo pipelines, '
'follow-up processes, etc.'),
'ldap_name': 'Communities:robot:GraceDBrobotCert',
}
def create_authgroup(apps, schema_editor):
AuthGroup = apps.get_model('ligoauth', 'AuthGroup')
# Create AuthGroup
AuthGroup.objects.create(**AUTHGROUP_INFO)
def delete_authgroup(apps, schema_editor):
AuthGroup = apps.get_model('ligoauth', 'AuthGroup')
# Delete AuthGroup
ag = AuthGroup.objects.get(name=AUTHGROUP_INFO['name'])
ag.delete()
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0043_x509cert_delete_users_m2m_field'),
]
operations = [
migrations.RunPython(create_authgroup, delete_authgroup),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-06-18 16:42
from __future__ import unicode_literals
from django.db import migrations
ROBOT_GROUP_NAME = 'robot_accounts'
# Add current RobotUsers to robot_accounts AuthGroup
def add_users(apps, schema_editor):
AuthGroup = apps.get_model('ligoauth', 'AuthGroup')
RobotUser = apps.get_model('ligoauth', 'RobotUser')
group = AuthGroup.objects.get(name=ROBOT_GROUP_NAME)
for robot in RobotUser.objects.all():
group.user_set.add(robot.user_ptr)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0044_create_robot_accounts_authgroup'),
]
operations = [
migrations.RunPython(add_users, 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