Fix update of assignement when assignment exist

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41553 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ae83d638
......@@ -62,15 +62,15 @@ organisation = context.getDestinationDecisionValue(portal_type="Organisation")\n
\n
assignment_configuration = {}\n
#Look on current assignement\n
old_role_list = context.portal_categories.role.getCategoryChildRelativeUrlList()\n
# XXX remove the base \'role/\'. A better way could be possible\n
old_role_list = [x.replace(\'role/\', \'\', 1) for x in old_role_list]\n
old_role_list = context.portal_categories.role.getCategoryChildLogicalPathItemList()[1:]\n
#old_role_list look like [[\'title\',\'logical_path\'],]\n
old_role_list = [ category[1] for category in old_role_list]\n
for role in context.getRoleList():\n
has_assignment = person.countFolder(portal_type=\'Assignment\',\n
role = role,\n
validation_state = \'open\')\n
\n
assignment_configuration[role] = bool(has_assignment)\n
assignment_configuration[role] = bool(has_assignment[0][0])\n
old_role_list.remove(role)\n
\n
#Close old assignement\n
......@@ -81,10 +81,25 @@ assignment_duration = context.portal_preferences.getPreferredCredentialAssignmen
today = DateTime()\n
delay = today+assignment_duration\n
\n
organisation_url = organisation and organisation.getRelativeUrl() or None;\n
for role,create_assingment in assignment_configuration.items():\n
if create_assingment:\n
assignment_for_website = person.newContent(\n
organisation_url = organisation is not None and organisation.getRelativeUrl() or None;\n
for role,has_assignment in assignment_configuration.items():\n
if has_assignment:\n
#Update assignment\n
current_assignment_list = person.searchFolder(portal_type=\'Assignment\',\n
role = role,\n
validation_state = \'open\')\n
for assignment in current_assignment_list:\n
assignment = assignment.getObject()\n
assignment.update()\n
assignment.edit(site = context.getSite(),\n
activity = context.getActivityList(), \n
function = context.getFunctionList(),\n
destination = organisation_url,\n
stop_date=delay)\n
assignment.open()\n
else:\n
#Create assignment\n
assignment = person.newContent(\n
portal_type=\'Assignment\',\n
title = \'%s %s Assignment\' % (context.getSite(\'\').capitalize(), role.capitalize()),\n
role = role,\n
......@@ -93,17 +108,9 @@ for role,create_assingment in assignment_configuration.items():\n
function = context.getFunctionList(),\n
destination = organisation_url,\n
start_date = today,\n
stop_date = delay\n
)\n
stop_date = delay)\n
\n
assignment_for_website.open()\n
else:\n
#Update assignment\n
current_assignment_list = person.searchFolder(portal_type=\'Assignment\',\n
role = role,\n
validation_state = \'open\')\n
for assignment in current_assignment_list:\n
assignment.getObject().setStopDate(delay)\n
assignment.open()\n
</string> </value>
</item>
<item>
......
320
\ No newline at end of file
321
\ 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