Skip to content
Snippets Groups Projects
Commit 0c8b8a6b authored by Renzo Frigato's avatar Renzo Frigato
Browse files

allow tags on groups

parent 035d345f
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,10 @@ routes = [
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:roles>'), listhandler.ListHandler, name='group_roles_post'),
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:roles>/<site:{site_id_re}>/<_id:{user_id_re}>'), listhandler.ListHandler, name='group_roles', methods=['GET', 'PUT', 'DELETE']),
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:tags>'), listhandler.ListHandler, methods=['POST'], name='tags_post'),
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:tags>/<value:{tag_re}>'), listhandler.ListHandler, name='tags'),
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>/<cid:{cid_re}>/<list_name:tags>'), listhandler.ListHandler, methods=['POST'], name='tags_post'),
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>/<cid:{cid_re}>/<list_name:tags>/<value:{tag_re}>'), listhandler.ListHandler, name='tags'),
......
......@@ -52,6 +52,22 @@ def group_roles_sublist(handler, container):
return f
return g
def group_tags_sublist(handler, container):
"""
This is the customized permissions checker for tags operations.
"""
access = _get_access(handler.uid, handler.user_site, container)
def g(exec_op):
def f(method, _id, query_params = None, payload = None, exclude_params=None):
if method == 'GET' and access >= INTEGER_ROLES['ro']:
return exec_op(method, _id, query_params, payload, exclude_params)
elif access >= INTEGER_ROLES['admin']:
return exec_op(method, _id, query_params, payload, exclude_params)
else:
handler.abort(403, 'user not authorized to perform a {} operation on the list'.format(method))
return f
return g
def permissions_sublist(handler, container):
"""
the customized permissions checker for permissions operations.
......
......@@ -67,7 +67,14 @@ def initialize_list_configurations():
'get_full_container': True,
'storage_schema_file': 'permission.json',
'input_schema_file': 'permission.json'
}
},
'tags': {
'storage': liststorage.StringListStorage,
'permchecker': listauth.group_tags_sublist,
'use_object_id': False,
'storage_schema_file': 'tag.json',
'input_schema_file': 'tag.json'
},
},
'projects': copy.deepcopy(container_default_configurations),
'sessions': copy.deepcopy(container_default_configurations),
......
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