Commit f8fdca02 authored by Nicolas Delaby's avatar Nicolas Delaby

Change typology of Resources for Events and Tickets

Values are not categories anymore longer, they become regular document
(services, products, ...).
The list of those values is controlled by use base_category and
preference configuration.
This improvement will allow users to maintain their list of resources
more easily.

Backward compatibility is provided, categories on documents will still
be displayed (if any) to not break UI.
parent 2dc4bf14
......@@ -50,36 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns the list of items based on the preferred\n
resources for events. It is intended to be used\n
by ListField instances.\n
"""\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
def getResourceItemList():\n
result = [(\'\', \'\')]\n
url_list = portal.portal_preferences.getPreferredCampaignResourceList()\n
for url in url_list:\n
try:\n
resource_value = portal.restrictedTraverse(url, None)\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
result.append((resource_value.getTranslatedTitle(), category_relative_url))\n
except Unauthorized:\n
pass\n
return result\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
return getResourceItemList()\n
<value> <string>return context.Ticket_getResourceItemList()\n
</string> </value>
</item>
<item>
......
......@@ -59,27 +59,35 @@ from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
sql_kw = {\'portal_type\': portal.getPortalResourceTypeList(),\n
\'use_uid\': portal.portal_categories.getCategoryUid(portal.portal_preferences.getPreferredEventUse(), base_category=\'use\'),\n
\'validation_state\': \'validated\'}\n
\n
def getResourceItemList():\n
result = [(\'\', \'\')]\n
url_list = portal.portal_preferences.getPreferredEventResourceList()\n
for url in url_list:\n
try:\n
resource_value = portal.restrictedTraverse(url, None)\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
result.append((resource_value.getTranslatedTitle(), category_relative_url))\n
except Unauthorized:\n
pass\n
return result\n
return [(\'\', \'\')] + [(result.getTitle(), result.getRelativeUrl()) for result in portal.portal_catalog(**sql_kw)]\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
return getResourceItemList()\n
result_list = getResourceItemList()[:]\n
\n
# BBB returns actual value in list field\n
if context.getResource() and context.getResource() not in [result[1] for result in result_list]:\n
try:\n
resource_value = portal.portal_categories.getCategoryValue(context.getResource(), base_category=\'resource\')\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
category_title = resource_value.getTranslatedTitle()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
category_title = resource_value.getTitle()\n
result_list.append((category_title, category_relative_url))\n
except Unauthorized:\n
pass\n
\n
return result_list\n
</string> </value>
</item>
<item>
......
......@@ -50,36 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns the list of items based on the preferred\n
resources for events. It is intended to be used\n
by ListField instances.\n
"""\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
def getResourceItemList():\n
result = [(\'\', \'\')]\n
url_list = portal.portal_preferences.getPreferredMeetingResourceList()\n
for url in url_list:\n
try:\n
resource_value = portal.restrictedTraverse(url, None)\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
result.append((resource_value.getTranslatedTitle(), category_relative_url))\n
except Unauthorized:\n
pass\n
return result\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
return getResourceItemList()\n
<value> <string>return context.Ticket_getResourceItemList()\n
</string> </value>
</item>
<item>
......
......@@ -50,36 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns the list of items based on the preferred\n
resources for events. It is intended to be used\n
by ListField instances.\n
"""\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
def getResourceItemList():\n
result = [(\'\', \'\')]\n
url_list = portal.portal_preferences.getPreferredSaleOpportunityResourceList()\n
for url in url_list:\n
try:\n
resource_value = portal.restrictedTraverse(url, None)\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
result.append((resource_value.getTranslatedTitle(), category_relative_url))\n
except Unauthorized:\n
pass\n
return result\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
return getResourceItemList()\n
<value> <string>return context.Ticket_getResourceItemList()\n
</string> </value>
</item>
<item>
......
......@@ -50,36 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns the list of items based on the preferred\n
resources for support requests. It is intended to be used\n
by ListField instances.\n
"""\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
def getResourceItemList():\n
result = [(\'\', \'\')]\n
url_list = portal.portal_preferences.getPreferredSupportRequestResourceList()\n
for url in url_list:\n
try:\n
resource_value = portal.restrictedTraverse(url, None)\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
result.append((resource_value.getTranslatedTitle(), category_relative_url))\n
except Unauthorized:\n
pass\n
return result\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
return getResourceItemList()\n
<value> <string>return context.Ticket_getResourceItemList()\n
</string> </value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns the list of items based on the preferred\n
resources for tickets. It is intended to be used\n
by ListField instances.\n
"""\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
preference_id = \'preferred_%s_use\' % \'_\'.join(token.lower() for token in context.getPortalType().split(\' \'))\n
sql_kw = {\'portal_type\': portal.getPortalResourceTypeList(),\n
\'use_uid\': portal.portal_categories.getCategoryUid(portal.portal_preferences.getPreference(preference_id), base_category=\'use\'),\n
\'validation_state\': \'validated\'}\n
\n
def getResourceItemList():\n
return [(\'\', \'\')] + [(result.getTitle(), result.getRelativeUrl()) for result in portal.portal_catalog(**sql_kw)]\n
\n
getResourceItemList = CachingMethod(getResourceItemList, \n
id=(script.id, context.Localizer.get_selected_language()), \n
cache_factory=\'erp5_ui_long\')\n
\n
result_list = getResourceItemList()[:]\n
\n
# BBB returns actual value in list field\n
if context.getResource() and context.getResource() not in [result[1] for result in result_list]:\n
try:\n
resource_value = portal.portal_categories.getCategoryValue(context.getResource(), base_category=\'resource\')\n
if resource_value is not None:\n
if resource_value.getPortalType() == \'Category\':\n
category_relative_url = resource_value.getCategoryRelativeUrl()\n
category_title = resource_value.getTranslatedTitle()\n
else:\n
category_relative_url = resource_value.getRelativeUrl()\n
category_title = resource_value.getTitle()\n
result_list.append((category_title, category_relative_url))\n
except Unauthorized:\n
pass\n
\n
return result_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_getResourceItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
544
\ No newline at end of file
545
\ 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