From d32f7e4256e54384b8e45c09274dba656025ccbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 22 Feb 2008 17:57:42 +0000 Subject: [PATCH] Add an external validator to validate that quantity steps can be converted to int Also add "figure" CSS class here git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19474 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../SupplyLine_validateQuantityStepList.xml | 158 ++++++++++++++++++ .../my_purchase_quantity_step_list.xml | 24 ++- .../my_sale_quantity_step_list.xml | 24 ++- bt5/erp5_trade/bt/revision | 2 +- 4 files changed, 201 insertions(+), 7 deletions(-) create mode 100644 bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/SupplyLine_validateQuantityStepList.xml diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/SupplyLine_validateQuantityStepList.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/SupplyLine_validateQuantityStepList.xml new file mode 100644 index 0000000000..08dd5baa74 --- /dev/null +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/SupplyLine_validateQuantityStepList.xml @@ -0,0 +1,158 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Python_magic</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>__ac_local_roles__</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string>"""Validate that all quantity steps are floats.\n +"""\n +for item in editor:\n + try:\n + float(item)\n + except (ValueError, TypeError):\n + return 0\n +return 1\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_owner</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>editor, request</string> </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>2</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>editor</string> + <string>request</string> + <string>_getiter_</string> + <string>item</string> + <string>float</string> + <string>ValueError</string> + <string>TypeError</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>SupplyLine_validateQuantityStepList</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_purchase_quantity_step_list.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_purchase_quantity_step_list.xml index fc6bbcef87..b3c3670489 100644 --- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_purchase_quantity_step_list.xml +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_purchase_quantity_step_list.xml @@ -19,7 +19,7 @@ <dictionary> <item> <key> <string>external_validator_failed</string> </key> - <value> <string>The input failed the external validator.</string> </value> + <value> <string>You did not enter a floating point number.</string> </value> </item> <item> <key> <string>line_too_long</string> </key> @@ -218,7 +218,7 @@ </item> <item> <key> <string>css_class</string> </key> - <value> <string></string> </value> + <value> <string>figure</string> </value> </item> <item> <key> <string>default</string> </key> @@ -240,7 +240,9 @@ </item> <item> <key> <string>external_validator</string> </key> - <value> <string></string> </value> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> </item> <item> <key> <string>extra</string> </key> @@ -319,4 +321,20 @@ </dictionary> </pickle> </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <tuple> + <global name="Method" module="Products.Formulator.MethodField"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>method_name</string> </key> + <value> <string>SupplyLine_validateQuantityStepList</string> </value> + </item> + </dictionary> + </pickle> + </record> </ZopeData> diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_sale_quantity_step_list.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_sale_quantity_step_list.xml index 11ffeb6de6..a317415a36 100644 --- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_sale_quantity_step_list.xml +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Supply_viewFieldLibrary/my_sale_quantity_step_list.xml @@ -19,7 +19,7 @@ <dictionary> <item> <key> <string>external_validator_failed</string> </key> - <value> <string>The input failed the external validator.</string> </value> + <value> <string>You did not enter a floating point number.</string> </value> </item> <item> <key> <string>line_too_long</string> </key> @@ -218,7 +218,7 @@ </item> <item> <key> <string>css_class</string> </key> - <value> <string></string> </value> + <value> <string>figure</string> </value> </item> <item> <key> <string>default</string> </key> @@ -240,7 +240,9 @@ </item> <item> <key> <string>external_validator</string> </key> - <value> <string></string> </value> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> </item> <item> <key> <string>extra</string> </key> @@ -316,4 +318,20 @@ </dictionary> </pickle> </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <tuple> + <global name="Method" module="Products.Formulator.MethodField"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>method_name</string> </key> + <value> <string>SupplyLine_validateQuantityStepList</string> </value> + </item> + </dictionary> + </pickle> + </record> </ZopeData> diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision index 3021b562c4..cb37cb5c1f 100644 --- a/bt5/erp5_trade/bt/revision +++ b/bt5/erp5_trade/bt/revision @@ -1 +1 @@ -184 \ No newline at end of file +186 \ No newline at end of file -- 2.30.9