Commit 092d3674 authored by Jérome Perrin's avatar Jérome Perrin

- keep fast input ordering when creating requirements

- if in the fast input a requirement has no sub requirements, but a description, the description apply to this requirement

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23100 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cfd20daf
...@@ -101,7 +101,8 @@ for requirement_line in listbox:\n ...@@ -101,7 +101,8 @@ for requirement_line in listbox:\n
requirements_items.sort(lambda x, y: cmp(x[\'id\'], y[\'id\']))\n requirements_items.sort(lambda x, y: cmp(x[\'id\'], y[\'id\']))\n
\n \n
clean_requirements = {}\n clean_requirements = {}\n
int_index_dict = dict()\n clean_requirements_key_list = [] # use a list for keys, to keep ordering\n
description_dict = dict()\n
has_1st_level_requirement = False\n has_1st_level_requirement = False\n
has_2nd_level_requirement = False\n has_2nd_level_requirement = False\n
new_1st_level_requirement = None\n new_1st_level_requirement = None\n
...@@ -116,6 +117,9 @@ for requirement_item in requirements_items:\n ...@@ -116,6 +117,9 @@ for requirement_item in requirements_items:\n
else:\n else:\n
has_1st_level_requirement = False\n has_1st_level_requirement = False\n
\n \n
if has_1st_level_requirement:\n
description_dict[new_1st_level_requirement_title] = \'\'\n
\n
# the item has a second level requirement, built it\n # the item has a second level requirement, built it\n
if requirement_item[\'sub_title\'] not in (\'\', None):\n if requirement_item[\'sub_title\'] not in (\'\', None):\n
has_2nd_level_requirement = True\n has_2nd_level_requirement = True\n
...@@ -128,13 +132,18 @@ for requirement_item in requirements_items:\n ...@@ -128,13 +132,18 @@ for requirement_item in requirements_items:\n
else:\n else:\n
has_2nd_level_requirement = False\n has_2nd_level_requirement = False\n
\n \n
if has_2nd_level_requirement == True and new_1st_level_requirement != None:\n if not has_2nd_level_requirement:\n
description_dict[new_1st_level_requirement_title] =\\\n
requirement_item[\'sub_description\']\n
\n
if has_2nd_level_requirement and new_1st_level_requirement != None:\n
new_1st_level_requirement.append(new_2nd_level_feat)\n new_1st_level_requirement.append(new_2nd_level_feat)\n
\n \n
if has_1st_level_requirement == True:\n if has_1st_level_requirement:\n
if clean_requirements.has_key(new_1st_level_requirement_title):\n if clean_requirements.has_key(new_1st_level_requirement_title):\n
new_1st_level_requirement = clean_requirements[new_1st_level_requirement_title] + new_1st_level_requirement\n new_1st_level_requirement = clean_requirements[new_1st_level_requirement_title] + new_1st_level_requirement\n
clean_requirements[new_1st_level_requirement_title] = new_1st_level_requirement\n clean_requirements[new_1st_level_requirement_title] = new_1st_level_requirement\n
clean_requirements_key_list.append(new_1st_level_requirement_title)\n
\n \n
int_index = 0\n int_index = 0\n
if len(destination_obj.contentValues()):\n if len(destination_obj.contentValues()):\n
...@@ -144,11 +153,12 @@ sub_requirement_int_index = 0\n ...@@ -144,11 +153,12 @@ sub_requirement_int_index = 0\n
int_index_step = 10\n int_index_step = 10\n
\n \n
# create requirement objects and sub-requirements\n # create requirement objects and sub-requirements\n
for key in clean_requirements.keys():\n for key in clean_requirements_key_list:\n
int_index += int_index_step\n int_index += int_index_step\n
new_1st_requirement = destination_obj.newContent( portal_type = requirement_type\n new_1st_requirement = destination_obj.newContent( portal_type = requirement_type\n
, title = key\n , title = key\n
, int_index = int_index\n , int_index = int_index\n
, description = description_dict[key]\n
)\n )\n
for second_level in clean_requirements[key]:\n for second_level in clean_requirements[key]:\n
sub_requirement_int_index += 10\n sub_requirement_int_index += 10\n
...@@ -223,8 +233,9 @@ return context.Base_redirect(form_id,\n ...@@ -223,8 +233,9 @@ return context.Base_redirect(form_id,\n
<string>requirement</string> <string>requirement</string>
<string>_write_</string> <string>_write_</string>
<string>clean_requirements</string> <string>clean_requirements</string>
<string>clean_requirements_key_list</string>
<string>dict</string> <string>dict</string>
<string>int_index_dict</string> <string>description_dict</string>
<string>False</string> <string>False</string>
<string>has_1st_level_requirement</string> <string>has_1st_level_requirement</string>
<string>has_2nd_level_requirement</string> <string>has_2nd_level_requirement</string>
......
547 548
\ 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