Skip to content

Commit

Permalink
Merge pull request #562 from NBISweden/feature/save-user-consent
Browse files Browse the repository at this point in the history
Add user to when giving consent and fix temporary links
  • Loading branch information
viklund committed May 17, 2019
2 parents 536cff8 + 859c446 commit a723542
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions backend/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def post(self, dataset, event, target):
user = self.current_user

if event == 'consent':
user.save()
dv = (db.DatasetVersion
.select()
.join(db.Dataset)
Expand Down
10 changes: 5 additions & 5 deletions backend/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ class AuthorizedStaticNginxFileHandler(AuthorizedHandler, BaseStaticNginxFileHan


class TemporaryStaticNginxFileHandler(BaseStaticNginxFileHandler):
def get(self, dataset, hash_value, file):
def get(self, dataset, ds_version, hash_value, file):
logging.debug("Want to download hash {} ({})".format(hash_value, file))
linkhash = (db.Linkhash
.select()
.join(db.DatasetVersion)
.join(db.DatasetFile)
.where(db.Linkhash.hash == hash_value,
db.Linkhash.expires_on > datetime.datetime.now(),
db.DatasetFile.name == file))
.where(db.Linkhash.hash == hash_value,
db.Linkhash.expires_on > datetime.datetime.now(),
db.DatasetFile.name == file))
if linkhash.count() > 0:
logging.debug("Linkhash valid")
# Get temporary user from hash_value
Expand All @@ -243,7 +243,7 @@ def get(self, dataset, hash_value, file):
.join(db.Linkhash)
.where(db.Linkhash.hash == hash_value)
).get()
super().get(dataset, file, user)
super().get(dataset, file, ds_version, user)
else:
logging.debug("Linkhash invalid")
self.send_error(status_code=403)
Expand Down
2 changes: 1 addition & 1 deletion backend/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, settings):
{"path": "static/"}),
(r'/(favicon.ico)', tornado.web.StaticFileHandler,
{"path": "static/img/"}),
(r"/release/(?P<dataset>[^\/]+)/(?P<hash_value>[^\/]+)/(?P<file>[^\/]+)", handlers.TemporaryStaticNginxFileHandler,
(r"/release/(?P<dataset>[^\/]+)/versions/(?P<ds_version>[^/]+)/(?P<hash_value>[^\/]+)/(?P<file>[^\/]+)", handlers.TemporaryStaticNginxFileHandler,
{"path": "/release-files/"}),
(r"/release/(?P<dataset>[^\/]+)/versions/(?P<ds_version>[^/]+)/(?P<file>[^\/]+)", handlers.AuthorizedStaticNginxFileHandler,
{"path": "/release-files/"}),
Expand Down

0 comments on commit a723542

Please sign in to comment.