From d9762354b3f140ee33a451fd63be1a042daa7399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Algrain?= <fxalgrain@tiolive.com> Date: Mon, 20 Dec 2010 17:07:33 +0000 Subject: [PATCH] Fix update of assignement when assignment exist git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41553 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...edentialRequest_updatePersonAssignment.xml | 43 +++++++++++-------- bt5/erp5_credential/bt/revision | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_updatePersonAssignment.xml b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_updatePersonAssignment.xml index e2c1c418a0..081555dbb6 100644 --- a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_updatePersonAssignment.xml +++ b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_updatePersonAssignment.xml @@ -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> diff --git a/bt5/erp5_credential/bt/revision b/bt5/erp5_credential/bt/revision index 194ba8cc75..9d239ff807 100644 --- a/bt5/erp5_credential/bt/revision +++ b/bt5/erp5_credential/bt/revision @@ -1 +1 @@ -320 \ No newline at end of file +321 \ No newline at end of file -- 2.30.9