UPLOAD_SETTINGS = ['menu_label',
'literal_column_headings',
'trim',
+ 'null',
]
REQUIRED_SETTINGS = []
BOOLEAN_SETTINGS = []
BOOLEAN_CHOICE_SETTINGS = ['literal_column_headings',
- 'trim']
+ 'trim',
+ 'null']
def check_settings(
--- /dev/null
+# Copyright (C) 2021 The Meme Factory, Inc. http://www.karlpinc.com/
+
+# This file is part of Pgwui_Upload_Core.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@karlpinc.com>
+
+'''Utility functions used in templates
+'''
+
+
+def show_choice(pgwui, setting):
+ '''Interpret a boolean_choice setting; should the user interface
+ display something?
+ '''
+ val = pgwui['upload_settings'][setting]
+ return (val == 'choice-yes' or val == 'choice-no')
<%!
+ from pgwui_upload_core.template_utils import show_choice
from pgwui_common.path import asset_abspath
auth_base_mak = asset_abspath('pgwui_common:templates/auth_base.mak')
-
- def show_choice(pgwui, setting):
- val = pgwui['upload_settings'][setting]
- return (val == 'choice-yes' or val == 'choice-no')
%>
<%inherit file="${auth_base_mak}" />
self.component = component
return self
+ def boolean_choice(self, upload_settings, setting):
+ val = upload_settings[setting]
+ # Technically, we only need 'choice-yes' here because
+ # otherwise the result is never displayed on the page.
+ return (val == 'yes-always' or val == 'choice-yes')
+
def build(self, settings={}):
super().build(settings)
upload_settings = settings['pgwui'][self.component]
- self.trim_upload = (
- upload_settings['trim'] == 'choice-yes')
- lch = upload_settings['literal_column_headings']
- self.literal_col_headings = (lch == 'yes-always', 'choice-yes')
+ self.upload_null = self.boolean_choice(upload_settings, 'null')
+ self.trim_upload = self.boolean_choice(upload_settings, 'trim')
+ self.literal_col_headings = self.boolean_choice(
+ upload_settings, 'literal_column_headings')
return self