diff options
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r-- | ishtar_common/forms_common.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 76e5bbf1e..cc4cf31a8 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -548,8 +548,11 @@ class OrganizationForm(ManageOldType, NewItemForm): form_label = _("Organization") associated_models = { "organization_type": models.OrganizationType, - "precise_town": models.Town, } + format_models = { + "precise_town_id": models.Town, + } + name = forms.CharField(label=_("Name"), max_length=300, validators=[name_validator]) organization_type = forms.ChoiceField(label=_("Organization type"), choices=[]) url = forms.URLField(label=_("Web address"), required=False) @@ -565,7 +568,7 @@ class OrganizationForm(ManageOldType, NewItemForm): ) postal_code = forms.CharField(label=_("Postal code"), max_length=10, required=False) town = forms.CharField(label=_("Town (freeform)"), max_length=30, required=False) - precise_town = get_town_field(required=False) + precise_town_id = get_town_field(required=False) country = forms.CharField(label=_("Country"), max_length=30, required=False) email = forms.EmailField(label=_("Email"), required=False) phone = forms.CharField(label=_("Phone"), max_length=32, required=False) @@ -587,11 +590,11 @@ class OrganizationForm(ManageOldType, NewItemForm): dct["organization_type"] = models.OrganizationType.objects.get( pk=dct["organization_type"] ) - if dct["precise_town"]: + if dct["precise_town_id"]: try: - dct["precise_town"] = models.Town.objects.get(pk=dct["precise_town"]) + dct["precise_town_id"] = models.Town.objects.get(pk=dct["precise_town_id"]).pk except models.Town.DoesNotExist: - dct.pop("precise_town") + dct.pop("precise_town_id") if not item: new_item = models.Organization(**dct) else: @@ -611,7 +614,7 @@ class OrganizationSelect(CustomForm, TableSelect): ) name = forms.CharField(label=_("Name"), max_length=300) organization_type = forms.ChoiceField(label=_("Type"), choices=[]) - precise_town = get_town_field() + precise_town_id = get_town_field() def __init__(self, *args, **kwargs): super(OrganizationSelect, self).__init__(*args, **kwargs) @@ -909,7 +912,9 @@ class SimplePersonForm(ManageOldType, NewItemForm): associated_models = { "attached_to": models.Organization, "title": models.TitleType, - "precise_town": models.Town, + } + format_models = { + "precise_town_id": models.Town, } title = forms.ChoiceField(label=_("Title"), choices=[], required=False) salutation = forms.CharField(label=_("Salutation"), max_length=200, required=False) @@ -950,7 +955,7 @@ class SimplePersonForm(ManageOldType, NewItemForm): ) postal_code = forms.CharField(label=_("Postal code"), max_length=10, required=False) town = forms.CharField(label=_("Town (freeform)"), max_length=30, required=False) - precise_town = get_town_field(required=False) + precise_town_id = get_town_field(required=False) country = forms.CharField(label=_("Country"), max_length=30, required=False) alt_address = forms.CharField( label=_("Other address: address"), widget=forms.Textarea, required=False |