From 4ae7d8707d186d24338dcae5957f37de5869996b Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Mon, 3 Oct 2022 22:38:27 -0400 Subject: [PATCH 1/5] Fix #578 fix #571 - let author filter irrelevant sessions and remove sessions at step 1 by default --- docassemble/AssemblyLine/sessions.py | 41 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/docassemble/AssemblyLine/sessions.py b/docassemble/AssemblyLine/sessions.py index e8a09d9a..9e136b41 100644 --- a/docassemble/AssemblyLine/sessions.py +++ b/docassemble/AssemblyLine/sessions.py @@ -263,6 +263,8 @@ def get_saved_interview_list( offset: int = 0, filename_to_exclude: str = "", exclude_current_filename: bool = True, + exclude_filenames:List[str] = None, + exclude_newly_started_sessions:bool = True, ) -> List[Dict]: """Get a list of saved sessions for the specified filename. If the save_interview_answers function was used to add metadata, the result list will include columns containing the metadata. @@ -305,8 +307,8 @@ def get_saved_interview_list( AND (userdict.filename = :filename OR :filename is null) - AND userdict.filename != :filename_to_exclude - AND userdict.filename != :current_filename + AND (userdict.filename NOT IN :filenames_to_exclude) + AND (NOT :exclude_newly_started_sessions OR num_keys > 1) ORDER BY modtime desc LIMIT :limit OFFSET :offset; @@ -324,6 +326,11 @@ def get_saved_interview_list( current_filename = "" if not filename_to_exclude: filename_to_exclude = "" + if exclude_filenames: + filenames_to_exclude = exclude_filenames + else: + filenames_to_exclude = [] + filenames_to_exclude.extend([current_filename, filename_to_exclude]) if user_id is None: if user_logged_in(): user_id = user_info().id @@ -351,8 +358,8 @@ def get_saved_interview_list( filename=filename, limit=limit, offset=offset, - filename_to_exclude=filename_to_exclude, - current_filename=current_filename, + filenames_to_exclude=tuple(filenames_to_exclude), + exclude_newly_started_sessions=exclude_newly_started_sessions, ) sessions = [] for session in rs: @@ -588,6 +595,8 @@ def session_list_html( metadata_key_name: str = "metadata", filename_to_exclude: str = al_session_store_default_filename, exclude_current_filename: bool = True, + exclude_filenames:List[str] = None, + exclude_newly_started_sessions:bool = True, name_label: str = word("Title"), date_label: str = word("Date modified"), details_label: str = word("Progress"), @@ -598,6 +607,7 @@ def session_list_html( delete_action: str = "interview_list_delete_session", copy_action: str = "interview_list_copy_action", clone_label: str = word("Copy as answer set"), + show_title:bool = True, limit: int = 50, offset: int = 0, ) -> str: @@ -616,6 +626,8 @@ def session_list_html( offset=offset, filename_to_exclude=filename_to_exclude, exclude_current_filename=exclude_current_filename, + exclude_filenames = exclude_filenames, + exclude_newly_started_sessions = exclude_newly_started_sessions, ) if not answers: @@ -680,13 +692,20 @@ def session_list_html( ) table += """""" - table += f""" - - { nice_interview_title(answer) } - {"
" if nice_interview_subtitle(answer) else ""} - { nice_interview_subtitle(answer) if nice_interview_subtitle(answer) else "" } - - """ + if show_title: + table += f""" + + { nice_interview_title(answer) } + {"
" if nice_interview_subtitle(answer) else ""} + { nice_interview_subtitle(answer) if nice_interview_subtitle(answer) else "" } + + """ + else: + table += f""" + + { nice_interview_subtitle(answer) or nice_interview_title(answer) } + + """ table += f""" { local_date(answer.get("modtime")) }
From 4d08199749322c5d8054464edb84295b4d755bf3 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Tue, 4 Oct 2022 10:58:50 -0400 Subject: [PATCH 2/5] Fix #573 Fix #572 --- docassemble/AssemblyLine/data/questions/interview_list.yml | 6 +----- docassemble/AssemblyLine/sessions.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docassemble/AssemblyLine/data/questions/interview_list.yml b/docassemble/AssemblyLine/data/questions/interview_list.yml index c8ae7f60..4a910629 100644 --- a/docassemble/AssemblyLine/data/questions/interview_list.yml +++ b/docassemble/AssemblyLine/data/questions/interview_list.yml @@ -210,16 +210,12 @@ fields: continue button label: | :save: Save changes --- -code: | - rename_interview_answers(user_info().filename, user_info().session, new_name = al_sessions_snapshot_new_label) - log("New name saved", "success") - al_sessions_rename_session = True ---- code: | al_sessions_snapshot_new_label try: rename_interview_answers(action_argument("filename"), action_argument("session"), new_name = al_sessions_snapshot_new_label) log(f"New name saved", "success") + session_page = 0 # Take back to first page where the renamed session will appear except: log("Problem saving new name", "danger") interview_list_rename_action = True diff --git a/docassemble/AssemblyLine/sessions.py b/docassemble/AssemblyLine/sessions.py index 9e136b41..66db6731 100644 --- a/docassemble/AssemblyLine/sessions.py +++ b/docassemble/AssemblyLine/sessions.py @@ -660,7 +660,7 @@ def session_list_html( "arguments": { "session": answer.get("key"), "filename": answer.get("filename"), - "title": answer.get("title") or "", + "title": nice_interview_subtitle(answer), }, }, ] From b418c793adbd610718eb2c0697196b4854c71cd4 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Tue, 4 Oct 2022 11:02:27 -0400 Subject: [PATCH 3/5] reformat with black --- docassemble/AssemblyLine/sessions.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docassemble/AssemblyLine/sessions.py b/docassemble/AssemblyLine/sessions.py index 9e136b41..017eff64 100644 --- a/docassemble/AssemblyLine/sessions.py +++ b/docassemble/AssemblyLine/sessions.py @@ -263,8 +263,8 @@ def get_saved_interview_list( offset: int = 0, filename_to_exclude: str = "", exclude_current_filename: bool = True, - exclude_filenames:List[str] = None, - exclude_newly_started_sessions:bool = True, + exclude_filenames: List[str] = None, + exclude_newly_started_sessions: bool = True, ) -> List[Dict]: """Get a list of saved sessions for the specified filename. If the save_interview_answers function was used to add metadata, the result list will include columns containing the metadata. @@ -595,8 +595,8 @@ def session_list_html( metadata_key_name: str = "metadata", filename_to_exclude: str = al_session_store_default_filename, exclude_current_filename: bool = True, - exclude_filenames:List[str] = None, - exclude_newly_started_sessions:bool = True, + exclude_filenames: List[str] = None, + exclude_newly_started_sessions: bool = True, name_label: str = word("Title"), date_label: str = word("Date modified"), details_label: str = word("Progress"), @@ -607,7 +607,7 @@ def session_list_html( delete_action: str = "interview_list_delete_session", copy_action: str = "interview_list_copy_action", clone_label: str = word("Copy as answer set"), - show_title:bool = True, + show_title: bool = True, limit: int = 50, offset: int = 0, ) -> str: @@ -626,8 +626,8 @@ def session_list_html( offset=offset, filename_to_exclude=filename_to_exclude, exclude_current_filename=exclude_current_filename, - exclude_filenames = exclude_filenames, - exclude_newly_started_sessions = exclude_newly_started_sessions, + exclude_filenames=exclude_filenames, + exclude_newly_started_sessions=exclude_newly_started_sessions, ) if not answers: From da7505c56f558ba2b0232f4769e34adf508e1a9e Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Tue, 4 Oct 2022 11:23:56 -0400 Subject: [PATCH 4/5] Improve #571 - add to global config --- .../AssemblyLine/data/questions/interview_list.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docassemble/AssemblyLine/data/questions/interview_list.yml b/docassemble/AssemblyLine/data/questions/interview_list.yml index 4a910629..97a3ff13 100644 --- a/docassemble/AssemblyLine/data/questions/interview_list.yml +++ b/docassemble/AssemblyLine/data/questions/interview_list.yml @@ -88,6 +88,9 @@ code: | nav.hide() section_in_progress_forms --- +code: | + al_sessions_to_exclude_from_interview_list = get_config("assembly line", {}).get("exclude from interview list") +--- sections: - section_in_progress_forms: In progress forms - section_answer_sets: Answer sets @@ -103,7 +106,7 @@ question: | % endif ${ action_button_html(get_config("assembly line",{}).get("new form url", AL_ORGANIZATION_HOMEPAGE), label="Start a new form", icon="plus-circle", color="primary", size="md") } subquestion: | - % if len(get_saved_interview_list(filename=None, filename_to_exclude=al_session_store_default_filename)) > 0: + % if len(get_saved_interview_list(filename=None, filename_to_exclude=al_session_store_default_filename, exclude_filenames=al_sessions_to_exclude_from_interview_list)) > 0: % if get_config("interview page pre"): ${ get_config("interview page pre") } % else: @@ -111,14 +114,14 @@ subquestion: | documents. % endif - ${ session_list_html(filename=None, limit=20, offset=session_page*20) } + ${ session_list_html(filename=None, limit=20, offset=session_page*20, exclude_filenames=al_sessions_to_exclude_from_interview_list) }