Commit 3c05692e authored by root's avatar root

[enh] Automatic choice for username

parent 8b2bb72f
......@@ -29,8 +29,25 @@ class ExternalAccountConfiguration(Configuration):
def convert_to_dict_for_hook(self):
d = super(ExternalAccountConfiguration, self).convert_to_dict_for_hook()
d["login"] = self.login
d['mail'] = self.offersubscription.member.email
d["firstname"] = 'Asso'
if self.offersubscription.member.first_name:
d["firstname"] = self.offersubscription.member.first_name
d["lastname"] = self.offersubscription.member.organization_name
if self.offersubscription.member.last_name:
d["lastname"] = self.offersubscription.member.last_name
return d
def save(self, **kwargs):
if self.login == '':
login = self.offersubscription.member.username.lower()
self.login = login
i=2
while ExternalAccountConfiguration.objects.filter(login=self.login).count() > 0:
self.login = login + str(i)
i += 1
config = super(Configuration, self).save(**kwargs)
return config
class Meta:
verbose_name = 'Compte externe'
verbose_name_plural = 'Comptes externe'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment