summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/forms_common.py8
-rw-r--r--ishtar_common/wizards.py6
2 files changed, 13 insertions, 1 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 67299fbac..e2c0e5db5 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -581,6 +581,7 @@ class AccountForm(forms.Form):
widget=forms.PasswordInput, required=False)
def __init__(self, *args, **kwargs):
+ person = None
if 'initial' in kwargs and 'pk' in kwargs['initial']:
try:
person = models.Person.objects.get(pk=kwargs['initial']['pk'])
@@ -591,7 +592,12 @@ class AccountForm(forms.Form):
kwargs['initial']['email'] = account.email
except ObjectDoesNotExist:
pass
- return super(AccountForm, self).__init__(*args, **kwargs)
+ if 'person' in kwargs:
+ person = kwargs.pop('person')
+ super(AccountForm, self).__init__(*args, **kwargs)
+ if person:
+ self.fields['username'].initial = \
+ person.raw_name.lower().replace(' ', '.')
def clean(self):
cleaned_data = self.cleaned_data
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 5105418a5..c2cd54d03 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -1343,6 +1343,12 @@ class AccountWizard(Wizard):
context_instance=RequestContext(self.request))
return res
+ def get_form_kwargs(self, step=None):
+ kwargs = super(AccountWizard, self).get_form_kwargs(step)
+ if step == 'account-account_management':
+ kwargs['person'] = self.get_current_object()
+ return kwargs
+
def get_form(self, step=None, data=None, files=None):
"""
Display the "Send email" field if necessary