diff --git a/gracedb/ligoauth/migrations/0059_grb_exttrig_cert.py b/gracedb/ligoauth/migrations/0059_grb_exttrig_cert.py new file mode 100644 index 0000000000000000000000000000000000000000..b27c286f278216e8b33805130f759e1b91341d76 --- /dev/null +++ b/gracedb/ligoauth/migrations/0059_grb_exttrig_cert.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-06-03 20:10 +from __future__ import unicode_literals + +from django.db import migrations + +# detchar is on a tear getting new certs, so I'm doing three +# at once. + +gracedb_account = 'grb.exttrig' +new_certs = ['/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-pcdev1.ligo.caltech.edu/CN=grb.exttrig/CN=Ryan Fisher/CN=UID:ryan.fisher.robot',] + + +def add_cert(apps, schema_editor): + RobotUser = apps.get_model('auth', 'User') + + # Get user + user = RobotUser.objects.get(username=gracedb_account) + + # Create new certificates + for cert in new_certs: + user.x509cert_set.create(subject=cert) + + +def delete_cert(apps, schema_editor): + RobotUser = apps.get_model('auth', 'User') + + # Get user + user = RobotUser.objects.get(username=gracedb_account) + + # Delete new certificates + for cert in new_certs: + cert = user.x509cert_set.get(subject=cert) + cert.delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('ligoauth', '0058_add_more_detchar_certs'), + ] + + operations = [ + migrations.RunPython(add_cert, delete_cert), + ] \ No newline at end of file