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 Coughlin
GraceDB Server
Commits
7172f633
Commit
7172f633
authored
9 years ago
by
Branson Craig Stephens
Browse files
Options
Downloads
Patches
Plain Diff
Fixed scrub_mdc_events management command to remove associated GroupObjectPermissions.
parent
bbadaea2
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
gracedb/management/commands/scrub_mdc_events.py
+32
-1
32 additions, 1 deletion
gracedb/management/commands/scrub_mdc_events.py
with
32 additions
and
1 deletion
gracedb/management/commands/scrub_mdc_events.py
+
32
−
1
View file @
7172f633
import
os
,
shutil
from
django.core.management.base
import
NoArgsCommand
from
gracedb.models
import
Event
,
Search
,
Group
from
gracedb.models
import
CoincInspiralEvent
,
MultiBurstEvent
from
guardian.models
import
GroupObjectPermission
from
django.contrib.contenttypes.models
import
ContentType
class
Command
(
NoArgsCommand
):
help
=
"
I kill the MDC events.
"
...
...
@@ -31,7 +34,35 @@ class Command(NoArgsCommand):
print
'
Problem! Have not deleted datadir %s
'
%
datadir
exit
(
1
)
# We need to delete the relevant GroupObjectPermission objects as well.
# Any CoincInspiralEvent for this event? If so, delete their associated
# GroupObjectPermissions.
try
:
coinc_event
=
CoincInspiralEvent
.
objects
.
get
(
id
=
e
.
id
)
ctype
=
ContentType
.
objects
.
get
(
app_label
=
'
gracedb
'
,
model
=
'
coincinspiralevent
'
)
gops
=
GroupObjectPermission
.
objects
.
filter
(
object_pk
=
e
.
id
,
content_type
=
ctype
)
for
g
in
gops
:
g
.
delete
()
except
:
pass
# Any MultiBurstEvent for this event? If so, delete their associated
# GroupObjectPermissions.
try
:
coinc_event
=
MultiBurstEvent
.
objects
.
get
(
id
=
e
.
id
)
ctype
=
ContentType
.
objects
.
get
(
app_label
=
'
gracedb
'
,
model
=
'
multiburstevent
'
)
gops
=
GroupObjectPermission
.
objects
.
filter
(
object_pk
=
e
.
id
,
content_type
=
ctype
)
for
g
in
gops
:
g
.
delete
()
except
:
pass
# Finally delete the GroupObjectPermissions on the Event itself.
ctype
=
ContentType
.
objects
.
get
(
app_label
=
'
gracedb
'
,
model
=
'
event
'
)
gops
=
GroupObjectPermission
.
objects
.
filter
(
object_pk
=
e
.
id
,
content_type
=
ctype
)
for
g
in
gops
:
g
.
delete
()
# Now, say goodbye to the database entry
# Does this delete annotations too? That's something to test.
e
.
delete
()
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