Commit 3dd998c3 authored by Romain Courteaud's avatar Romain Courteaud

Fix Person_shiftDefaultCareer in order to be usable for non manager users.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14341 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 72eae8a2
...@@ -68,41 +68,46 @@ ...@@ -68,41 +68,46 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>object_list = []\n <value> <string>from Products.CMFActivity.Errors import ActivityPendingError\n
default_career = None\n N_ = context.Base_translateString\n
new_start_date = None\n
\n \n
# Create a list of all career line except the default one\n person = context\n
for object in context.contentValues(filter={\'portal_type\':\'Career\'}):\n career_list = []\n
if object.getId() != \'default_career\': \n
object_list += [object]\n
else:\n
default_career = object\n
new_start_date = default_career.getStopDate()\n
\n \n
# No default career\n default_career = getattr(person, \'default_career\', None)\n
if default_career == None:\n
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'/Person_viewCareer?portal_status_message=Current+career+must+exist.\')\n
\n \n
# Inverse sort of the list by id\n
object_list.sort(lambda x, y: -cmp(int(x.getId()), int(y.getId())))\n
\n \n
# Shift all career lines id values\n if default_career is None:\n
new_id = str(context.generateNewId())\n # No default career.\n
for career_line in object_list:\n message = N_(\'Current career must exist.\')\n
current_id = career_line.getId()\n return context.Base_redirect(form_id=\'Person_viewCareer\',\n
context.manage_renameObject(current_id, new_id)\n keep_items={\'portal_status_message\': message})\n
new_id = current_id\n else:\n
# Copy and paste the default career.\n
# Change IDs\n
new_id = person.generateNewId()\n
try:\n
default_career.setId(new_id)\n
except ActivityPendingError, error:\n
message = N_("%s" % error)\n
return context.Base_redirect(form_id=\'Person_viewCareer\',\n
keep_items={\'portal_status_message\': message})\n
\n \n
# Create a new default_career\n new_start_date = default_career.getStopDate()\n
context.manage_renameObject(\'default_career\', new_id)\n
new_default = context.manage_copyObjects(ids=(new_id,))\n
new_object = context.manage_pasteObjects(new_default)\n
context.manage_renameObject(new_object[0][\'new_id\'], \'default_career\')\n
context.setCareerStopDate(None)\n
context.setCareerStartDate(new_start_date)\n
\n \n
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'/Person_viewCareer?portal_status_message=Last+career+step+terminated.+New+career+step+added.\')\n cb_data = person.manage_copyObjects(ids=(new_id,))\n
copied = person.manage_pasteObjects(cb_data)\n
\n
new_default_career = getattr(person, copied[0][\'new_id\'])\n
\n
new_default_career.edit(\n
id=\'default_career\',\n
start_date=new_start_date,\n
stop_date=None)\n
\n
message = N_(\'Last career step terminated. New career step added.\')\n
return context.Base_redirect(form_id=\'Person_viewCareer\',\n
keep_items={\'portal_status_message\': message})\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -151,21 +156,24 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'/Person_view ...@@ -151,21 +156,24 @@ return context.REQUEST.RESPONSE.redirect(context.absolute_url() + \'/Person_view
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>object_list</string> <string>Products.CMFActivity.Errors</string>
<string>None</string> <string>ActivityPendingError</string>
<string>default_career</string>
<string>new_start_date</string>
<string>_getiter_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>object</string> <string>N_</string>
<string>str</string> <string>person</string>
<string>career_list</string>
<string>getattr</string>
<string>None</string>
<string>default_career</string>
<string>message</string>
<string>new_id</string> <string>new_id</string>
<string>career_line</string> <string>error</string>
<string>current_id</string> <string>new_start_date</string>
<string>new_default</string> <string>cb_data</string>
<string>new_object</string> <string>copied</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>new_default_career</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -581,7 +581,7 @@ ...@@ -581,7 +581,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>searchFolder</string> </value> <value> <string>contentValues</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
111 113
\ No newline at end of file \ 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