Skip to content

Commit

Permalink
Fetch dataset title and pass it as query param
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarthisius committed Nov 28, 2018
1 parent c706ac7 commit a4b8453
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/rest/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import cherrypy
import validators
from urllib.parse import urlparse, urlunparse, urlencode
from urllib.error import HTTPError, URLError
from girder.api import access
from girder.api.describe import Description, autoDescribeRoute
from girder.api.rest import Resource, RestException, setResponseHeader

from ..lib.dataverse.provider import DataverseImportProvider


class Integration(Resource):

Expand Down Expand Up @@ -40,13 +43,20 @@ def dataverseExternalTools(self, fileId, siteUrl, apiToken):
url = '{scheme}://{netloc}/api/access/datafile/{fileId}'.format(
scheme=site.scheme, netloc=site.netloc, fileId=fileId
)
query = {'uri': url}
try:
title, _, _ = DataverseImportProvider._parse_access_url(urlparse(url))
query['name'] = title
except (HTTPError, URLError):
# This doesn't bode well, but let's fail later when tale import happens
pass

# TODO: Make base url a plugin setting, defaulting to dashboard.<domain>
dashboard_url = os.environ.get('DASHBOARD_URL', 'https://dashboard.wholetale.org')
location = urlunparse(
urlparse(dashboard_url)._replace(
path='/compose',
query=urlencode({'uri': url}))
query=urlencode(query))
)
setResponseHeader('Location', location)
cherrypy.response.status = 303

0 comments on commit a4b8453

Please sign in to comment.