Permet la création de compte Crans quand l'objet est un club
This commit is contained in:
parent
2becf821d3
commit
990f791298
1 changed files with 31 additions and 16 deletions
27
objets.py
27
objets.py
|
@ -948,7 +948,6 @@ class proprio(CransLdapObject):
|
|||
return self['uid'][0]
|
||||
|
||||
elif login:
|
||||
fn = crans_utils.strip_accents(unicode(self['prenom'][0]).capitalize())
|
||||
ln = crans_utils.strip_accents(unicode(self['nom'][0]).capitalize())
|
||||
login = crans_utils.strip_spaces(crans_utils.strip_accents(login), by=u'-').lower()
|
||||
if not re.match('^[a-z][-a-z]{1,15}$', login):
|
||||
|
@ -956,16 +955,19 @@ class proprio(CransLdapObject):
|
|||
if crans_utils.mailexist(login):
|
||||
raise ValueError("Login existant ou correspondant à un alias mail.")
|
||||
|
||||
home = u'/home/' + login
|
||||
if self.ldap_name == u'adherent':
|
||||
|
||||
home = u'/home/' + login[0] + '/' + login
|
||||
if os.path.exists(home):
|
||||
raise ValueError('Création du compte impossible : home existant')
|
||||
|
||||
if os.path.exists("/var/mail/" + login):
|
||||
raise ValueError('Création du compte impossible : /var/mail/%s existant' % str(login))
|
||||
if os.path.exists("/home/mail/" + login):
|
||||
raise ValueError('Création du compte impossible : /home/mail/%s existant' % str(login))
|
||||
|
||||
fn = crans_utils.strip_accents(unicode(self['prenom'][0]).capitalize())
|
||||
self._modifs['objectClass'] = [u'adherent', u'cransAccount', u'posixAccount', u'shadowAccount']
|
||||
self['uid'] = [login]
|
||||
self['homeDirectory'] = [home]
|
||||
self['cn'] = [fn + u' ' + ln]
|
||||
self['mail'] = [login + u"@crans.org"]
|
||||
calias = crans_utils.strip_spaces(fn) + u'.' + crans_utils.strip_spaces(ln) + '@crans.org'
|
||||
if crans_utils.mailexist(calias):
|
||||
|
@ -973,7 +975,20 @@ class proprio(CransLdapObject):
|
|||
if crans_utils.mailexist(calias):
|
||||
raise ValueError('Creation impossible, Alias canonique déjà pris, merci de choisir un autre login')
|
||||
self['canonicalAlias'] = [calias]
|
||||
self['cn'] = [fn + u' ' + ln]
|
||||
|
||||
else:
|
||||
# C'est un club
|
||||
home = u'/home/c/' + login
|
||||
if os.path.exists(home):
|
||||
raise ValueError('Création du compte impossible : home existant')
|
||||
if os.path.exists("/home/mail/" + login):
|
||||
raise ValueError('Création du compte impossible : /home/mail/%s existant' % str(login))
|
||||
self._modifs['objectClass'] = [u'club', u'cransAccount', u'posixAccount', u'shadowAccount']
|
||||
self['homeDirectory'] = [home]
|
||||
self['cn'] = [ln]
|
||||
|
||||
# Les attributs communs
|
||||
self['uid'] = [login]
|
||||
self['loginShell'] = [unicode(shell)]
|
||||
if hash_pass:
|
||||
self['userPassword'] = [unicode(hash_pass)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue