implement new task osusers.tasks.delete_ldap_group
This commit is contained in:
parent
cdbaa3ca36
commit
93a27a83aa
1 changed files with 22 additions and 0 deletions
|
@ -217,3 +217,25 @@ def delete_ldap_group_if_empty(groupname):
|
|||
ldapgroup.dn, len(ldapgroup.members))
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
@shared_task
|
||||
def delete_ldap_group(groupname):
|
||||
"""
|
||||
This taks deletes the given group.
|
||||
|
||||
:param str groupname: the group name
|
||||
:return: True if the user has been deleted, False otherwise
|
||||
:rtype: boolean
|
||||
|
||||
"""
|
||||
try:
|
||||
ldapgroup = LdapGroup.objects.get(name=groupname)
|
||||
except LdapGroup.DoesNotExist:
|
||||
_logger.info('ldap group with name {0} does not exist'.format(
|
||||
groupname)
|
||||
)
|
||||
else:
|
||||
ldapgroup.delete()
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue