From 374a023e5e61e83ca7e705b84b65cc95df228601 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Fri, 4 Dec 2009 12:36:47 +0000 Subject: [PATCH] Improve performance of project planning box generation. Configure new domains to display the full list of task/task reports. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31076 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Project_generatePersonDomain.xml | 27 +++++-------- .../Project_generateProjectLineDomain.xml | 3 +- .../Project_getPlanningBoxReportList.xml | 39 ++++++++----------- .../Project_viewPlanning/planning_box.xml | 14 +++++-- .../TaskModule_generateDomain.xml | 34 +++++----------- bt5/erp5_project/bt/revision | 2 +- 6 files changed, 50 insertions(+), 69 deletions(-) diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generatePersonDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generatePersonDomain.xml index 4a5e64ff1e..475317f3ad 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generatePersonDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generatePersonDomain.xml @@ -59,25 +59,22 @@ object_path = request.get(\'object_path\')\n if object_path is None:\n object_path = context.REQUEST.get(\'URL1\').split(\'/\')[-1]\n \n -search_path = \'\'.join(["%project_module/", object_path,"%"])\n +real_context = context.restrictedTraverse(object_path)\n \n if depth == 0:\n - category_list = []\n - for line in context.portal_catalog(path=search_path ):\n - category_list.extend([ i for i in line.getObject().getSourceValueList() if i not in category_list])\n -\n -\n + category_list = context.portal_catalog(\n + source_related_relative_url=(real_context.getRelativeUrl(), \'%s/%%\' % real_context.getRelativeUrl()),\n + )\n else:\n return domain_list\n \n for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n - membership_criterion_base_category = (\'source\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n - domain_generator_method_id = script.id,\n + domain = parent.generateTempDomain(id=\'sub%s\' % category.getId())\n + domain.edit(title=category.getTitle(),\n + membership_criterion_base_category=(\'source\',), \n + membership_criterion_category=(category.getRelativeUrl(),),\n + domain_generator_method_id=script.id,\n uid = category.getUid())\n - \n domain_list.append(domain)\n \n return domain_list\n @@ -127,13 +124,9 @@ return domain_list\n <string>object_path</string> <string>None</string> <string>_getitem_</string> - <string>search_path</string> + <string>real_context</string> <string>category_list</string> <string>_getiter_</string> - <string>line</string> - <string>append</string> - <string>$append0</string> - <string>i</string> <string>category</string> <string>domain</string> <string>script</string> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generateProjectLineDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generateProjectLineDomain.xml index 0031f489f5..4eb08abad5 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generateProjectLineDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_generateProjectLineDomain.xml @@ -67,7 +67,6 @@ domain_list = []\n \n if depth == 0:\n category_list = [context.project_module.restrictedTraverse(object_path)]\n - \n else:\n category_list = []\n parent_category_list = parent.getMembershipCriterionCategoryList()\n @@ -80,7 +79,7 @@ for category in category_list:\n domain = parent.generateTempDomain(id = \'%s_%s\' % (depth, i))\n domain.edit(title = category.getTitle(),\n membership_criterion_base_category = (\'source_project\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n + membership_criterion_category = (category.getRelativeUrl(), ),\n domain_generator_method_id = script.id,\n uid = category.getUid())\n i += 1\n diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getPlanningBoxReportList.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getPlanningBoxReportList.xml index fe68599d84..ca1d531309 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getPlanningBoxReportList.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getPlanningBoxReportList.xml @@ -58,33 +58,28 @@ selection_tool = context.portal_selections\n selection = selection_tool.getSelectionFor(\'project_planning_selection\')\n \n -def getSourceProjectRelatedValueList():\n - object_path = context.getRelativeUrl()\n - search_path = \'\'.join(["%", object_path,"%"])\n - return_list = []\n - for line in context.portal_catalog(path=search_path ):\n - return_list.extend([ i for i in line.getObject().getSourceProjectRelatedValueList(**kw) if i not in return_list])\n - return return_list\n -\n if selection is not None:\n - if selection.report_path in [\'project_person_domain\' ]:\n - return context.getSourceProjectRelatedValueList(**kw)\n -\n - if selection.report_path in [\'project_person_task_report_domain\']:\n + if selection.report_path in (\'task_module_domain\', \'project_person_domain\'):\n + kw[\'source_project_relative_url\'] = (context.getRelativeUrl(), \'%s/%%\' % context.getRelativeUrl())\n + elif selection.report_path == \'project_person_task_report_domain\':\n # It was required filter to one specific portal type\n kw[\'portal_type\'] = [\'Task Report\']\n - return context.getSourceProjectRelatedValueList(**kw)\n -\n - if selection.report_path in [\'project_projectline_domain\']:\n - return getSourceProjectRelatedValueList()\n -\n - if selection.report_path in [\'project_project_task_report_domain\']:\n + kw[\'source_project_relative_url\'] = (context.getRelativeUrl(), \'%s/%%\' % context.getRelativeUrl())\n + elif selection.report_path == \'project_projectline_domain\':\n + kw[\'source_project_relative_url\'] = (context.getRelativeUrl(), \'%s/%%\' % context.getRelativeUrl())\n + elif selection.report_path in (\'task_report_module_domain\', \'project_project_task_report_domain\'):\n # It was required filter to one specific portal type\n kw[\'portal_type\'] = [\'Task Report\']\n - return getSourceProjectRelatedValueList()\n + kw[\'source_project_relative_url\'] = (context.getRelativeUrl(), \'%s/%%\' % context.getRelativeUrl())\n + elif selection.report_path == \'parent\':\n + return context.searchFolder(**kw)\n + else:\n + raise NotImplementedError, "Unknow domain %s" % selection.report_path\n \n + return context.portal_catalog(**kw)\n \n -return context.searchFolder(**kw)\n +else:\n + return context.searchFolder(**kw)\n </string> </value> </item> <item> @@ -126,10 +121,10 @@ return context.searchFolder(**kw)\n <string>context</string> <string>selection_tool</string> <string>selection</string> - <string>getSourceProjectRelatedValueList</string> <string>None</string> - <string>_apply_</string> <string>_write_</string> + <string>_apply_</string> + <string>NotImplementedError</string> </tuple> </value> </item> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_viewPlanning/planning_box.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_viewPlanning/planning_box.xml index 522686e018..f3ded0dfe6 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_viewPlanning/planning_box.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_viewPlanning/planning_box.xml @@ -13,10 +13,10 @@ <key> <string>delegated_list</string> </key> <value> <list> - <string>title</string> - <string>report_root_list</string> - <string>portal_types</string> <string>list_method</string> + <string>portal_types</string> + <string>report_root_list</string> + <string>title</string> </list> </value> </item> @@ -118,6 +118,14 @@ <key> <string>report_root_list</string> </key> <value> <list> + <tuple> + <string>task_module_domain</string> + <string>Task</string> + </tuple> + <tuple> + <string>task_report_module_domain</string> + <string>Task Report</string> + </tuple> <tuple> <string>parent</string> <string>Project Line</string> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateDomain.xml index 54f6644a18..6e3479682a 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateDomain.xml @@ -57,29 +57,17 @@ domain_list = []\n \n if depth == 0:\n - category_list = [ context.task_module.getObject() ] \n -\n -# XXX this is usefull but Breaks the edition\n -#elif depth == 1:\n -# category_list = context.portal_selections.getSelectionValueList(context=context,\n -# selection_name= \'task_report_selection\')\n -\n + module = context.task_module\n \n + domain = parent.generateTempDomain(id=\'sub%s\' % module.getId())\n + domain.edit(title=module.getTitle(),\n + membership_criterion_base_category=(\'parent\', ), \n + membership_criterion_category=(module.getRelativeUrl(),),\n + domain_generator_method_id=script.id,\n + uid=module.getUid())\n + return [domain]\n else:\n - return domain_list\n -\n -for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n - membership_criterion_base_category = (\'parent\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n - domain_generator_method_id = script.id,\n - uid = category.getUid())\n - \n - domain_list.append(domain)\n -#from Products.ERP5Type.Log import log\n -#log("%s on %s" % (script.getId(), context.getPath()), "%d objects domain" % len(domain_list))\n -return domain_list\n + return []\n </string> </value> </item> <item> @@ -123,9 +111,7 @@ return domain_list\n <string>context</string> <string>request</string> <string>domain_list</string> - <string>category_list</string> - <string>_getiter_</string> - <string>category</string> + <string>module</string> <string>domain</string> <string>script</string> </tuple> diff --git a/bt5/erp5_project/bt/revision b/bt5/erp5_project/bt/revision index 3247896b00..86ed5c7d2a 100644 --- a/bt5/erp5_project/bt/revision +++ b/bt5/erp5_project/bt/revision @@ -1 +1 @@ -712 \ No newline at end of file +717 \ No newline at end of file -- 2.30.9