From 88f5eb31d39947de1fa59f4a75353286418edea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 3 Feb 2010 15:12:11 +0000 Subject: [PATCH] reuse Base_getPreferredSectionItemList git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32233 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...nsaction_getDestinationSectionItemList.xml | 48 +++++-------------- ...ngTransaction_getSourceSectionItemList.xml | 43 +++++------------ bt5/erp5_accounting/bt/revision | 2 +- 3 files changed, 25 insertions(+), 68 deletions(-) diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationSectionItemList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationSectionItemList.xml index f7bdf800ca..dc701c2274 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationSectionItemList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationSectionItemList.xml @@ -53,34 +53,13 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>section = context.portal_preferences.getPreferredSectionCategory() or\\\n - context.portal_preferences.getPreferredAccountingTransactionSectionCategory()\n + <value> <string>section_item_list = context.Base_getPreferredSectionItemList(portal_type=\'Organisation\')\n +current_destination_section = context.getDestinationSection()\n +if current_destination_section is not None and\\\n + current_destination_section not in zip(*section_item_list)[1]:\n + section_item_list.append((context.getDestinationSectionTitle(), context.getDestinationSection()))\n \n -section_value = None\n -result = []\n -\n -if section is not None:\n - section_value = context.portal_categories.resolveCategory(section)\n -\n -if section_value is not None:\n - result = section_value.getGroupRelatedValueList(portal_type=\'Organisation\',\n - checked_permission=\'View\')\n -\n - result = [r for r in result\n - if r.getProperty(\'validation_state\') not in (\'invalidated\', \'deleted\')]\n -\n -\n -current_destination_section = context.getDestinationSectionValue()\n -\n -if current_destination_section is not None and current_destination_section not in result:\n - result.append(current_destination_section)\n -\n -def sorted(seq, key):\n - seq = seq[::]\n - seq.sort(key=key)\n - return seq\n -\n -return [(\'\', \'\')] + sorted([(i.getTitle(), i.getRelativeUrl()) for i in result], key=lambda x:x[0])\n +return section_item_list\n </string> </value> </item> <item> @@ -119,17 +98,12 @@ return [(\'\', \'\')] + sorted([(i.getTitle(), i.getRelativeUrl()) for i in resu <tuple> <string>_getattr_</string> <string>context</string> - <string>section</string> - <string>None</string> - <string>section_value</string> - <string>result</string> - <string>append</string> - <string>$append0</string> - <string>_getiter_</string> - <string>r</string> + <string>section_item_list</string> <string>current_destination_section</string> - <string>sorted</string> - <string>i</string> + <string>None</string> + <string>_getitem_</string> + <string>_apply_</string> + <string>zip</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourceSectionItemList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourceSectionItemList.xml index 539b35b6e0..fec3d59564 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourceSectionItemList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourceSectionItemList.xml @@ -53,31 +53,13 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>section_cat = context.portal_preferences.getPreferredAccountingTransactionSectionCategory()\n -if section_cat in (None, \'\') : \n - section_cat = context.getPortalDefaultSectionCategory()\n + <value> <string>section_item_list = context.Base_getPreferredSectionItemList(portal_type=\'Organisation\')\n +current_source_section = context.getSourceSection()\n +if current_source_section is not None and\\\n + current_source_section not in zip(*section_item_list)[1]:\n + section_item_list.append((context.getSourceSectionTitle(), context.getSourceSection()))\n \n -section_cat_obj = None\n -result = []\n -\n -if section_cat is not None:\n - # get the organisations belonging to this group\n - section_cat_obj = context.portal_categories.resolveCategory(section_cat)\n -\n -if section_cat_obj is not None:\n - result = section_cat_obj.getGroupRelatedValueList(portal_type=\'Organisation\',\n - checked_permission=\'Access contents information\')\n - result = [r for r in result\n - if r.getProperty(\'validation_state\') not in (\'invalidated\', \'deleted\')]\n -\n -current_source_section = context.getSourceSectionValue()\n -if current_source_section is not None and current_source_section not in result:\n - result.append(current_source_section)\n -\n -def sorted(seq, key):\n - seq = seq[::]\n - seq.sort(key=key)\n - return seq\n +return section_item_list\n \n # convert to ListField format\n return [(\'\', \'\')] + sorted([(i.getTitle(), i.getRelativeUrl()) for i in result], key=lambda x:x[0])\n @@ -119,16 +101,17 @@ return [(\'\', \'\')] + sorted([(i.getTitle(), i.getRelativeUrl()) for i in resu <tuple> <string>_getattr_</string> <string>context</string> - <string>section_cat</string> + <string>section_item_list</string> + <string>current_source_section</string> <string>None</string> - <string>section_cat_obj</string> - <string>result</string> + <string>_getitem_</string> + <string>_apply_</string> + <string>zip</string> + <string>sorted</string> <string>append</string> <string>$append0</string> <string>_getiter_</string> - <string>r</string> - <string>current_source_section</string> - <string>sorted</string> + <string>result</string> <string>i</string> </tuple> </value> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index e50f8eba35..8b37c8cfe6 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -1096 \ No newline at end of file +1097 \ No newline at end of file -- 2.30.9