Commit 76ce5e7f authored by Mame Coumba Sall's avatar Mame Coumba Sall

Apply suggestions by Jerome

parent e7594cc5
......@@ -73,7 +73,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ProjectModule_closeRelatedAssigmentListDialog</string> </value>
<value> <string>string:${object_url}/ProjectModule_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>6.5</float> </value>
<value> <float>13.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -75,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ClosedProject_closeRelatedAssigmentsDialog</string> </value>
<value> <string>string:${object_url}/Project_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -52,36 +52,10 @@
<key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query\n
closed_project_list = context.portal_catalog(portal_type=\'Project\', validation_state=\'invalidated\')\n
assignment_list = []\n
all_assignment_list = []\n
for project in closed_project_list:\n
destination_project_uid_list = [x.uid for x in context.portal_catalog(\n
relative_url=\'%s/%%\' % project.getRelativeUrl())] + [project.getUid()]\n
sql_kw = {}\n
if kw.has_key(\'from_date\') and kw[\'from_date\'] is not None:\n
query_kw = {\'delivery.start_date\' : kw[\'from_date\'],\n
\'range\' : \'min\'}\n
sql_kw[\'delivery.start_date\'] = Query(**query_kw)\n
if kw.has_key(\'at_date\') and kw[\'at_date\'] is not None:\n
query_kw = {\'delivery.stop_date\' : kw[\'at_date\'],\n
\'range\' : \'ngt\'}\n
sql_kw[\'delivery.stop_date\'] = Query(**query_kw)\n
assignment_list.extend([x.getObject() for x in \\\n
context.portal_catalog(\n
portal_type=\'Assignment\',\n
destination_project_uid = destination_project_uid_list,\n
validation_state = \'open\',\n
**sql_kw)])\n
\n
\n
def sortAssignment(a, b):\n
result = cmp(a.getStartDate(), b.getStartDate())\n
if result == 0:\n
result = cmp(a.getTitle(), b.getTitle())\n
return result\n
\n
assignment_list.sort(sortAssignment)\n
\n
return assignment_list\n
all_assignment_list.extend(project.Project_getDestinationProjectRelatedAssignmentList(**kw))\n
return all_assignment_list\n
</string> </value>
</item>
<item>
......
......@@ -35,7 +35,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Project_closeRelatedAssignments</string> </value>
<value> <string>Project_closeRelatedAssignmentList</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -88,7 +88,10 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
<list>
<string>listbox_start_date</string>
<string>listbox_stop_date</string>
</list>
</value>
</item>
<item>
......@@ -108,7 +111,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ProjectModule_closeRelatedAssigmentListDialog</string> </value>
<value> <string>ProjectModule_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
......@@ -116,7 +119,7 @@
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ClosedProject_closeRelatedAssigmentsDialog</string> </value>
<value> <string>ProjectModule_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
......
......@@ -51,13 +51,18 @@
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Message import translateString\n
from zExceptions import Unauthorized\n
portal = context.getPortalObject()\n
\n
message = translateString("Selected Assignments are now invalidated.")\n
for line in listbox:\n
if line.has_key(\'listbox_key\') and line[\'listbox_selected\'] is True:\n
assignment = portal.restrictedTraverse(line[\'listbox_key\'])\n
portal.portal_workflow.doActionFor(assignment, \'close_action\')\n
try:\n
portal.portal_workflow.doActionFor(assignment, \'close_action\')\n
except:\n
return context.Base_redirect(\'view\',\n
keep_items={\'portal_status_message\': "You are not allowed to close assignments"}, **kw)\n
\n
return context.Base_redirect(\'view\',\n
keep_items={\'portal_status_message\': message}, **kw)\n
......@@ -69,7 +74,7 @@ return context.Base_redirect(\'view\',\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_closeRelatedAssignments</string> </value>
<value> <string>Project_closeRelatedAssignmentList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -56,31 +56,22 @@
from Products.ZSQLCatalog.SQLCatalog import Query\n
\n
sql_kw = {}\n
if kw.has_key(\'from_date\') and kw[\'from_date\'] is not None:\n
if kw.get(\'from_date\') is not None:\n
query_kw = {\'delivery.start_date\' : kw[\'from_date\'],\n
\'range\' : \'min\'}\n
sql_kw[\'delivery.start_date\'] = Query(**query_kw)\n
if kw.has_key(\'at_date\') and kw[\'at_date\'] is not None:\n
if kw.get(\'at_date\') is not None:\n
query_kw = {\'delivery.stop_date\' : kw[\'at_date\'],\n
\'range\' : \'ngt\'}\n
sql_kw[\'delivery.stop_date\'] = Query(**query_kw)\n
assignment_list = ([x.getObject() for x in \\\n
context.portal_catalog(selection=selection, selection_report=selection_report, \n
portal_type=\'Assignment\',\n
destination_project_uid = destination_project_uid_list,\n
default_destination_project_uid = destination_project_uid_list,\n
validation_state = \'open\',\n
**sql_kw)])\n
\n
\n
def sortAssignment(a, b):\n
result = cmp(a.getStartDate(), b.getStartDate())\n
if result == 0:\n
result = cmp(a.getTitle(), b.getTitle())\n
return result\n
\n
assignment_list.sort(sortAssignment)\n
\n
return assignment_list\n
return sorted(assignment_list, key=lambda assignment: (assignment.getParentValue().getTitle(), assignment.getStartDate()))\n
</string> </value>
</item>
<item>
......
......@@ -35,7 +35,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Project_closeRelatedAssignments</string> </value>
<value> <string>Project_closeRelatedAssignmentList</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ClosedProject_closeRelatedAssigmentsDialog</string> </value>
<value> <string>Project_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
......@@ -119,7 +119,7 @@
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ClosedProject_closeRelatedAssigmentsDialog</string> </value>
<value> <string>Project_viewCloseRelatedAssigmentListDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
......
......@@ -149,11 +149,11 @@
</tuple>
<tuple>
<string>start_date</string>
<string>Start Date</string>
<string>Begin Date</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>Stop Date</string>
<string>End Date</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
......
......@@ -81,7 +81,7 @@
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>TaskReport_viewFieldLibrary</string> </value>
<value> <string>Base_viewProjectFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
......
......@@ -81,7 +81,7 @@
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>TaskReport_viewFieldLibrary</string> </value>
<value> <string>Base_viewProjectFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
......
838
\ No newline at end of file
839
\ 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