From 7d097f60ce810628d0a42afa7fd0e40fde2e763f Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 1 Dec 2023 10:14:34 -0500 Subject: [PATCH 1/3] Fix issue when filename not provided --- .../ALDashboard/data/questions/list_sessions.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docassemble/ALDashboard/data/questions/list_sessions.yml b/docassemble/ALDashboard/data/questions/list_sessions.yml index 82739c2..762d833 100644 --- a/docassemble/ALDashboard/data/questions/list_sessions.yml +++ b/docassemble/ALDashboard/data/questions/list_sessions.yml @@ -31,7 +31,7 @@ fields: speedy_get_users() - Filter out interviews that are on the first page: filter_step1 required: False - datatype: yesno + datatype: yesno default: True --- # next((item.get('title') for item in interviews if item.get('filename') == interview['filename']), interview['filename'] ) @@ -42,7 +42,11 @@ code: | mandatory: True event: load_answer question: | + % if filename: Recently started sessions for ${ interviews.get(filename, {"title": filename}).get('title', filename) } + % else: + Recently started sessions for ${ chosen_user or "all users"} + % endif subquestion: | @@ -59,6 +63,10 @@ subquestion: | @@ -67,7 +75,7 @@ subquestion: |  Join
-  Vars +  Vars % endfor @@ -76,4 +84,4 @@ question back button: True --- event: view_session_variables code: | - response(binaryresponse=json.dumps(dashboard_get_session_variables(session_id=action_argument('session_id'), filename=filename)).encode('utf-8'), content_type="application/json", response_code=200) \ No newline at end of file + response(binaryresponse=json.dumps(dashboard_get_session_variables(session_id=action_argument('session_id'), filename=action_argument('filename'))).encode('utf-8'), content_type="application/json", response_code=200) \ No newline at end of file From 949bc410be39bd1176ad1784f5c3fa70239adfbd Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 1 Dec 2023 10:22:35 -0500 Subject: [PATCH 2/3] Tweak indentation --- .../ALDashboard/data/questions/list_sessions.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docassemble/ALDashboard/data/questions/list_sessions.yml b/docassemble/ALDashboard/data/questions/list_sessions.yml index 762d833..3620d07 100644 --- a/docassemble/ALDashboard/data/questions/list_sessions.yml +++ b/docassemble/ALDashboard/data/questions/list_sessions.yml @@ -62,11 +62,11 @@ subquestion: | % for interview in sessions_list: From 93357282f23c4cc9e722c81c4ee74995228fafaf Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Fri, 1 Dec 2023 12:14:10 -0500 Subject: [PATCH 3/3] Fix issues with text breaking making it impossible to click links under 'actions' --- docassemble/ALDashboard/aldashboard.py | 20 +++++++++++++++++++ .../data/questions/list_sessions.yml | 12 ++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docassemble/ALDashboard/aldashboard.py b/docassemble/ALDashboard/aldashboard.py index 3405934..4178b52 100644 --- a/docassemble/ALDashboard/aldashboard.py +++ b/docassemble/ALDashboard/aldashboard.py @@ -56,6 +56,7 @@ "install_fonts", "list_installed_fonts", "dashboard_get_session_variables", + "nicer_interview_filename", ] @@ -327,3 +328,22 @@ def list_installed_fonts(): # From server.py # subq = db.session.query(db.func.max(UserDict.indexno).label('indexno'), UserDict.filename, UserDict.key).group_by(UserDict.filename, UserDict.key).subquery() # interview_query = db.session.query(UserDictKeys.user_id, UserDictKeys.temp_user_id, UserDictKeys.filename, UserDictKeys.key, UserDict.dictionary, UserDict.encrypted, UserModel.email).join(subq, and_(subq.c.filename == UserDictKeys.filename, subq.c.key == UserDictKeys.key)).join(UserDict, and_(UserDict.indexno == subq.c.indexno, UserDict.key == UserDictKeys.key, UserDict.filename == UserDictKeys.filename)).join(UserModel, UserModel.id == UserDictKeys.user_id).filter(UserDictKeys.user_id == user_id, UserDictKeys.filename == filename, UserDictKeys.key == session).group_by(UserModel.email, UserDictKeys.user_id, UserDictKeys.temp_user_id, UserDictKeys.filename, UserDictKeys.key, UserDict.dictionary, UserDict.encrypted, UserDictKeys.indexno).order_by(UserDictKeys.indexno) + +def nicer_interview_filename(filename: str) -> str: + """ + Given a filename like docassemble.playground10ALWeaver:data/questions/assembly_line.yml, + return a less cluttered name like: playground10ALWeaver:assembly_line + """ + filename_parts = filename.split(":") + + # Fixing the slicing for the first part of the filename + if filename_parts[0].startswith("docassemble."): + filename_parts[0] = filename_parts[0][len("docassemble."):] + + # Check if there are two parts and modify the second part + if len(filename_parts) > 1: + if filename_parts[1].startswith("data/questions/"): + filename_parts[1] = filename_parts[1][len("data/questions/"):] + return f"{filename_parts[0]}:{filename_parts[1].replace('.yml', '')}" + + return filename_parts[0] diff --git a/docassemble/ALDashboard/data/questions/list_sessions.yml b/docassemble/ALDashboard/data/questions/list_sessions.yml index 3620d07..bff7d78 100644 --- a/docassemble/ALDashboard/data/questions/list_sessions.yml +++ b/docassemble/ALDashboard/data/questions/list_sessions.yml @@ -43,9 +43,11 @@ mandatory: True event: load_answer question: | % if filename: - Recently started sessions for ${ interviews.get(filename, {"title": filename}).get('title', filename) } + Recently started sessions for ${ nicer_interview_filename(interviews.get(filename, {"title": filename}).get('title', filename)) } + % elif chosen_user: + Recently started sessions for User ID ${ chosen_user} % else: - Recently started sessions for ${ chosen_user or "all users"} + Recently started sessions for all users % endif subquestion: |
${ interview.key } + % if not filename: +
+ ${ interview.filename } + % endif
${ interview.user_id } ${ format_date(interview.modtime, "MMM d YYYY") }
- ${ interview.key } - % if not filename: -
- ${ interview.filename } - % endif + ${ interview.key } + % if not filename: +
+ ${ interview.filename } + % endif
${ interview.user_id } ${ format_date(interview.modtime, "MMM d YYYY") }
@@ -61,11 +63,11 @@ subquestion: | % for interview in sessions_list: - @@ -84,4 +86,4 @@ question back button: True --- event: view_session_variables code: | - response(binaryresponse=json.dumps(dashboard_get_session_variables(session_id=action_argument('session_id'), filename=action_argument('filename'))).encode('utf-8'), content_type="application/json", response_code=200) \ No newline at end of file + response(binaryresponse=json.dumps(dashboard_get_session_variables(session_id=action_argument('session_id'), filename=action_argument('filename'))).encode('utf-8'), content_type="application/json", response_code=200)
+ ${ interview.key } % if not filename:
- ${ interview.filename } + ${ nicer_interview_filename(interview.filename) } % endif
${ interview.user_id }