diff --git a/gracedb/ligoauth/migrations/0004_update_gstlal_spiir_account.py b/gracedb/ligoauth/migrations/0004_update_gstlal_spiir_account.py index c2bacb72c9b51d1be34762cb2cf1abb50617090b..c6c25ee224d99c6e7008c161cf67d9f5caf73d64 100644 --- a/gracedb/ligoauth/migrations/0004_update_gstlal_spiir_account.py +++ b/gracedb/ligoauth/migrations/0004_update_gstlal_spiir_account.py @@ -37,11 +37,12 @@ def update_accounts(apps, schema_editor): user.x509cert_set.add(new_cert) # Delete gstlal-spiir-gpu user and associated cert(s) - gpu_user = LocalUser.objects.get(username=GSTLAL_SPIIR_GPU['username']) + gpu_user = LocalUser.objects.get(username=GSTLAL_SPIIR_GPU['username']).user_ptr for cert in gpu_user.x509cert_set.all(): cert.delete() gpu_user.delete() + def rollback_accounts(apps, schema_editor): LocalUser = apps.get_model('ligoauth', 'LocalUser') X509Cert = apps.get_model('ligoauth', 'X509Cert') @@ -70,6 +71,7 @@ class Migration(migrations.Migration): dependencies = [ ('ligoauth', '0003_initial_localuser_and_x509cert_data'), + ('guardian', '0002_authorize_users_to_populate_pipelines'), ] operations = [ diff --git a/gracedb/ligoauth/migrations/0013_make_gstlal-spiir-gpu_robotuser.py b/gracedb/ligoauth/migrations/0013_make_gstlal-spiir-gpu_robotuser.py deleted file mode 100644 index 45807d3a787f478d52e4d770d285781c1d7e76a6..0000000000000000000000000000000000000000 --- a/gracedb/ligoauth/migrations/0013_make_gstlal-spiir-gpu_robotuser.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.16 on 2018-10-17 18:24 -from __future__ import unicode_literals - -from django.db import migrations - -username = 'gstlal-spiir-gpu' - - -def add_robotuser(apps, schema_editor): - User = apps.get_model('auth', 'User') - RobotUser = apps.get_model('ligoauth', 'RobotUser') - - # Get user account - user = User.objects.get(username=username) - - # Create RobotUser account with user_ptr and update dict - r_user = RobotUser.objects.create(user_ptr=user) - r_user.__dict__.update(user.__dict__) - r_user.save() - - -def remove_robotuser(apps, schema_editor): - RobotUser = apps.get_model('ligoauth', 'RobotUser') - - # Delete RobotUser, keep parent User - r_user = RobotUser.objects.get(username=username) - r_user.delete(keep_parents=True) - - -class Migration(migrations.Migration): - - dependencies = [ - ('ligoauth', '0012_rename_localuser_to_robotuser'), - ] - - operations = [ - migrations.RunPython(add_robotuser, remove_robotuser), - ] diff --git a/gracedb/ligoauth/migrations/0014_x509cert_subject_longer.py b/gracedb/ligoauth/migrations/0013_x509cert_subject_longer.py similarity index 86% rename from gracedb/ligoauth/migrations/0014_x509cert_subject_longer.py rename to gracedb/ligoauth/migrations/0013_x509cert_subject_longer.py index c7cedb58fc8adef9734369374e91ba6e4bc57817..2baccbc704f9dc2a9764a5e5333ec20a8cfc5f0f 100644 --- a/gracedb/ligoauth/migrations/0014_x509cert_subject_longer.py +++ b/gracedb/ligoauth/migrations/0013_x509cert_subject_longer.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('ligoauth', '0013_make_gstlal-spiir-gpu_robotuser'), + ('ligoauth', '0012_rename_localuser_to_robotuser'), ] operations = [ diff --git a/gracedb/ligoauth/migrations/0015_add_new_dashboard_cert.py b/gracedb/ligoauth/migrations/0014_add_new_dashboard_cert.py similarity index 95% rename from gracedb/ligoauth/migrations/0015_add_new_dashboard_cert.py rename to gracedb/ligoauth/migrations/0014_add_new_dashboard_cert.py index 6173c204fefe8802d98f799ef6ff1dbdebe7879a..decc12de503b7bbfcb850b2f4e3855d27636d65c 100644 --- a/gracedb/ligoauth/migrations/0015_add_new_dashboard_cert.py +++ b/gracedb/ligoauth/migrations/0014_add_new_dashboard_cert.py @@ -36,7 +36,7 @@ def remove_cert(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('ligoauth', '0014_x509cert_subject_longer'), + ('ligoauth', '0013_x509cert_subject_longer'), ] operations = [ diff --git a/gracedb/migrations/guardian/0002_authorize_users_to_populate_pipelines.py b/gracedb/migrations/guardian/0002_authorize_users_to_populate_pipelines.py index d24233f6606e525a24eca9243cce41f913959d5a..7cf2f9f307194c079d5b895445c733a6080b6805 100644 --- a/gracedb/migrations/guardian/0002_authorize_users_to_populate_pipelines.py +++ b/gracedb/migrations/guardian/0002_authorize_users_to_populate_pipelines.py @@ -146,8 +146,9 @@ def add_permissions(apps, schema_editor): # Loop over users for username in pp_dict['usernames']: - # Robot users should be created already by ligoauth 0002 - user, created = User.objects.get_or_create(username=username) + # Robot users should have been already created by ligoauth 0003, + # but we have to create human user accounts here + user, _ = User.objects.get_or_create(username=username) # Create UserObjectPermission uop, uop_created = UserObjectPermission.objects.get_or_create(