Commit 93a5cc91 authored by Thibaut Deheunynck's avatar Thibaut Deheunynck

improve script PersonModule_getBestCandidateList ( request for Fabien ).

update script modifyOrganisationFromM2 and modifyPhysicalPersonFromP2.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22955 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e67e1197
...@@ -185,6 +185,7 @@ for candidate in candidate_list:\n ...@@ -185,6 +185,7 @@ for candidate in candidate_list:\n
candidate_birthplace_address_city)),candidate.getRelativeUrl()))\n candidate_birthplace_address_city)),candidate.getRelativeUrl()))\n
\n \n
# Append extra actions\n # Append extra actions\n
result.append((\'-\', \'_no_action\'))\n
result.append((\'New Person\', \'_action_create\'))\n result.append((\'New Person\', \'_action_create\'))\n
return result\n return result\n
</string> </value> </string> </value>
......
...@@ -133,13 +133,9 @@ for organisation in organisation_list:\n ...@@ -133,13 +133,9 @@ for organisation in organisation_list:\n
\n \n
# Open all assignemnts that are in open_submitted state\n # Open all assignemnts that are in open_submitted state\n
destination_form_uid = context.portal_categories.destination_form.getUid()\n destination_form_uid = context.portal_categories.destination_form.getUid()\n
#assignment_list = [assignment.getObject() for assignment in context.portal_catalog(portal_type=\'Assignment\',\n assignment_list = [assignment.getObject() for assignment in context.portal_catalog(portal_type=\'Assignment\',\n
#validation_state = \'open_submitted\',\n validation_state = \'open_submitted\',\n
#destination_form_uid = request_eform.getUid())]\n destination_form_uid = request_eform.getUid())]\n
assignment_list = [assignment for assignment in \\\n
organisation.getDestinationRelatedValueList() if \\\n
assignment.getValidationState()==\'open_submitted\']\n
context.log(assignment_list)\n
for assignment in assignment_list:\n for assignment in assignment_list:\n
context.log(assignment)\n context.log(assignment)\n
assignment.open()\n assignment.open()\n
......
...@@ -65,9 +65,12 @@ ...@@ -65,9 +65,12 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string encoding="cdata"><![CDATA[
"""\n
This script collects *all* filled properties in the P2\n This script collects *all* filled properties in the P2\n
request_eform and updates the person and the organisation already created with the P0.\n request_eform and updates the person and the organisation already\n
created with the P0.\n
"""\n """\n
\n \n
# Initalize some useful variables\n # Initalize some useful variables\n
...@@ -84,9 +87,9 @@ def attachLocationYearInfo(last_id):\n ...@@ -84,9 +87,9 @@ def attachLocationYearInfo(last_id):\n
location_info = request_eform.getSite().split(\'/\')[0]\n location_info = request_eform.getSite().split(\'/\')[0]\n
if location_info == \'dakar\':\n if location_info == \'dakar\':\n
location_initials = \'DKR\'\n location_initials = \'DKR\'\n
elif location_info == \'Thies\':\n elif location_info == \'thies\':\n
location_initials = \'TH\'\n location_initials = \'TH\'\n
elif location_info == \'Saint-Louis\':\n elif location_info == \'saint-louis\':\n
location_initials = \'SL\'\n location_initials = \'SL\'\n
year = str(date.year())\n year = str(date.year())\n
type_of_form = \'M\'\n type_of_form = \'M\'\n
...@@ -112,9 +115,25 @@ query=ComplexQuery(Query(title=request_eform.getTitle()),\n ...@@ -112,9 +115,25 @@ query=ComplexQuery(Query(title=request_eform.getTitle()),\n
Query(birth_date=request_eform.getOwnerBirthday()),\n Query(birth_date=request_eform.getOwnerBirthday()),\n
Query(birthplace_city=request_eform.getOwnerBirthplace()),\n Query(birthplace_city=request_eform.getOwnerBirthplace()),\n
operator="AND")\n operator="AND")\n
result=[person.getObject() for person in context.portal_catalog(portal_type=\'Person\',query=query)]\n person_list=[person.getObject() for person in \\\n
# Modify person based on properties filled in P2\n context.portal_catalog(portal_type=\'Person\',query=query)]\n
for person in result:\n \n
if len(person_list) >1 :\n
raise ValidationFailed, "Error : There is more than one person with the "\\\n
" title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (\n
request_eform.getTitle(),\n
request_eform.getStartDate(),\n
request_eform.getDefaultBirthplaceAddressCity())\n
elif len(person_list) == 0:\n
raise ValidationFailed, "Error : There is nobody with the "\\\n
" title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (\n
request_eform.getTitle(),\n
request_eform.getStartDate(),\n
request_eform.getDefaultBirthplaceAddressCity())\n
\n
else:\n
# Modify person based on properties filled in P2\n
person = person_list[0]\n
person.edit(first_name=request_eform.getOwnerFirstName(),\n person.edit(first_name=request_eform.getOwnerFirstName(),\n
last_name=request_eform.getOwnerLastName(),\n last_name=request_eform.getOwnerLastName(),\n
start_date=request_eform.getOwnerBirthday(),\n start_date=request_eform.getOwnerBirthday(),\n
...@@ -135,6 +154,7 @@ for person in result:\n ...@@ -135,6 +154,7 @@ for person in result:\n
if request_eform.getCompanyModifications():\n if request_eform.getCompanyModifications():\n
organisation_list = [organisation.getObject() for organisation in \\\n organisation_list = [organisation.getObject() for organisation in \\\n
organisation_module.searchFolder(corporate_registration_code=request_eform.getCorporateRegistrationCode())]\n organisation_module.searchFolder(corporate_registration_code=request_eform.getCorporateRegistrationCode())]\n
context.log(organisation_list)\n
for organisation in organisation_list:\n for organisation in organisation_list:\n
activity_free_text = organisation.getActivityFreeText()\n activity_free_text = organisation.getActivityFreeText()\n
activity_list = activity_free_text and activity_free_text.split(\',\') or []\n activity_list = activity_free_text and activity_free_text.split(\',\') or []\n
...@@ -187,6 +207,8 @@ for person in result:\n ...@@ -187,6 +207,8 @@ for person in result:\n
else:\n else:\n
organisation.edit(activity_free_text = request_eform.getModifiedAddedActivities())\n organisation.edit(activity_free_text = request_eform.getModifiedAddedActivities())\n
organisation.getDefaultAddress().modify()\n organisation.getDefaultAddress().modify()\n
\n
\n
# Update the request_eform with the allocated number\n # Update the request_eform with the allocated number\n
request_eform.edit(registration_number = new_registry_number)\n request_eform.edit(registration_number = new_registry_number)\n
# Update the registration date of the request_eform with the time when the registry officer\n # Update the registration date of the request_eform with the time when the registry officer\n
...@@ -197,7 +219,9 @@ history_list = context.portal_workflow.getInfoFor(request_eform,\n ...@@ -197,7 +219,9 @@ history_list = context.portal_workflow.getInfoFor(request_eform,\n
for history in history_list:\n for history in history_list:\n
if history[\'action\'] == \'validate_action\':\n if history[\'action\'] == \'validate_action\':\n
request_eform.edit(registration_date=history[\'time\'])\n request_eform.edit(registration_date=history[\'time\'])\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -268,7 +292,9 @@ for history in history_list:\n ...@@ -268,7 +292,9 @@ for history in history_list:\n
<string>_getiter_</string> <string>_getiter_</string>
<string>context</string> <string>context</string>
<string>person</string> <string>person</string>
<string>result</string> <string>person_list</string>
<string>len</string>
<string>ValidationFailed</string>
<string>organisation</string> <string>organisation</string>
<string>organisation_list</string> <string>organisation_list</string>
<string>activity_free_text</string> <string>activity_free_text</string>
......
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