summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/forms_common.py43
-rw-r--r--ishtar_common/templates/ishtar/wizard/wizard_person.html5
-rw-r--r--ishtar_common/views.py6
3 files changed, 17 insertions, 37 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 8529e0c24..6a8db2693 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1155,6 +1155,7 @@ class SimplePersonForm(ManageOldType, NewItemForm):
associated_models = {
"attached_to": models.Organization,
"title": models.TitleType,
+ "person_types": models.PersonType, # already set for subclass
}
format_models = {
"precise_town_id": models.Town,
@@ -1217,13 +1218,13 @@ class SimplePersonForm(ManageOldType, NewItemForm):
alt_country = forms.CharField(
label=_("Other address: country"), max_length=30, required=False
)
+ TYPES = [
+ FieldType("title", models.TitleType),
+ ]
def __init__(self, *args, **kwargs):
- super(SimplePersonForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
self.fields["raw_name"].widget.attrs["readonly"] = True
- self.fields["title"].choices = models.TitleType.get_types(
- initial=self.init_data.get("title")
- )
class PersonUserSelect(PersonSelect):
@@ -1355,25 +1356,24 @@ class BaseOrganizationPersonForm(forms.ModelForm):
class PersonForm(SimplePersonForm):
person_types = forms.MultipleChoiceField(
- label=_("Person type"),
+ label=_("Person types"),
choices=[],
required=False,
- widget=forms.CheckboxSelectMultiple,
+ widget=widgets.Select2Multiple,
)
+ TYPES = SimplePersonForm.TYPES + [
+ FieldType("person_types", models.PersonType, True)
+ ]
def __init__(self, *args, **kwargs):
- super(PersonForm, self).__init__(*args, **kwargs)
- self.fields["person_types"].choices = models.PersonType.get_types(
- initial=self.init_data.get("person_types"), empty_first=False
- )
- self.fields["person_types"].help_text = models.PersonType.get_help()
+ super().__init__(*args, **kwargs)
self.limit_fields()
def save(self, user, item=None):
dct = self.cleaned_data
dct["history_modifier"] = user
for key in self.associated_models.keys():
- if key in dct:
+ if key in dct and key != "person_types":
if not dct[key]:
dct.pop(key)
else:
@@ -1402,25 +1402,6 @@ class NoOrgaPersonForm(PersonForm):
self.fields.pop("attached_to")
-class PersonTypeForm(ManageOldType, forms.Form):
- form_label = _("Person type")
- base_model = "person_type"
- associated_models = {"person_type": models.PersonType}
- person_type = forms.MultipleChoiceField(
- label=_("Person type"),
- choices=[],
- required=False,
- widget=widgets.Select2Multiple,
- )
-
- def __init__(self, *args, **kwargs):
- super(PersonTypeForm, self).__init__(*args, **kwargs)
- self.fields["person_type"].choices = models.PersonType.get_types(
- initial=self.init_data.get("person_type"), empty_first=False
- )
- self.fields["person_type"].help_text = models.PersonType.get_help()
-
-
class BiographicalNoteForm(CustomForm, ManageOldType, NewItemForm):
form_label = _("Biographical note")
form_admin_name = _("Biographical note - 010 - General")
diff --git a/ishtar_common/templates/ishtar/wizard/wizard_person.html b/ishtar_common/templates/ishtar/wizard/wizard_person.html
index b760c027f..ed4100cb4 100644
--- a/ishtar_common/templates/ishtar/wizard/wizard_person.html
+++ b/ishtar_common/templates/ishtar/wizard/wizard_person.html
@@ -21,11 +21,12 @@
<div class="card-body form-row">
{% bs_field wizard.form.surname 1 %}
{% bs_field wizard.form.name 1 %}
+ {% bs_field wizard.form.person_types %}
+ {% bs_field wizard.form.raw_name %}
{% bs_field wizard.form.title %}
{% bs_field wizard.form.salutation %}
- {% bs_field wizard.form.raw_name %}
- {% bs_field wizard.form.email %}
{% bs_field wizard.form.attached_to %}
+ {% bs_field wizard.form.email %}
</div>
</div>
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 69e93a24f..4c83fd818 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -359,8 +359,7 @@ person_search_wizard = wizards.PersonSearch.as_view(
person_creation_wizard = wizards.PersonWizard.as_view(
[
- ("identity-person_creation", forms.SimplePersonForm),
- ("person_type-person_creation", forms.PersonTypeForm),
+ ("identity-person_creation", forms.PersonForm),
("final-person_creation", FinalForm),
],
label=_("New person"),
@@ -370,8 +369,7 @@ person_creation_wizard = wizards.PersonWizard.as_view(
person_modification_wizard = wizards.PersonModifWizard.as_view(
[
("selec-person_modification", forms.PersonFormSelection),
- ("identity-person_modification", forms.SimplePersonForm),
- ("person_type-person_creation", forms.PersonTypeForm),
+ ("identity-person_modification", forms.PersonForm),
("final-person_modification", FinalForm),
],
label=_("Person modification"),