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 ...@@ -66,30 +66,31 @@ old_role_list = context.portal_categories.role.getCategoryChildLogicalPathItemLi
#old_role_list look like [[\'title\',\'logical_path\'],]\n #old_role_list look like [[\'title\',\'logical_path\'],]\n
old_role_list = [ category[1] for category in old_role_list]\n old_role_list = [ category[1] for category in old_role_list]\n
for role in context.getRoleList():\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 old_role_list.remove(role)\n
\n
\n \n
#Close old assignement\n #Close old assignement\n
context.CredentialRequest_closePersonAssignment(old_role_list)\n open_assignment_list = context.CredentialRequest_closePersonAssignment(old_role_list)\n
\n \n
#Initialisation\n #Initialisation\n
assignment_duration = context.portal_preferences.getPreferredCredentialAssignmentDuration()\n assignment_duration = context.portal_preferences.getPreferredCredentialAssignmentDuration()\n
today = DateTime()\n today = DateTime()\n
delay = today+assignment_duration\n delay = today+assignment_duration\n
\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 organisation_url = organisation is not None and organisation.getRelativeUrl() or None;\n
for role,has_assignment in assignment_configuration.items():\n for role in context.getRoleList():\n
if has_assignment:\n if role in current_assignment_list:\n
#Update assignment\n #Update assignment\n
current_assignment_list = person.searchFolder(portal_type=\'Assignment\',\n for assignment in current_assignment_list[role]:\n
role = role,\n
validation_state = \'open\')\n
for assignment in current_assignment_list:\n
assignment = assignment.getObject()\n
assignment.update()\n assignment.update()\n
assignment.edit(site = context.getSite(),\n assignment.edit(site = context.getSite(),\n
activity = context.getActivityList(), \n activity = context.getActivityList(), \n
......
323 324
\ 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