Skip to content
Snippets Groups Projects
Commit 75c968d6 authored by Megan Henning's avatar Megan Henning
Browse files

Add final fixes/suggestions

parent b6c0e301
No related branches found
No related tags found
No related merge requests found
......@@ -52,13 +52,14 @@ class ContainerStorage(object):
cont = self.get_el(_id, projection=projection)
if get_children:
children = self.get_children(_id, projection=projection)
cont[CHILD_MAP.get(self.cont_name)] = children
cont[CHILD_MAP[self.cont_name]] = children
return cont
def get_children(self, _id, projection=None):
child_name = CHILD_MAP.get(self.cont_name)
if not child_name:
raise ValueError('Children can only be listed from group, project or session level')
try:
child_name = CHILD_MAP[self.cont_name]
except KeyError:
raise APINotFoundException('Children cannot be listed from the {0} level'.format(self.cont_name))
query = {self.cont_name[:-1]: bson.objectid.ObjectId(_id)}
return self.factory(child_name, use_object_id=True).get_all_el(query, None, projection)
......
......@@ -108,7 +108,10 @@ class ListStorage(object):
log.debug('update {}'.format(update))
result = self.dbc.update_one(query, update)
if self.list_name is 'files' and self.cont_name in ['sessions', 'acquisitions']:
session_id = _id if self.cont_name == 'sessions' else AcquisitionStorage().get_container(_id).get('session')
if self.cont_name == 'sessions':
session_id = _id
else:
session_id = AcquisitionStorage().get_container(_id).get('session')
SessionStorage().recalc_session_compliance(session_id)
return result
......
......@@ -499,10 +499,8 @@ class ContainerHandler(base.RequestHandler):
if result.modified_count == 1:
sessions = self.storage.get_children(project_id, projection={'_id':1})
log.debug('sessions are {}'.format(sessions))
session_storage = self.container_handler_configurations['sessions']['storage']
for s in sessions:
log.debug('update session {}'.format(s))
session_storage.exec_op('PUT', s['_id'], payload={'project_has_template': True})
return {'modified': result.modified_count}
else:
......
......@@ -18,8 +18,6 @@ from .dao import containerutil, hierarchy
from .jobs import rules
from .types import Origin
from . import config
log = config.log
class Placer(object):
"""
......
......@@ -34,7 +34,9 @@
schema: !include ../schemas/input/project-template.json
responses:
200:
description: Project's sessions' compliance was recalculated, returns list of
description: |
Project's sessions' compliance was recalculated.
Returns list of session that were modified.
404:
description: Project was not found
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment