diff --git a/api/api.py b/api/api.py index af2ca74b12c21cf86fb29753cd4a045e58fca773..508f7bc32ba7f7b154f0047c32e7f4e1c92fcdde 100644 --- a/api/api.py +++ b/api/api.py @@ -142,7 +142,8 @@ endpoints = [ route('/<:[^/]+>/logs', JobHandler, h='add_logs', m=['POST']), ]), route('/gears', GearsHandler), - route('/gears/temp', GearHandler, h='upload', m=['POST']), + route('/gears/temp', GearHandler, h='upload', m=['POST']), + route('/gears/temp/<cid:{cid}>', GearHandler, h='download', m=['GET']), prefix('/gears', [ route('/<:[^/]+>', GearHandler), route('/<:[^/]+>/invocation', GearHandler, h='get_invocation'), diff --git a/api/jobs/handlers.py b/api/jobs/handlers.py index 3f7f044e806572afeec1089cd3c970f3a9852de5..0fc2c8f72acc37ee2773e5c2b3614022188e388a 100644 --- a/api/jobs/handlers.py +++ b/api/jobs/handlers.py @@ -71,19 +71,26 @@ class GearHandler(base.RequestHandler): gear = get_gear(_id) return suggest_container(gear, cont_name+'s', cid) + # Temporary Function def upload(self): """Upload new gear file""" if not self.user_is_admin: self.abort(403, 'Request requires admin') r = upload.process_upload(self.request, upload.Strategy.gear, container_type='gear', origin=self.origin, metadata=self.request.headers.get('metadata')) - id = upsert_gear(r[1]) - return {'_id': str(id)} + gear_id = upsert_gear(r[1]) + return {'_id': str(gear_id)} + + # Temporary Function + def download(self, **kwargs): + dl_id = kwargs.pop('cid') + return {'_id':str(dl_id)} + def post(self, _id): """Upsert an entire gear document.""" - if not self.user_is_admin: + if not self.superuser_request: self.abort(403, 'Request requires superuser') doc = self.request.json diff --git a/api/upload.py b/api/upload.py index 1cd1c9c97a26517925f23f5bf6a4d0d4193958e7..00d8101c8a6c65f09daf80d71ea8b06d8f8b05c9 100644 --- a/api/upload.py +++ b/api/upload.py @@ -91,8 +91,6 @@ def process_upload(request, strategy, container_type=None, id_=None, origin=None # Non-file form fields may have an empty string as filename, check for 'falsy' values file_fields = [x for x in form if form[x].filename] - # if file_fields: - # return file_fields # TODO: Change schemas to enabled targeted uploads of more than one file. # Ref docs from placer.TargetedPlacer for details. if strategy == Strategy.targeted and len(file_fields) > 1: