From 66c9ea3d435f98d417fcf56da01e6d20ff383ec3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 1 Mar 2023 17:31:44 +0100 Subject: Search - Account: add "profile type" field --- CHANGES.md | 1 + ishtar_common/forms_common.py | 13 ++++++++----- ishtar_common/models.py | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3083fc4c9..19a06b447 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,7 @@ Ishtar changelog - add created before/after field - Operation: add "old code" field - Find: add "remain" field (operations and sites) + - Account: add "profile type" field - Free text search: - use accent and unaccented string - add french_archeo thesaurus config diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index f14799f53..4286ae9fd 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -783,11 +783,10 @@ class PersonSelect(CustomForm, TableSelect): ), validators=[models.valid_id(models.Organization)], ) - - def __init__(self, *args, **kwargs): - super(PersonSelect, self).__init__(*args, **kwargs) - self.fields["person_types"].choices = models.PersonType.get_types() - self.fields["title"].choices = models.TitleType.get_types() + TYPES = [ + FieldType("person_types", models.PersonType), + FieldType("title", models.TitleType), + ] class PersonFormSelection(CustomFormSearch): @@ -963,6 +962,10 @@ class SimplePersonForm(ManageOldType, NewItemForm): class PersonUserSelect(PersonSelect): ishtaruser__isnull = forms.NullBooleanField(label=_("Already has an account")) + profiles__profile_type = forms.ChoiceField(label=_("Profile type"), choices=[]) + TYPES = [ + FieldType("profiles__profile_type", models.ProfileType), + ] class PersonUserFormSelection(PersonFormSelection): diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 096a5e0a7..80a6a9141 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2808,6 +2808,10 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem): pgettext_lazy("key for text search", "has-account"), "ishtaruser__isnull", ), + "profiles__profile_type": SearchAltName( + pgettext_lazy("key for text search", "profile-type"), + "profiles__profile_type__label__iexact", + ), } QA_EDIT = QuickAction( url="person-qa-bulk-update", -- cgit v1.2.3