diff --git a/docassemble/AssemblyLine/data/questions/interview_list.yml b/docassemble/AssemblyLine/data/questions/interview_list.yml index ca459a10..f84039c1 100644 --- a/docassemble/AssemblyLine/data/questions/interview_list.yml +++ b/docassemble/AssemblyLine/data/questions/interview_list.yml @@ -116,7 +116,7 @@ metadata: In progress forms short title: | In progress forms - temporary session: True + temporary session: True --- modules: - .sessions @@ -216,14 +216,16 @@ default screen parts: % endif - % if PAGE_TITLE: - ${ PAGE_TITLE } + % if LOGO_TITLE_ROW_1: + ${ LOGO_TITLE_ROW_1 } % elif showifdef("AL_ORGANIZATION_TITLE"): ${ AL_ORGANIZATION_TITLE } % else: - ${ get_config("app name", "CourtFormsOnline") } + ${ get_config("app name", "CourtFormsOnline") } % endif - % if PAGE_QUESTION: + % if LOGO_TITLE_ROW_2: + ${ LOGO_TITLE_ROW_2 } + % elif PAGE_QUESTION: ${ PAGE_QUESTION } % else: ${ all_variables(special='metadata').get('title','').rstrip() } @@ -390,20 +392,6 @@ code: | --- ########### Get customized text values from configuration file ###################################33 --- -code: | - def config_with_language_fallback(config_key, top_level_config_key=None): - interview_list_config = get_config("assembly line",{}).get("interview list",{}) - if interview_list_config.get(config_key): - if isinstance(interview_list_config.get(config_key), dict): - if get_language() in interview_list_config.get(config_key): - return interview_list_config.get(config_key)[get_language()] - else: - return next(iter(interview_list_config.get(config_key).values()), None) - else: - return interview_list_config.get(config_key) - else: - return get_config(top_level_config_key or config_key) ---- code: | PAGE_TITLE = config_with_language_fallback("page title", "interview page title") --- @@ -436,6 +424,5 @@ code: | --- code: | LOGO_TITLE_ROW_2 = config_with_language_fallback("logo title row 2") - --- code: al_sessions_to_exclude_from_interview_list = get_config("assembly line",{}).get("interview list",{}).get("exclude from interview list", get_config("assembly line",{}).get("exclude from interview list")) diff --git a/docassemble/AssemblyLine/sessions.py b/docassemble/AssemblyLine/sessions.py index e7d3af22..1db05f2a 100644 --- a/docassemble/AssemblyLine/sessions.py +++ b/docassemble/AssemblyLine/sessions.py @@ -14,6 +14,7 @@ DASet, format_time, get_config, + get_language, get_default_timezone, get_session_variables, interview_menu, @@ -52,6 +53,7 @@ __all__ = [ "al_session_store_default_filename", + "config_with_language_fallback", "delete_interview_sessions", "export_interview_variables", "get_filtered_session_variables_string", @@ -1270,3 +1272,38 @@ def is_valid_json(json_string: str) -> bool: validation_error("Enter a valid JSON-formatted string") return False return True + +def config_with_language_fallback(config_key:str, top_level_config_key:Optional[str]=None) -> Optional[str]: + """Returns the value of a config key under `assembly line` `interview list` with options to fallback + to an alternative key at the top level of the global configuration. + + Used in interview_list.yml to allow overriding some of the labels in the interview list + with options specified in the global configuration. top_level_config should be reserved + to handle backwards compatibility (e.g., changed location of some configuration keys) + + Example configuration, showing both the single-string and language-specific string options: + assembly line: + interview list: + title: + en: In progress forms + es: Formularios en progreso + short title: My forms + + Args: + config_key (str): The config key to look up. The config can be a single string or a dictionary with language keys. + top_level_config_key (str, optional): Optional, alternative top-level config key to look up. Defaults to None. + + Returns: + str: The value of the config key, or the alternative key, or None. + """ + interview_list_config = get_config("assembly line",{}).get("interview list",{}) + if interview_list_config.get(config_key): + if isinstance(interview_list_config.get(config_key), dict): + if get_language() in interview_list_config.get(config_key): + return interview_list_config.get(config_key)[get_language()] + else: + return next(iter(interview_list_config.get(config_key).values()), None) + else: + return interview_list_config.get(config_key) + else: + return get_config(top_level_config_key or config_key) \ No newline at end of file