implement new task osusers.tasks.delete_ldap_group

This commit is contained in:
Jan Dittberner 2014-12-29 15:04:00 +01:00
parent cdbaa3ca36
commit 93a27a83aa

View file

@ -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