Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/handlers/collectionshandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .. import config
from ..auth import containerauth, always_ok
from ..dao import containerstorage
from ..dao import APIStorageException

from containerhandler import ContainerHandler

Expand Down
7 changes: 4 additions & 3 deletions api/handlers/containerhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ def put(self, cont_name, **kwargs):
if target_parent_container:
if cont_name == 'sessions':
payload['group'] = target_parent_container['group']
payload['permissions'] = target_parent_container.get('roles')
if payload['permissions'] is None:
payload['permissions'] = target_parent_container['permissions']
if cont_name == 'projects':
payload['permissions'] = target_parent_container.get('roles', [])
else:
payload['permissions'] = target_parent_container.get('permissions', [])

payload['modified'] = datetime.datetime.utcnow()
if payload.get('timestamp'):
Expand Down
1 change: 1 addition & 0 deletions api/handlers/grouphandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def post(self):
payload_validator = validators.payload_from_schema_file(self, 'group.json')
payload_validator(payload, 'POST')
payload['created'] = payload['modified'] = datetime.datetime.utcnow()
payload['roles'] = [{'_id': self.uid, 'access': 'admin', 'site': self.user_site}]
result = mongo_validator(permchecker(self.storage.exec_op))('POST', payload=payload)
if result.acknowledged:
return {'_id': result.inserted_id}
Expand Down
2 changes: 1 addition & 1 deletion api/handlers/listhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _initialize_request(self, cont_name, list_name, _id, query_params=None):
else:
self.abort(404, 'Element {} not found in container {}'.format(_id, storage.cont_name))
mongo_validator = validators.mongo_from_schema_file(self, config.get('storage_schema_file'))
input_validator = validators.payload_from_schema_file(self, config.get('payload_schema_file'))
input_validator = validators.payload_from_schema_file(self, config.get('input_schema_file'))
keycheck = validators.key_check(self, config.get('storage_schema_file'))
return container, permchecker, storage, mongo_validator, input_validator, keycheck

Expand Down
1 change: 1 addition & 0 deletions api/schemas/input/acquisition.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"timestamp": {"type": "string"},
"timezone": {"type": "string"}
},
"required": ["label"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add minLength=1 for label

"additionalProperties": false
}
1 change: 1 addition & 0 deletions api/schemas/input/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

"curator": {"type": "string"}
},
"required": ["label"],
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion api/schemas/input/container.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"properties": {
"_id": {"type": "string"},
"public": {"type": "boolean"},
"label": {"type": "string"},
"label": {"type": "string", "minLength": 1, "maxLength": 256},
"metadata": {"type": "object"}
}
}
2 changes: 0 additions & 2 deletions api/schemas/input/file.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"type": "object",
"properties": {
"name": { "type": "string" },
"created": {"type": "string", "format": "date-time"},
"modified": {"type": "string", "format": "date-time"},
"type": { "type": "string" },
"size": { "type": "integer" },
"hash": { "type": "string" },
Expand Down
1 change: 1 addition & 0 deletions api/schemas/input/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

"group": {"type": "string"}
},
"required": ["label"],
"additionalProperties": false
}
1 change: 1 addition & 0 deletions api/schemas/input/session.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"timezone": {"type": "string"},
"subject": {"$ref": "subject.json"}
},
"required": ["label"],
"additionalProperties": false
}