Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael William Coughlin
GraceDB Server
Commits
2409e493
Commit
2409e493
authored
7 years ago
by
Tanner Prestegard
Committed by
gracedb-dev1
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
updating information for oLIB and LIB PE accounts
parent
c20f601b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ligoauth/migrations/0018_update_lib_accounts.py
+69
-0
69 additions, 0 deletions
ligoauth/migrations/0018_update_lib_accounts.py
with
69 additions
and
0 deletions
ligoauth/migrations/0018_update_lib_accounts.py
0 → 100644
+
69
−
0
View file @
2409e493
# -*- coding: utf-8 -*-
# Default imports
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
from
django.conf
import
settings
ROBOTS
=
[{
'
username
'
:
{
'
old
'
:
'
LIB
'
,
'
new
'
:
'
LIB_PE
'
},
'
last_name
'
:
{
'
old
'
:
'
LIB at CIT
'
,
'
new
'
:
'
LIB PE at CIT
'
},
},
{
'
username
'
:
'
oLIB
'
,
'
last_name
'
:
{
'
old
'
:
'
LIB at CIT
'
,
'
new
'
:
'
oLIB at CIT
'
},
},
]
def
create_robots
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
# Get user and update information
for
entry
in
ROBOTS
:
update_username
=
False
# get user
if
isinstance
(
entry
[
'
username
'
],
dict
):
username
=
entry
[
'
username
'
][
'
old
'
]
update_username
=
True
else
:
username
=
entry
[
'
username
'
]
user
=
LocalUser
.
objects
.
get
(
username
=
username
)
# update information
if
update_username
:
user
.
username
=
entry
[
'
username
'
][
'
new
'
]
user
.
last_name
=
entry
[
'
last_name
'
][
'
new
'
]
# save
user
.
save
()
def
delete_robots
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
# Get user and update information
for
entry
in
ROBOTS
:
update_username
=
False
# get user
if
isinstance
(
entry
[
'
username
'
],
dict
):
username
=
entry
[
'
username
'
][
'
new
'
]
update_username
=
True
else
:
username
=
entry
[
'
username
'
]
user
=
LocalUser
.
objects
.
get
(
username
=
username
)
# update information
if
update_username
:
user
.
username
=
entry
[
'
username
'
][
'
old
'
]
user
.
last_name
=
entry
[
'
last_name
'
][
'
old
'
]
# save
user
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
ligoauth
'
,
'
0017_add_virgo_detchar
'
),
]
operations
=
[
migrations
.
RunPython
(
create_robots
,
delete_robots
)
]
# End of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment