Commit cff55b4d authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Fix up old migrations to work with new Group names

parent 9563902e
......@@ -3,7 +3,10 @@
from __future__ import unicode_literals
from django.db import migrations
from django.conf import settings
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
# List of robot user account information and their corresponding
# x509 certificate subjects. Based on current production database
......@@ -345,7 +348,7 @@ def add_localusers_and_x509certs(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
# Create user accounts
lvc_group = Group.objects.get(name=settings.LVC_GROUP)
lvc_group = Group.objects.get(name=LVC_GROUP)
for l_dict in LOCALUSERS:
localuser, created = LocalUser.objects.get_or_create(username=l_dict['username'])
localuser.last_name = l_dict['last_name']
......
......@@ -8,7 +8,11 @@
from __future__ import unicode_literals
from django.db import migrations
from django.conf import settings
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
OLD_ACCOUNTS = {
'gdb-processor': {
......@@ -61,7 +65,7 @@ def deactivate_old_and_add_new_accounts(apps, schema_editor):
new_user.x509cert_set.create(subject=subject)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group = Group.objects.get(name=LVC_GROUP)
group.user_set.add(new_user)
def activate_old_and_remove_new_accounts(apps, schema_editor):
......
......@@ -2,7 +2,11 @@
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
ROBOTS = [
{
......@@ -20,7 +24,7 @@ def create_robots(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
Group = apps.get_model('auth', 'Group')
lvc_group = Group.objects.get(name=settings.LVC_GROUP)
lvc_group = Group.objects.get(name=LVC_GROUP)
for entry in ROBOTS:
user, created = LocalUser.objects.get_or_create(username=entry['username'])
......
......@@ -2,9 +2,13 @@
# Generated by Django 1.11.16 on 2019-01-04 18:39
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
ACCOUNT = {
'username': 'deepclean',
'email': 'michael.coughlin@ligo.org',
......@@ -27,7 +31,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group = Group.objects.get(name=LVC_GROUP)
group.user_set.add(user)
# Create X509 certificates
......
......@@ -2,9 +2,13 @@
# Generated by Django 1.11.18 on 2019-02-18 19:50
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
ACCOUNT = {
'username': 'Gwhen',
'email': 'stefan.countryman@ligo.org',
......@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group = Group.objects.get(name=LVC_GROUP)
group.user_set.add(user)
# Create X509 certificates
......
......@@ -2,9 +2,13 @@
# Generated by Django 1.11.18 on 2019-03-27 17:12
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
ACCOUNT = {
'username': 'fermi-gbm-follow-up',
'email': 'tyson.littenberg@ligo.org',
......@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group = Group.objects.get(name=LVC_GROUP)
group.user_set.add(user)
# Create X509 certificates
......
......@@ -2,9 +2,13 @@
# Generated by Django 1.11.20 on 2019-05-14 17:48
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
# Previously, this was taken from settings.LVC_GROUP, but that value has
# changed. So we have to hard-code it for past migrations.
LVC_GROUP = 'Communities:LSCVirgoLIGOGroupMembers'
ACCOUNT = {
'username': 'gweventlistener',
'email': 'rachel.scrandis@ligo.org',
......@@ -22,7 +26,7 @@ def create_acct_and_cert(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group = Group.objects.get(name=LVC_GROUP)
group.user_set.add(user)
# Create new certificate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment