From d5037adb458986e5c6b64cf318fe50b6c42934e3 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Thu, 19 Sep 2024 13:30:58 -0500 Subject: [PATCH] Simplify template rendering --- src/pgwui_sql/templates/sql_edit.mak | 19 +++++++++++------- src/pgwui_sql/views/base.py | 30 ++++++++++------------------ 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/pgwui_sql/templates/sql_edit.mak b/src/pgwui_sql/templates/sql_edit.mak index 66d5f1b..7dda16b 100644 --- a/src/pgwui_sql/templates/sql_edit.mak +++ b/src/pgwui_sql/templates/sql_edit.mak @@ -29,9 +29,6 @@ tab_value Value to supply in upload_fmt when tab is checked csv_checked HTML with the state of the csv checkbox tab_checked HTML with the sate of the tab checkbox - one_file_value Value to supply in download_as when "one file" is checked - many_files_value Value to supply in download_as when "many files" - is checked one_file_checked HTML with the state of the "one file" checkbox many_files_checked HTML with the state of the "many files" checkbox include_sql Include SQL in the downloaded results @@ -40,6 +37,14 @@ <%! from pgwui_common.path import asset_abspath + from pgwui_core.constants import ( + CSV_VALUE, + TAB_VALUE, + ) + from pgwui_sql.constants import ( + ONE_FILE_VALUE, + MANY_FILES_VALUE, + ) sql_base_mak = asset_abspath('pgwui_sql:templates/sql_base.mak') %> @@ -164,7 +169,7 @@ id="download_fmt_csv_id" tabindex="${tab_index.val}" type="radio" - value="${csv_value}" + value="${CSV_VALUE}" ${csv_checked | n} /> @@ -173,7 +178,7 @@ id="download_fmt_tab_id" tabindex="${tab_index.val + 1}" type="radio" - value="${tab_value}" + value="${TAB_VALUE}" ${tab_checked | n} /> @@ -190,7 +195,7 @@ id="download_as_one_file_id" tabindex="${tab_index.val}" type="radio" - value="${one_file_value}" + value="${ONE_FILE_VALUE}" ${one_file_checked | n} />