mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Do not display primary groups by default when running yunohost user group list
This commit is contained in:
parent
302e755f48
commit
f950378c63
2 changed files with 15 additions and 1 deletions
|
@ -216,6 +216,11 @@ user:
|
||||||
full: --full
|
full: --full
|
||||||
help: Display all informations known about each groups
|
help: Display all informations known about each groups
|
||||||
action: store_true
|
action: store_true
|
||||||
|
-p:
|
||||||
|
full: --include-primary-groups
|
||||||
|
help: Also display primary groups (each user has an eponym group that only contains itself)
|
||||||
|
action: store_true
|
||||||
|
default: false
|
||||||
|
|
||||||
### user_group_create()
|
### user_group_create()
|
||||||
create:
|
create:
|
||||||
|
|
|
@ -488,13 +488,17 @@ def user_info(username):
|
||||||
#
|
#
|
||||||
# Group subcategory
|
# Group subcategory
|
||||||
#
|
#
|
||||||
def user_group_list(short=False, full=False):
|
def user_group_list(short=False, full=False, include_primary_groups=True):
|
||||||
"""
|
"""
|
||||||
List users
|
List users
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
short -- Only list the name of the groups without any additional info
|
short -- Only list the name of the groups without any additional info
|
||||||
full -- List all the info available for each groups
|
full -- List all the info available for each groups
|
||||||
|
include_primary_groups -- Include groups corresponding to users (which should always only contains this user)
|
||||||
|
This option is set to false by default in the action map because we don't want to have
|
||||||
|
these displayed when the user runs `yunohost user group list`, but internally we do want
|
||||||
|
to list them when called from other functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Fetch relevant informations
|
# Fetch relevant informations
|
||||||
|
@ -507,10 +511,15 @@ def user_group_list(short=False, full=False):
|
||||||
|
|
||||||
# Parse / organize information to be outputed
|
# Parse / organize information to be outputed
|
||||||
|
|
||||||
|
users = user_list()["users"]
|
||||||
groups = {}
|
groups = {}
|
||||||
for infos in groups_infos:
|
for infos in groups_infos:
|
||||||
|
|
||||||
name = infos["cn"][0]
|
name = infos["cn"][0]
|
||||||
|
|
||||||
|
if not include_primary_groups and name in users:
|
||||||
|
continue
|
||||||
|
|
||||||
groups[name] = {}
|
groups[name] = {}
|
||||||
|
|
||||||
groups[name]["members"] = [_ldap_path_extract(p, "uid") for p in infos.get("member", [])]
|
groups[name]["members"] = [_ldap_path_extract(p, "uid") for p in infos.get("member", [])]
|
||||||
|
|
Loading…
Add table
Reference in a new issue