Commit 391c4bec authored by Vincent Pelletier's avatar Vincent Pelletier

Fix WebSite_getDocumentPhysicalPath when we're not in a section. This case...

Fix WebSite_getDocumentPhysicalPath when we're not in a section. This case should not happen, but better not to fail stupidly.
Correct the way WebSite_getDocumentValueList allows to display draft documents : wrong name was used, and there was a more elegant way.
Handle the case where the same documents exists in 2 versions, only display the newest.
Display the short title in the WebSection_view listbox.
Add links to Web Pages in WebSection_view listbox.
Add a new function in WebSite API to generate "physical" urls to documents from listbox (context from caller isn't preserved, otherwise WebSite_getDocumentphysicalPath would have been enough).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6109 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8a65fbd4
......@@ -342,8 +342,8 @@
<string>Reference</string>
</tuple>
<tuple>
<string>title</string>
<string>Title</string>
<string>short_title</string>
<string>Short Title</string>
</tuple>
<tuple>
<string>portal_type</string>
......@@ -377,8 +377,8 @@
<value>
<list>
<tuple>
<string>only_published</string>
<string>False</string>
<string>validation_state</string>
<string>%</string>
</tuple>
</list>
</value>
......@@ -497,8 +497,8 @@
<value>
<list>
<tuple>
<string>title</string>
<string>title</string>
<string>short_title</string>
<string>Short Title</string>
</tuple>
</list>
</value>
......@@ -529,23 +529,23 @@
<list>
<tuple>
<string>reference</string>
<string>WebSite_getUrl</string>
<string>WebSite_getListboxUrl</string>
</tuple>
<tuple>
<string>title</string>
<string>WebSite_getUrl</string>
<string>short_title</string>
<string>WebSite_getListboxUrl</string>
</tuple>
<tuple>
<string>portal_type</string>
<string>WebSite_getUrl</string>
<string>WebSite_getListboxUrl</string>
</tuple>
<tuple>
<string>creation_date</string>
<string>WebSite_getUrl</string>
<string>WebSite_getListboxUrl</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>WebSite_getUrl</string>
<string>WebSite_getListboxUrl</string>
</tuple>
</list>
</value>
......
......@@ -68,8 +68,11 @@
<key> <string>_body</string> </key>
<value> <string>if reference_path is None:\n
reference_path = context\n
section = reference_path.WebSite_getSectionValue()\n
if section is None:\n
section = context.WebSite_getSite()\n
if context.WebSite_getDocumentValue() is not None:\n
return "%s/%s" % (reference_path.WebSite_getSectionValue().WebSite_getUrl(),context.WebSite_getDocumentValue().getRelativeUrl())\n
return "%s/%s" % (section.WebSite_getUrl(),context.WebSite_getDocumentValue().getRelativeUrl())\n
return None\n
</string> </value>
</item>
......@@ -121,6 +124,7 @@ return None\n
<string>None</string>
<string>context</string>
<string>_getattr_</string>
<string>section</string>
</tuple>
</value>
</item>
......
......@@ -66,7 +66,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Form.Selection import DomainSelection\n
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Form.Selection import DomainSelection\n
\n
if not context.getMembershipCriterionCategoryList() and not context.getSourceList():\n
return []\n
......@@ -74,24 +76,23 @@ if not context.getMembershipCriterionCategoryList() and not context.getSourceLis
def content_cmp(c1, c2):\n
c1_value = c1.getObject()\n
c2_value = c2.getObject()\n
#if hasattr(c1, \'getShortTitle\') and c1.getShortTitle() == \'Overview\': return -1\n
#if hasattr(c2, \'getShortTitle\') and c2.getShortTitle() == \'Overview\': return 1\n
return cmp(c1_value.getIntIndex(), c2_value.getIntIndex())\n
\n
if context.getMembershipCriterionCategoryList():\n
domain = DomainSelection(domain_dict = {\'web_site\': context})\n
kw[\'selection_domain\'] = domain\n
kw[\'portal_type\'] = \'Web Page\'\n
if only_published is True:\n
kw[\'validation_state\'] = \'published\'\n
kw.setdefault(\'validation_state\',\'published\')\n
if not kw.has_key(\'sort_on\'): kw[\'sort_on\'] = \'int_index\'\n
brain_list = list(context.portal_catalog(**kw))\n
else:\n
brain_list = []\n
\n
# Make a new search with local documents\n
reference_list = map(lambda x:x.getReference(), context.getSourceValueList(portal_type="Web Page"))\n
brain_list.extend(list(context.portal_catalog(reference= reference_list, portal_type="Web Page")))\n
value_list = context.getSourceValueList(portal_type="Web Page")\n
if len(value_list):\n
reference_list = map(lambda x:x.getReference(), value_list)\n
brain_list.extend(list(context.portal_catalog(reference= reference_list, portal_type="Web Page")))\n
\n
# Make sure a single reference is counted once only\n
brain_dict = {}\n
......@@ -103,7 +104,12 @@ for b in brain_list:\n
if reference is None:\n
none_list.append(b)\n
else:\n
brain_dict[reference] = b\n
# Take the most recent version in case of conflicts\n
if brain_dict.has_key(reference):\n
if b.getVersion() > brain_dict[reference].getVersion():\n
brain_dict[reference] = b\n
else:\n
brain_dict[reference] = b\n
\n
brain_list = brain_dict.values() + none_list\n
\n
......@@ -111,7 +117,9 @@ brain_list = brain_dict.values() + none_list\n
brain_list.sort(content_cmp)\n
\n
return brain_list\n
</string> </value>
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -125,7 +133,7 @@ return brain_list\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>only_published=True, **kw</string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -145,13 +153,12 @@ return brain_list\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>only_published</string>
<string>kw</string>
<string>Products.ERP5Form.Selection</string>
<string>DomainSelection</string>
......@@ -160,10 +167,11 @@ return brain_list\n
<string>content_cmp</string>
<string>domain</string>
<string>_write_</string>
<string>True</string>
<string>list</string>
<string>_apply_</string>
<string>brain_list</string>
<string>value_list</string>
<string>len</string>
<string>map</string>
<string>reference_list</string>
<string>brain_dict</string>
......@@ -173,6 +181,7 @@ return brain_list\n
<string>o</string>
<string>None</string>
<string>reference</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
......@@ -184,9 +193,7 @@ return brain_list\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>1</int>
</tuple>
<none/>
</value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">bfINCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>if brain is not None:\n
return \'%s/%s\' % (context.REQUEST[\'URL0\'], brain.getRelativeUrl())\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/erp5/portal_skins/erp5_web/WebSite_getListboxUrl</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>brain=None, selection=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>brain</string>
<string>selection</string>
<string>None</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getListboxUrl</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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