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
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
IGWN Computing and Software
GraceDB
GraceDB Server
Commits
bcc873e4
Commit
bcc873e4
authored
5 years ago
by
Alexander Pace
Browse files
Options
Downloads
Patches
Plain Diff
Adding migration for edoardo milotti to cwb pipeline
parent
8720b3bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#96403
passed
5 years ago
Stage: test
Stage: branch
Stage: latest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gracedb/migrations/guardian/0008_add_edoardo_milotti_to_cwb.py
+57
-0
57 additions, 0 deletions
...db/migrations/guardian/0008_add_edoardo_milotti_to_cwb.py
with
57 additions
and
0 deletions
gracedb/migrations/guardian/0008_add_edoardo_milotti_to_cwb.py
0 → 100644
+
57
−
0
View file @
bcc873e4
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-01 16:19
from
__future__
import
unicode_literals
from
django.db
import
migrations
# Creates UserObjectPermission objects which allow specific users
# to add events for pipelines. Based on current production database
# content (27 October 2017)
# List of pipeline names and lists of usernames who should
# be allowed to add events for them
PP_LIST
=
[
{
'
pipeline
'
:
'
cwb
'
,
'
usernames
'
:
[
'
edoardo.milotti@ligo.org
'
,
]
},
]
def
add_permissions
(
apps
,
schema_editor
):
User
=
apps
.
get_model
(
'
auth
'
,
'
User
'
)
Permission
=
apps
.
get_model
(
'
auth
'
,
'
Permission
'
)
UserObjectPermission
=
apps
.
get_model
(
'
guardian
'
,
'
UserObjectPermission
'
)
Pipeline
=
apps
.
get_model
(
'
events
'
,
'
Pipeline
'
)
ContentType
=
apps
.
get_model
(
'
contenttypes
'
,
'
ContentType
'
)
perm
=
Permission
.
objects
.
get
(
codename
=
'
populate_pipeline
'
)
ctype
=
ContentType
.
objects
.
get_for_model
(
Pipeline
)
for
pp_dict
in
PP_LIST
:
pipeline
=
Pipeline
.
objects
.
get
(
name
=
pp_dict
[
'
pipeline
'
])
# Loop over users
for
username
in
pp_dict
[
'
usernames
'
]:
# 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
(
user
=
user
,
permission
=
perm
,
content_type
=
ctype
,
object_pk
=
pipeline
.
id
)
def
remove_permissions
(
apps
,
schema_editor
):
pass
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
guardian
'
,
'
0007_add_gareth_davies_to_pycbc
'
),
]
operations
=
[
migrations
.
RunPython
(
add_permissions
,
remove_permissions
),
]
\ No newline at 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