Fix get of assignment to update. Reduce use of catalog search.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42649 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b4931ec
......@@ -66,30 +66,31 @@ old_role_list = context.portal_categories.role.getCategoryChildLogicalPathItemLi
#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[0][0])\n
old_role_list.remove(role)\n
\n
\n
#Close old assignement\n
context.CredentialRequest_closePersonAssignment(old_role_list)\n
open_assignment_list = context.CredentialRequest_closePersonAssignment(old_role_list)\n
\n
#Initialisation\n
assignment_duration = context.portal_preferences.getPreferredCredentialAssignmentDuration()\n
today = DateTime()\n
delay = today+assignment_duration\n
\n
current_assignment_list = {}\n
for assignment in open_assignment_list:\n
role = assignement.getRole()\n
if role in current_assignment_list:\n
current_assignment_list[role].append(assignment)\n
else:\n
current_assignment_list[role] = [assignment]\n
\n
\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
for role in context.getRoleList():\n
if role in current_assignment_list:\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
for assignment in current_assignment_list[role]:\n
assignment.update()\n
assignment.edit(site = context.getSite(),\n
activity = context.getActivityList(), \n
......
323
\ No newline at end of file
324
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