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
c454abe7
Commit
c454abe7
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adding error handling for destroy views.
Adding try/except blocks to destroy views to handle errors in perform_destroy
parent
90c8b2c8
No related branches found
No related tags found
1 merge request
!8
Superevents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gracedb/superevents/api/views.py
+33
-6
33 additions, 6 deletions
gracedb/superevents/api/views.py
with
33 additions
and
6 deletions
gracedb/superevents/api/views.py
+
33
−
6
View file @
c454abe7
...
@@ -127,11 +127,20 @@ class SupereventEventViewSet(mixins.ListModelMixin,
...
@@ -127,11 +127,20 @@ class SupereventEventViewSet(mixins.ListModelMixin,
return
obj
return
obj
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
try
:
self
.
perform_destroy
(
instance
)
except
Superevent
.
PreferredEventRemovalError
as
e
:
return
Response
(
e
.
__str__
(),
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
def
perform_destroy
(
self
,
instance
):
def
perform_destroy
(
self
,
instance
):
remove_event_from_superevent
(
instance
.
superevent
,
instance
,
remove_event_from_superevent
(
instance
.
superevent
,
instance
,
self
.
request
.
user
,
add_superevent_log
=
True
,
self
.
request
.
user
,
add_superevent_log
=
True
,
add_event_log
=
True
,
issue_superevent_alert
=
True
,
add_event_log
=
True
,
issue_superevent_alert
=
True
,
issue_event_alert
=
True
)
issue_event_alert
=
True
)
class
SupereventLabelViewSet
(
GetParentSupereventMixin
,
class
SupereventLabelViewSet
(
GetParentSupereventMixin
,
...
@@ -151,10 +160,18 @@ class SupereventLabelViewSet(GetParentSupereventMixin,
...
@@ -151,10 +160,18 @@ class SupereventLabelViewSet(GetParentSupereventMixin,
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
instance
=
self
.
get_object
()
remove_label_from_superevent
(
instance
,
request
.
user
,
try
:
add_log_message
=
True
,
issue_alert
=
True
)
self
.
perform_destroy
(
instance
)
except
Exception
as
e
:
return
Response
(
e
.
__str__
(),
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
def
perform_destroy
(
self
,
instance
):
remove_label_from_superevent
(
instance
,
self
.
request
.
user
,
add_log_message
=
True
,
issue_alert
=
True
)
class
SupereventLogViewSet
(
mixins
.
ListModelMixin
,
class
SupereventLogViewSet
(
mixins
.
ListModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
RetrieveModelMixin
,
...
@@ -199,6 +216,16 @@ class SupereventLogTagViewSet(GetParentSupereventMixin,
...
@@ -199,6 +216,16 @@ class SupereventLogTagViewSet(GetParentSupereventMixin,
parent_log
=
self
.
get_parent_log
()
parent_log
=
self
.
get_parent_log
()
return
parent_log
.
tags
.
all
()
return
parent_log
.
tags
.
all
()
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
try
:
self
.
perform_destroy
(
instance
)
except
Exception
as
e
:
return
Response
(
e
.
__str__
(),
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
def
perform_destroy
(
self
,
instance
):
def
perform_destroy
(
self
,
instance
):
parent_log
=
self
.
get_parent_log
()
parent_log
=
self
.
get_parent_log
()
remove_tag_from_log
(
parent_log
,
instance
,
self
.
request
.
user
,
remove_tag_from_log
(
parent_log
,
instance
,
self
.
request
.
user
,
...
...
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