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
c8a74529
Commit
c8a74529
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Using new file utilities for superevents
parent
4262614d
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/superevents/api/views.py
+2
-36
2 additions, 36 deletions
gracedb/superevents/api/views.py
with
2 additions
and
36 deletions
gracedb/superevents/api/views.py
+
2
−
36
View file @
c8a74529
...
...
@@ -17,6 +17,7 @@ from ..utils import remove_tag_from_log, remove_event_from_superevent, \
remove_label_from_superevent
from
core.vfile
import
VersionedFile
from
core.http
import
check_and_serve_file
from
events.models
import
Event
,
Label
from
events.view_utils
import
reverse
as
gracedb_reverse
#from events.api.views import IsAuthorizedForPipeline, LigoLwRenderer
...
...
@@ -206,42 +207,7 @@ class SupereventFileViewSet(GetParentSupereventMixin,
file_name
=
self
.
kwargs
.
get
(
self
.
lookup_field
,
None
)
file_path
=
os
.
path
.
join
(
parent_superevent
.
datadir
,
file_name
)
# Check if file exists:
if
not
os
.
path
.
exists
(
file_path
):
err_msg
=
"
File {0} not found for superevent {1}
"
.
format
(
file_name
,
parent_superevent
.
superevent_id
)
response
=
Response
(
err_msg
,
status
=
status
.
HTTP_404_NOT_FOUND
)
elif
not
os
.
access
(
file_path
,
os
.
R_OK
):
err_msg
=
"
File {0} for superevent {1} is not readable
"
.
format
(
file_name
,
parent_superevent
.
superevent_id
)
response
=
Response
(
err_msg
,
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
elif
os
.
path
.
isfile
(
file_path
):
# Get an actual file.
# If the user is external, check for authorization
# TODO: update this
#if is_external(request.user):
# if not check_external_file_access(superevent, file_name):
# msg = "You do not have permission to view this file."
# return HttpResponseForbidden(msg)
# Try to figure out content type of file
content_type
,
encoding
=
VersionedFile
.
guess_mimetype
(
file_path
)
content_type
=
content_type
or
"
application/octet-stream
"
# Set up response object
response
=
Response
()
# Use Apache XSendFile module to serve file
response
[
'
X-Sendfile
'
]
=
file_path
# For binary files, add as an attachment (will be downloaded from
# browser instead of opened)
if
content_type
==
"
application/octet-stream
"
:
response
[
'
Content-Disposition
'
]
=
\
'
attachment; filename=
"
{0}
"'
.
format
(
os
.
path
.
basename
(
file_name
))
return
response
return
check_and_serve_file
(
request
,
file_path
,
ResponseClass
=
Response
)
class
SupereventVOEventViewSet
(
mixins
.
ListModelMixin
,
...
...
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