Commit 55d6036b authored by Vincent Pelletier's avatar Vincent Pelletier

Validate check reference length in fast input.

Fix reference generation at check generation time.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14325 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cd064361
...@@ -110,6 +110,11 @@ def convertTravelerCheckReferenceToInt(traveler_check_reference):\n ...@@ -110,6 +110,11 @@ def convertTravelerCheckReferenceToInt(traveler_check_reference):\n
raise ValueError\n raise ValueError\n
return int(traveler_check_reference[4:])\n return int(traveler_check_reference[4:])\n
\n \n
def convertCheckReferenceToInt(check_reference):\n
if len(check_reference) != 8:\n
raise ValueError, \'Check reference must be 8-char long.\'\n
return int(check_reference)\n
\n
# listbox is not passed at the first time when this script is called.\n # listbox is not passed at the first time when this script is called.\n
# when the user clicks on the Update button, listbox is passed, and\n # when the user clicks on the Update button, listbox is passed, and\n
# the contents must be preserved in the form.\n # the contents must be preserved in the form.\n
...@@ -156,8 +161,8 @@ else:\n ...@@ -156,8 +161,8 @@ else:\n
convert_func = convertTravelerCheckReferenceToInt\n convert_func = convertTravelerCheckReferenceToInt\n
value_denomination = \'traveler check reference\'\n value_denomination = \'traveler check reference\'\n
else:\n else:\n
convert_func = int\n convert_func = convertCheckReferenceToInt\n
value_denomination = \'number\'\n value_denomination = \'check reference\'\n
try:\n try:\n
reference_range_min = convert_func(reference_range_min)\n reference_range_min = convert_func(reference_range_min)\n
except ValueError:\n except ValueError:\n
...@@ -269,6 +274,7 @@ else:\n ...@@ -269,6 +274,7 @@ else:\n
<string>field_error_dict</string> <string>field_error_dict</string>
<string>generate_error</string> <string>generate_error</string>
<string>convertTravelerCheckReferenceToInt</string> <string>convertTravelerCheckReferenceToInt</string>
<string>convertCheckReferenceToInt</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>range</string> <string>range</string>
<string>i</string> <string>i</string>
......
...@@ -77,11 +77,12 @@ def getReference(reference):\n ...@@ -77,11 +77,12 @@ def getReference(reference):\n
# First convert to float to avoid failing to convert if reference = \'1.0\'\n # First convert to float to avoid failing to convert if reference = \'1.0\'\n
return int(float(reference))\n return int(float(reference))\n
\n \n
def generateReference(reference, ignored):\n def generateReference(reference, original_reference):\n
"""\n """\n
Convert an int into a reference\n Convert an int into a reference of correct length\n
"""\n """\n
return str(reference)\n reference = str(reference)\n
return \'%s%s\' % (\'0\' * (len(original_reference) - len(reference)), reference)\n
\n \n
def validateTravelerCheckReferenceFormat(traveler_check_reference):\n def validateTravelerCheckReferenceFormat(traveler_check_reference):\n
"""\n """\n
......
173 175
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment