From cff55b4d0dcb75cb2cb9ddf69ed3e8f3306d5abd Mon Sep 17 00:00:00 2001 From: Tanner Prestegard <tanner.prestegard@ligo.org> Date: Fri, 31 May 2019 14:50:41 -0500 Subject: [PATCH] Fix up old migrations to work with new Group names --- .../0003_initial_localuser_and_x509cert_data.py | 7 +++++-- .../ligoauth/migrations/0005_update_emfollow_accounts.py | 8 ++++++-- gracedb/ligoauth/migrations/0007_update_gstlalcbctest.py | 8 ++++++-- .../migrations/0021_create_deepclean_account_and_certs.py | 8 ++++++-- .../migrations/0024_create_gwhen_account_and_certs.py | 8 ++++++-- .../0028_create_gbm_followup_account_and_certs.py | 8 ++++++-- .../0032_create_gweventlistener_acct_and_cert.py | 8 ++++++-- 7 files changed, 41 insertions(+), 14 deletions(-) diff --git a/gracedb/ligoauth/migrations/0003_initial_localuser_and_x509cert_data.py b/gracedb/ligoauth/migrations/0003_initial_localuser_and_x509cert_data.py index 5763179e6..fd2bb2f9e 100644 --- a/gracedb/ligoauth/migrations/0003_initial_localuser_and_x509cert_data.py +++ b/gracedb/ligoauth/migrations/0003_initial_localuser_and_x509cert_data.py @@ -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'] diff --git a/gracedb/ligoauth/migrations/0005_update_emfollow_accounts.py b/gracedb/ligoauth/migrations/0005_update_emfollow_accounts.py index 8382f725e..f88071fce 100644 --- a/gracedb/ligoauth/migrations/0005_update_emfollow_accounts.py +++ b/gracedb/ligoauth/migrations/0005_update_emfollow_accounts.py @@ -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): diff --git a/gracedb/ligoauth/migrations/0007_update_gstlalcbctest.py b/gracedb/ligoauth/migrations/0007_update_gstlalcbctest.py index 8b7b8b608..f8bc735cf 100644 --- a/gracedb/ligoauth/migrations/0007_update_gstlalcbctest.py +++ b/gracedb/ligoauth/migrations/0007_update_gstlalcbctest.py @@ -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']) diff --git a/gracedb/ligoauth/migrations/0021_create_deepclean_account_and_certs.py b/gracedb/ligoauth/migrations/0021_create_deepclean_account_and_certs.py index fb51749df..0dcca4f17 100644 --- a/gracedb/ligoauth/migrations/0021_create_deepclean_account_and_certs.py +++ b/gracedb/ligoauth/migrations/0021_create_deepclean_account_and_certs.py @@ -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 diff --git a/gracedb/ligoauth/migrations/0024_create_gwhen_account_and_certs.py b/gracedb/ligoauth/migrations/0024_create_gwhen_account_and_certs.py index 22f514ce7..d6f6627f5 100644 --- a/gracedb/ligoauth/migrations/0024_create_gwhen_account_and_certs.py +++ b/gracedb/ligoauth/migrations/0024_create_gwhen_account_and_certs.py @@ -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 diff --git a/gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py b/gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py index edd1be88b..52927afcf 100644 --- a/gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py +++ b/gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py @@ -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 diff --git a/gracedb/ligoauth/migrations/0032_create_gweventlistener_acct_and_cert.py b/gracedb/ligoauth/migrations/0032_create_gweventlistener_acct_and_cert.py index d4a54c91b..89ae9e6e9 100644 --- a/gracedb/ligoauth/migrations/0032_create_gweventlistener_acct_and_cert.py +++ b/gracedb/ligoauth/migrations/0032_create_gweventlistener_acct_and_cert.py @@ -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 -- GitLab