Add Flask interview list endpoint - #1104
rajeswari1301 wants to merge 9 commits into
Conversation
nonprofittechy
left a comment
There was a problem hiding this comment.
Minor nits. Biggest question to consider: should this definitely use HTML encoded into the file? An alternative is to use a traditional external HTML template. You'd need to load it in as a string though given that Docassemble only looks for Flask templates in one hardcoded folder.
Thank you for the review! I fixed the CSS and package name. Right now, the page wrapper currently uses a separate file. Registering the package's template folder directly with flask would be the fix rather than another workaround, but that would mean updating every link on the page and handling the check that stops this route from loading twice |
ff02b62 to
fe71015
Compare
We cannot register the package's template folder. But we can put templates in the data/sources or data/templates folder, and read them in as a string using a normal filesystem operation. I think that would be more readable and maintainable than hardcoding the template in the Python module. What do you think? |
|
Expanding on the suggestion to move the HTML out of Proposed implementation plan
The end state I have in mind is: Python handles auth/request/data/mutations; Jinja handles layout and conditional presentation; CSS handles styling. That should make this endpoint considerably easier to review and maintain while keeping the current docassemble/Flask constraints intact. |
Moved the page's HTML out of Python and into the Jinja template. The route now just hands the template the data it needs - session info, config, page and search state and lets Jinja render it, with its autoescaping doing the job manual escape() calls used to do. Also moved the template file into data/templates and added tests covering the empty list, normal rows, search and pagination, the answer-sets toggle, and escaping of session titles.
Thanks for the thorough review and suggestion! I checked the existing conventions in this repo, and since ALDashboard already stores full-page templates in data/templates, I moved the HTML out of the python module and into 'data/templates/al_interview_list_page.html'. I also refactored the helper functions, updated the tests to cover the rendered template, it's ready for another look whenever you have a chance. Thanks again! |
Replaced the redundant session query in interview_list.yml, which was executing 2–3 times per page load and now runs only once, tested it at 50 - 2375 saved sessions - and it was about about 2-3 times faster each time, getting better the bigger the list gets.
It supports all the same features - viewing, searching, renaming, deleting, copying, and paging through results and pulls its settings from the same config the old page already uses.
#1102