Commit 2e669ff4 authored by GraceDB's avatar GraceDB

Update spiir account

parent 32550bcf
Pipeline #61141 passed with stages
in 13 minutes and 19 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-03-15 20:38
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'old_username': 'gstlal-spiir',
'new_username': 'spiir',
'old_last_name': 'GSTLAL SPIIR Analysis',
'new_last_name': 'SPIIR',
'new_subject': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-pcdev11.ligo.caltech.edu/CN=spiir/CN=Qi Chu/CN=UID:qi.chu.robot',
}
def update_acct(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
# Get user
user = RobotUser.objects.get(username=ACCOUNT['old_username'])
# Create new certificate for user
user.x509cert_set.create(subject=ACCOUNT['new_subject'])
# Update user information
user.username = ACCOUNT['new_username']
user.last_name = ACCOUNT['new_last_name']
user.save(update_fields=['username', 'last_name'])
def revert_acct(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
# Get user
user = RobotUser.objects.get(username=ACCOUNT['new_username'])
# Delete new certificate
user.x509cert_set.get(subject=ACCOUNT['new_subject']).delete()
# Revert user information
user.username = ACCOUNT['old_username']
user.last_name = ACCOUNT['old_last_name']
user.save(update_fields=['username', 'last_name'])
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0029_update_detchar_certs'),
]
operations = [
migrations.RunPython(update_acct, revert_acct),
]
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