Commit e2a55d8e authored by Jérome Perrin's avatar Jérome Perrin

set an int index on created lines.

redirect properly (view name was omitted)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23098 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 610e7ab6
......@@ -81,7 +81,7 @@ if context_obj.getPortalType() == requirement_module_type:\n
elif context_obj.getPortalType() in (requirement_document_type, requirement_type):\n
destination_obj = context_obj\n
else:\n
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_status_message=Error:+bad+context.\')\n
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'/view?portal_status_message=Error:+bad+context.\')\n
\n
# this list contain all requirements items\n
requirements_items = []\n
......@@ -101,6 +101,7 @@ for requirement_line in listbox:\n
requirements_items.sort(lambda x, y: cmp(x[\'id\'], y[\'id\']))\n
\n
clean_requirements = {}\n
int_index_dict = dict()\n
has_1st_level_requirement = False\n
has_2nd_level_requirement = False\n
new_1st_level_requirement = None\n
......@@ -114,7 +115,7 @@ for requirement_item in requirements_items:\n
new_1st_level_requirement_title = requirement_item[\'title\']\n
else:\n
has_1st_level_requirement = False\n
\n
\n
# the item has a second level requirement, built it\n
if requirement_item[\'sub_title\'] not in (\'\', None):\n
has_2nd_level_requirement = True\n
......@@ -135,19 +136,31 @@ for requirement_item in requirements_items:\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
\n
int_index = 0\n
if len(destination_obj.contentValues()):\n
int_index = max([req.getIntIndex() for req in destination_obj.contentValues()])\n
\n
sub_requirement_int_index = 0\n
int_index_step = 10\n
\n
# create requirement objects and sub-requirements\n
for key in clean_requirements.keys():\n
int_index += int_index_step\n
new_1st_requirement = destination_obj.newContent( portal_type = requirement_type\n
, title = key\n
, int_index = int_index\n
)\n
for second_level in clean_requirements[key]:\n
sub_requirement_int_index += 10\n
new_2nd_requirement = new_1st_requirement.newContent( portal_type = requirement_type\n
, title = second_level[\'title\']\n
, description = second_level[\'description\']\n
, int_index = sub_requirement_int_index\n
)\n
\n
# return to the requirement module\n
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_status_message=Requirement+document+added.\')\n
# return to the requirement\n
translateString = context.Base_translateString\n
return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=translateString(\'Requirement document added.\')))\n
</string> </value>
</item>
<item>
......@@ -164,7 +177,7 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_stat
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=[], **kw</string> </value>
<value> <string>listbox=[], form_id=\'view\', **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -184,13 +197,14 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_stat
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>listbox</string>
<string>form_id</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
......@@ -209,6 +223,8 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_stat
<string>requirement</string>
<string>_write_</string>
<string>clean_requirements</string>
<string>dict</string>
<string>int_index_dict</string>
<string>False</string>
<string>has_1st_level_requirement</string>
<string>has_2nd_level_requirement</string>
......@@ -218,10 +234,20 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_stat
<string>True</string>
<string>new_1st_level_requirement_title</string>
<string>new_2nd_level_feat</string>
<string>int_index</string>
<string>len</string>
<string>max</string>
<string>append</string>
<string>$append0</string>
<string>req</string>
<string>sub_requirement_int_index</string>
<string>int_index_step</string>
<string>key</string>
<string>_inplacevar_</string>
<string>new_1st_requirement</string>
<string>second_level</string>
<string>new_2nd_requirement</string>
<string>translateString</string>
</tuple>
</value>
</item>
......@@ -235,6 +261,7 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'?portal_stat
<value>
<tuple>
<list/>
<string>view</string>
</tuple>
</value>
</item>
......
545
\ No newline at end of file
546
\ 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