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

Rename LocalUser model to RobotUser

RobotUser should only be used for robot user accounts.  It's a clunky
way of identifying robot accounts, but it's all we have for now.
parent 379ef37c
No related branches found
No related tags found
No related merge requests found
......@@ -103,13 +103,13 @@ Edit the migration to do what you want it to do. You could use this as a templat
]
def create_robots(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
Group = apps.get_model('auth', 'Group')
lvc_group = Group.objects.get(name=settings.LVC_GROUP)
for entry in ROBOTS:
user, created = LocalUser.objects.get_or_create(username=entry['username'])
user, created = RobotUser.objects.get_or_create(username=entry['username'])
if created:
user.first_name = entry['first_name']
user.last_name = entry['last_name']
......@@ -133,13 +133,13 @@ Edit the migration to do what you want it to do. You could use this as a templat
lvc_group.user_set.add(user)
def delete_robots(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
for entry in ROBOTS:
for dn in entry['dns']:
X509Cert.objects.get(subject=dn).delete()
LocalUser.objects.get(username=entry['username']).delete()
RobotUser.objects.get(username=entry['username']).delete()
class Migration(migrations.Migration):
......
from django.contrib import admin
from .models import LocalUser, LigoLdapUser, X509Cert
from .models import RobotUser, LigoLdapUser, X509Cert
class LigoLdapUserAdmin(admin.ModelAdmin):
list_display = ['username', 'first_name', 'last_name']
......@@ -10,6 +10,6 @@ class X509CertAdmin(admin.ModelAdmin):
list_display = ['subject']
search_fields = ['subject']
admin.site.register(LocalUser)
admin.site.register(RobotUser)
admin.site.register(LigoLdapUser, LigoLdapUserAdmin)
admin.site.register(X509Cert, X509CertAdmin)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-17 18:22
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0011_update_virgo_detchar_cert'),
]
operations = [
migrations.RenameModel(
old_name='LocalUser',
new_name='RobotUser',
),
]
......@@ -7,7 +7,7 @@ from django.contrib.auth.models import User
# There seems to be a LOT of duplication here and I don't know
# if that is good or bad. Normally, that seems bad...
#
# The thing is, LigoLdapUser and LocalUser (and whatever we might add later)
# The thing is, LigoLdapUser and RobotUser (and whatever we might add later)
# are actual entities that we want synched with the Django User, so they *are*
# separate could conceivably have different first_name's, say, yet still refer
# to the same (abstract) user entity. Not likely, and not initially, but
......@@ -58,7 +58,8 @@ class LigoLdapUser(User):
return u"{0} {1}".format(self.first_name, self.last_name).encode('utf-8')
class LocalUser(User):
# Class for robot accounts
class RobotUser(User):
pass
class X509Cert(models.Model):
......
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