Added Post multiple groups API

This commit is contained in:
sangramga
2018-03-31 15:42:58 +05:30
parent 5039b3ac6f
commit 9a8457deff

View File

@@ -45,10 +45,12 @@ class GroupListAPIHandler(_GroupAPIHandler):
async def post(self):
"""POST creates Multiple groups """
model = self.get_json_body()
self._check_group_model(model)
if not model or not isinstance(model, dict) or not model.get('groups'):
raise web.HTTPError(400, "Must specify at least one group to create")
groupnames = model.get("groups",[])
groupnames = model.pop("groups",[])
self._check_group_model(model)
created = []
for name in groupnames:
existing = orm.Group.find(self.db, name=name)