diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-06 15:52:40 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-06 15:52:40 +0200 | 
| commit | e2027c3b2c4bcc2356ec06b5fb6dc8d5bf780e50 (patch) | |
| tree | ced06e4a3e0ef4600d2dbbf2741f001125c162bf /ishtar_common/forms_common.py | |
| parent | 180d93d47cfae279ef927ea5fa736fa1fc37c553 (diff) | |
| parent | b7a7183cdb07c7782abac7fe01d86cc2beb1411e (diff) | |
| download | Ishtar-e2027c3b2c4bcc2356ec06b5fb6dc8d5bf780e50.tar.bz2 Ishtar-e2027c3b2c4bcc2356ec06b5fb6dc8d5bf780e50.zip | |
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common/forms_common.py')
| -rw-r--r-- | ishtar_common/forms_common.py | 21 | 
1 files changed, 16 insertions, 5 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 2788283db..560a1abb3 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -261,6 +261,8 @@ class SimplePersonForm(ManageOldType, NewItemForm):      associated_models = {'attached_to': models.Organization,                           'title': models.TitleType}      title = forms.ChoiceField(label=_("Title"), choices=[]) +    salutation = forms.CharField(label=_("Salutation"), max_length=200, +                                 required=False)      surname = forms.CharField(label=_(u"Surname"), max_length=50,                                validators=[name_validator])      name = forms.CharField(label=_(u"Name"), max_length=200, @@ -363,14 +365,14 @@ class AccountFormSelection(forms.Form):  class BasePersonForm(forms.ModelForm):      class Meta:          model = models.Person -        fields = ['title', 'name', 'surname', 'address', 'address_complement', -                  'town', 'postal_code'] +        fields = ['title', 'salutation', 'name', 'surname', 'address', +                  'address_complement', 'town', 'postal_code']  class BaseOrganizationPersonForm(forms.ModelForm):      class Meta:          model = models.Person -        fields = ['attached_to', 'title', 'name', 'surname'] +        fields = ['attached_to', 'title', 'salutation', 'name', 'surname']          widgets = {'attached_to': widgets.JQueryPersonOrganization(              reverse_lazy('autocomplete-organization'),              reverse_lazy('organization_create'), @@ -412,8 +414,17 @@ class PersonForm(SimplePersonForm):          dct = self.cleaned_data          dct['history_modifier'] = user          if 'attached_to' in dct and dct['attached_to']: -            dct['attached_to'] = models.Organization.objects.get( -                pk=dct['attached_to']) +            try: +                dct['attached_to'] = models.Organization.objects.get( +                    pk=dct['attached_to']) +            except models.Organization.DoesNotExist: +                dct.pop('attached_to') +        if 'title' in dct and dct['title']: +            try: +                dct['title'] = models.TitleType.objects.get( +                    pk=dct['title']) +            except models.TitleType.DoesNotExist: +                dct.pop('title')          person_types = dct.pop('person_types')          new_item = models.Person.objects.create(**dct)          for pt in person_types: | 
