Browse Source

r1093@denkpolster: jan | 2008-04-05 18:54:02 +0200

correctly handle empty user lists in sysuser create
  * use prefix + 01 if list of users with prefix is empty (fixes #11)


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@250 a67ec6bc-e5d5-0310-a910-815c51eb3124
master
Jan Dittberner 14 years ago
parent
commit
7152902ff3
  1. 16
      gnuviechadmin/backend/sysuser.py

16
gnuviechadmin/backend/sysuser.py

@ -50,14 +50,18 @@ class SysuserEntity(BackendEntity):
def _get_next_sysusername(self):
prefix = config.get('sysuser', 'nameprefix')
self.logger.debug("looking for next user with prefix %s" % (prefix))
usernames = [user.username for user in \
getenttools.find_user_by_prefix(prefix)]
maxid = max([int(username[len(prefix):]) for username in usernames])
maxid += 2
for number in range(1, maxid):
username = "%s%02d" % (prefix, number)
if not username in usernames:
return username
if usernames:
maxid = max([int(username[len(prefix):]) for username in usernames])
maxid += 2
for number in range(1, maxid):
username = "%s%02d" % (prefix, number)
if not username in usernames:
return username
else:
return "%s%02d" % (prefix, 1)
def _get_default_sysusertype(self):
return 1

Loading…
Cancel
Save