From 651e1c21fa2c2935e74b93e9173c23e2bdaf55b9 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 7 Sep 2023 15:44:24 -0400 Subject: [PATCH 1/5] MVP Fix #208 - add title parameter and support for asking it, not yet printing it out --- docassemble/AssemblyLine/al_general.py | 39 +++++++++++++++++++ .../data/questions/ql_baseline.yml | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index 11bd8be2..2d5da1a0 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -900,6 +900,8 @@ def name_fields( self, person_or_business: str = "person", show_suffix: bool = True, + show_title: bool = False, + title_options: Optional[List[str]] = None, show_if: Union[str, Dict[str, str], None] = None, ) -> List[Dict[str, str]]: """ @@ -911,6 +913,10 @@ def name_fields( Default is "person". show_suffix (bool, optional): Determines if the name's suffix (e.g., Jr., Sr.) should be included in the prompts. Default is True. + show_title: (bool, optional): Determines if the name's title (e.g., Mr., Ms.) should be included in the prompts. + Default is False. + title_options (List[str], optional): A list of title options to use in the prompts. Default is defined as a list + of common titles in English-speaking countries. show_if (Union[str, Dict[str, str], None], optional): Condition to determine which fields to show. It can be a string, a dictionary with conditions, or None. Default is None. @@ -921,6 +927,29 @@ def name_fields( If `person_or_business` is set to None, the method will offer the end user a choice and will set appropriate "show ifs" conditions for each type. """ + if not title_options: + title_options = [ + "Mr.", + "Mrs.", + "Miss", + "Ms.", + "Mx.", + "Dr.", + "Prof.", + "Hon.", + "Rev.", + "Sir", + "Lord", + "Lady", + "Dame", + "Maj.", + "Gen.", + "Capt.", + "Lt.", + "Sgt.", + "Fr.", + "Sr." + ] if person_or_business == "person": fields = [ { @@ -946,6 +975,16 @@ def name_fields( "required": False, } ) + if show_title: + fields.insert( + 0, + { + "label": str(self.name_title_label), + "field": self.attr_name("name.title"), + "choices": title_options, + "required": False, + }, + ) if show_if: for field in fields: field["show if"] = show_if diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index 99c403c8..86c7998a 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -243,6 +243,11 @@ code: | # This helps us keep questions consistent and translated just once --- generic object: ALIndividual +template: x.name_title_label +content: | + Title (optional) +--- +generic object: ALIndividual template: x.first_name_label content: | First name @@ -462,7 +467,7 @@ fields: choices: - users[0].address if defined("users[0].address.address") else None object labeler: | - lambda y: y.on_one_line() + lambda y: y.on_one_line() none of the above: | Somewhere else disable others: True From 01c8745f007aa424ba4b6eca54752052169d5936 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 7 Sep 2023 16:13:42 -0400 Subject: [PATCH 2/5] Progress on #216 --- docassemble/AssemblyLine/al_general.py | 8 ++++---- .../data/questions/ql_baseline.yml | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index 2d5da1a0..6c38a575 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -843,15 +843,15 @@ def contact_methods(self) -> str: """ methods = [] if self.phone_numbers(): - methods.append({self.phone_numbers(): word("by phone at ")}) + methods.append({self.phone_numbers(): str(self.phone_number_contact_label)}) if hasattr(self, "email") and self.email: - methods.append({self.email: word("by email at ")}) + methods.append({self.email: str(self.email_contact_label)}) if hasattr(self, "other_contact_method") and self.other_contact_method: - methods.append({self.other_contact_method: "by "}) + methods.append({self.other_contact_method: str(self.other_contact_method_label)}) return comma_and_list( [ - list(method.values())[0] + list(method.keys())[0] + list(method.values())[0] + " " + list(method.keys())[0] for method in methods if len(method) ], diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index 86c7998a..f6031ae9 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -2314,4 +2314,21 @@ content: | generic object: ALIndividual template: x.pronoun_self_described_label content: | - Self described pronouns \ No newline at end of file + Self described pronouns +--- +############# Contact method strings ################ +--- +generic object: ALIndividual +template: x.phone_number_contact_label +content: | + by phone at +--- +generic object: ALIndividual +template: x.email_contact_label +content: | + by email at +--- +generic object: ALIndividual +template: x.other_contact_method_label +content: | + by \ No newline at end of file From 4431a2e049c14623dbeeeb90018504e1556c6be7 Mon Sep 17 00:00:00 2001 From: nonprofittechy Date: Mon, 11 Sep 2023 13:59:27 +0000 Subject: [PATCH 3/5] :art: Format Python code with psf/black --- docassemble/AssemblyLine/al_general.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index 6c38a575..86b37384 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -847,7 +847,9 @@ def contact_methods(self) -> str: if hasattr(self, "email") and self.email: methods.append({self.email: str(self.email_contact_label)}) if hasattr(self, "other_contact_method") and self.other_contact_method: - methods.append({self.other_contact_method: str(self.other_contact_method_label)}) + methods.append( + {self.other_contact_method: str(self.other_contact_method_label)} + ) return comma_and_list( [ @@ -948,7 +950,7 @@ def name_fields( "Lt.", "Sgt.", "Fr.", - "Sr." + "Sr.", ] if person_or_business == "person": fields = [ From 332951e44243b188c3151b9108f3f85dcecf0406 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 14 Sep 2023 12:53:48 -0400 Subject: [PATCH 4/5] Update docassemble/AssemblyLine/data/questions/ql_baseline.yml Co-authored-by: Bryce Willey --- docassemble/AssemblyLine/data/questions/ql_baseline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index f6031ae9..725a5886 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -2320,7 +2320,7 @@ content: | --- generic object: ALIndividual template: x.phone_number_contact_label -content: | +content: >- by phone at --- generic object: ALIndividual From 4d35464dc6b793693636245613f3648e5e935cf2 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Thu, 14 Sep 2023 12:54:41 -0400 Subject: [PATCH 5/5] Apply suggestions from code review --- docassemble/AssemblyLine/data/questions/ql_baseline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docassemble/AssemblyLine/data/questions/ql_baseline.yml b/docassemble/AssemblyLine/data/questions/ql_baseline.yml index 725a5886..43616450 100644 --- a/docassemble/AssemblyLine/data/questions/ql_baseline.yml +++ b/docassemble/AssemblyLine/data/questions/ql_baseline.yml @@ -2325,10 +2325,10 @@ content: >- --- generic object: ALIndividual template: x.email_contact_label -content: | +content: >- by email at --- generic object: ALIndividual template: x.other_contact_method_label -content: | +content: >- by \ No newline at end of file