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

Fix up old migrations to work with new Group names

parent 9563902e
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations 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 # List of robot user account information and their corresponding
# x509 certificate subjects. Based on current production database # x509 certificate subjects. Based on current production database
...@@ -345,7 +348,7 @@ def add_localusers_and_x509certs(apps, schema_editor): ...@@ -345,7 +348,7 @@ def add_localusers_and_x509certs(apps, schema_editor):
Group = apps.get_model('auth', 'Group') Group = apps.get_model('auth', 'Group')
# Create user accounts # 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: for l_dict in LOCALUSERS:
localuser, created = LocalUser.objects.get_or_create(username=l_dict['username']) localuser, created = LocalUser.objects.get_or_create(username=l_dict['username'])
localuser.last_name = l_dict['last_name'] localuser.last_name = l_dict['last_name']
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations 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 = { OLD_ACCOUNTS = {
'gdb-processor': { 'gdb-processor': {
...@@ -61,7 +65,7 @@ def deactivate_old_and_add_new_accounts(apps, schema_editor): ...@@ -61,7 +65,7 @@ def deactivate_old_and_add_new_accounts(apps, schema_editor):
new_user.x509cert_set.create(subject=subject) new_user.x509cert_set.create(subject=subject)
# Add user to LVC group # 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) group.user_set.add(new_user)
def activate_old_and_remove_new_accounts(apps, schema_editor): def activate_old_and_remove_new_accounts(apps, schema_editor):
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models 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 = [ ROBOTS = [
{ {
...@@ -20,7 +24,7 @@ def create_robots(apps, schema_editor): ...@@ -20,7 +24,7 @@ def create_robots(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser') LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert') X509Cert = apps.get_model('ligoauth', 'X509Cert')
Group = apps.get_model('auth', 'Group') 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: for entry in ROBOTS:
user, created = LocalUser.objects.get_or_create(username=entry['username']) user, created = LocalUser.objects.get_or_create(username=entry['username'])
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
# Generated by Django 1.11.16 on 2019-01-04 18:39 # Generated by Django 1.11.16 on 2019-01-04 18:39
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations 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 = { ACCOUNT = {
'username': 'deepclean', 'username': 'deepclean',
'email': 'michael.coughlin@ligo.org', 'email': 'michael.coughlin@ligo.org',
...@@ -27,7 +31,7 @@ def create_account_and_certs(apps, schema_editor): ...@@ -27,7 +31,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT) user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group # 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) group.user_set.add(user)
# Create X509 certificates # Create X509 certificates
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
# Generated by Django 1.11.18 on 2019-02-18 19:50 # Generated by Django 1.11.18 on 2019-02-18 19:50
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations 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 = { ACCOUNT = {
'username': 'Gwhen', 'username': 'Gwhen',
'email': 'stefan.countryman@ligo.org', 'email': 'stefan.countryman@ligo.org',
...@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor): ...@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT) user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group # 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) group.user_set.add(user)
# Create X509 certificates # Create X509 certificates
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
# Generated by Django 1.11.18 on 2019-03-27 17:12 # Generated by Django 1.11.18 on 2019-03-27 17:12
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations 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 = { ACCOUNT = {
'username': 'fermi-gbm-follow-up', 'username': 'fermi-gbm-follow-up',
'email': 'tyson.littenberg@ligo.org', 'email': 'tyson.littenberg@ligo.org',
...@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor): ...@@ -26,7 +30,7 @@ def create_account_and_certs(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT) user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group # 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) group.user_set.add(user)
# Create X509 certificates # Create X509 certificates
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
# Generated by Django 1.11.20 on 2019-05-14 17:48 # Generated by Django 1.11.20 on 2019-05-14 17:48
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations 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 = { ACCOUNT = {
'username': 'gweventlistener', 'username': 'gweventlistener',
'email': 'rachel.scrandis@ligo.org', 'email': 'rachel.scrandis@ligo.org',
...@@ -22,7 +26,7 @@ def create_acct_and_cert(apps, schema_editor): ...@@ -22,7 +26,7 @@ def create_acct_and_cert(apps, schema_editor):
user = RobotUser.objects.create(**ACCOUNT) user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group # 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) group.user_set.add(user)
# Create new certificate # Create new certificate
......
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