Skip to content

Commit e6ae243

Browse files
committed
add "admins" subgroup to each product, NOTE: This does not mean anything for RASENMAEHER etc, no-one is auto-assigned to the admins group and products need to be separately configured to use it for something
1 parent 19f21d6 commit e6ae243

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/rasenmaeher_api/kchelpers.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,16 @@ async def ensure_product_groups(self) -> Optional[bool]:
210210
subgroups_by_name: Dict[str, Dict[str, Any]] = {
211211
subgroup["name"]: subgroup for subgroup in group["subGroups"]
212212
}
213-
subgrpname = f"{productname}_default"
214-
if subgrpname not in subgroups_by_name:
215-
LOGGER.info("Creating KC group /{}/{}".format(productname, subgrpname))
216-
new_id = await self.kcadmin.a_create_group({"name": subgrpname}, parent=group["id"])
217-
subgroups_by_name[subgrpname] = await self.kcadmin.a_get_group(new_id)
218-
created = True
219-
if self._product_initial_grps is None:
220-
self._product_initial_grps = {}
221-
self._product_initial_grps[productname] = subgroups_by_name[subgrpname]
213+
for suffix in ("default", "admins"):
214+
subgrpname = f"{productname}_{suffix}"
215+
if subgrpname not in subgroups_by_name:
216+
LOGGER.info("Creating KC group /{}/{}".format(productname, subgrpname))
217+
new_id = await self.kcadmin.a_create_group({"name": subgrpname}, parent=group["id"])
218+
subgroups_by_name[subgrpname] = await self.kcadmin.a_get_group(new_id)
219+
created = True
220+
if self._product_initial_grps is None:
221+
self._product_initial_grps = {}
222+
if suffix == "default":
223+
self._product_initial_grps[productname] = subgroups_by_name[subgrpname]
222224
LOGGER.debug("Product initial KC groups: {}".format(self._product_initial_grps))
223225
return created

0 commit comments

Comments
 (0)