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 @@ ...@@ -342,8 +342,8 @@
<string>Reference</string> <string>Reference</string>
</tuple> </tuple>
<tuple> <tuple>
<string>title</string> <string>short_title</string>
<string>Title</string> <string>Short Title</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_type</string> <string>portal_type</string>
...@@ -377,8 +377,8 @@ ...@@ -377,8 +377,8 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>only_published</string> <string>validation_state</string>
<string>False</string> <string>%</string>
</tuple> </tuple>
</list> </list>
</value> </value>
...@@ -497,8 +497,8 @@ ...@@ -497,8 +497,8 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>title</string> <string>short_title</string>
<string>title</string> <string>Short Title</string>
</tuple> </tuple>
</list> </list>
</value> </value>
...@@ -529,23 +529,23 @@ ...@@ -529,23 +529,23 @@
<list> <list>
<tuple> <tuple>
<string>reference</string> <string>reference</string>
<string>WebSite_getUrl</string> <string>WebSite_getListboxUrl</string>
</tuple> </tuple>
<tuple> <tuple>
<string>title</string> <string>short_title</string>
<string>WebSite_getUrl</string> <string>WebSite_getListboxUrl</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_type</string> <string>portal_type</string>
<string>WebSite_getUrl</string> <string>WebSite_getListboxUrl</string>
</tuple> </tuple>
<tuple> <tuple>
<string>creation_date</string> <string>creation_date</string>
<string>WebSite_getUrl</string> <string>WebSite_getListboxUrl</string>
</tuple> </tuple>
<tuple> <tuple>
<string>modification_date</string> <string>modification_date</string>
<string>WebSite_getUrl</string> <string>WebSite_getListboxUrl</string>
</tuple> </tuple>
</list> </list>
</value> </value>
......
...@@ -68,8 +68,11 @@ ...@@ -68,8 +68,11 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>if reference_path is None:\n <value> <string>if reference_path is None:\n
reference_path = context\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 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 return None\n
</string> </value> </string> </value>
</item> </item>
...@@ -121,6 +124,7 @@ return None\n ...@@ -121,6 +124,7 @@ return None\n
<string>None</string> <string>None</string>
<string>context</string> <string>context</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>section</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -66,7 +66,9 @@ ...@@ -66,7 +66,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <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 \n
if not context.getMembershipCriterionCategoryList() and not context.getSourceList():\n if not context.getMembershipCriterionCategoryList() and not context.getSourceList():\n
return []\n return []\n
...@@ -74,24 +76,23 @@ if not context.getMembershipCriterionCategoryList() and not context.getSourceLis ...@@ -74,24 +76,23 @@ if not context.getMembershipCriterionCategoryList() and not context.getSourceLis
def content_cmp(c1, c2):\n def content_cmp(c1, c2):\n
c1_value = c1.getObject()\n c1_value = c1.getObject()\n
c2_value = c2.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 return cmp(c1_value.getIntIndex(), c2_value.getIntIndex())\n
\n \n
if context.getMembershipCriterionCategoryList():\n if context.getMembershipCriterionCategoryList():\n
domain = DomainSelection(domain_dict = {\'web_site\': context})\n domain = DomainSelection(domain_dict = {\'web_site\': context})\n
kw[\'selection_domain\'] = domain\n kw[\'selection_domain\'] = domain\n
kw[\'portal_type\'] = \'Web Page\'\n kw[\'portal_type\'] = \'Web Page\'\n
if only_published is True:\n kw.setdefault(\'validation_state\',\'published\')\n
kw[\'validation_state\'] = \'published\'\n
if not kw.has_key(\'sort_on\'): kw[\'sort_on\'] = \'int_index\'\n if not kw.has_key(\'sort_on\'): kw[\'sort_on\'] = \'int_index\'\n
brain_list = list(context.portal_catalog(**kw))\n brain_list = list(context.portal_catalog(**kw))\n
else:\n else:\n
brain_list = []\n brain_list = []\n
\n \n
# Make a new search with local documents\n # Make a new search with local documents\n
reference_list = map(lambda x:x.getReference(), context.getSourceValueList(portal_type="Web Page"))\n value_list = context.getSourceValueList(portal_type="Web Page")\n
brain_list.extend(list(context.portal_catalog(reference= reference_list, 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 \n
# Make sure a single reference is counted once only\n # Make sure a single reference is counted once only\n
brain_dict = {}\n brain_dict = {}\n
...@@ -103,7 +104,12 @@ for b in brain_list:\n ...@@ -103,7 +104,12 @@ for b in brain_list:\n
if reference is None:\n if reference is None:\n
none_list.append(b)\n none_list.append(b)\n
else:\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 \n
brain_list = brain_dict.values() + none_list\n brain_list = brain_dict.values() + none_list\n
\n \n
...@@ -111,7 +117,9 @@ brain_list = brain_dict.values() + none_list\n ...@@ -111,7 +117,9 @@ brain_list = brain_dict.values() + none_list\n
brain_list.sort(content_cmp)\n brain_list.sort(content_cmp)\n
\n \n
return brain_list\n return brain_list\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -125,7 +133,7 @@ return brain_list\n ...@@ -125,7 +133,7 @@ return brain_list\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>only_published=True, **kw</string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -145,13 +153,12 @@ return brain_list\n ...@@ -145,13 +153,12 @@ return brain_list\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>only_published</string>
<string>kw</string> <string>kw</string>
<string>Products.ERP5Form.Selection</string> <string>Products.ERP5Form.Selection</string>
<string>DomainSelection</string> <string>DomainSelection</string>
...@@ -160,10 +167,11 @@ return brain_list\n ...@@ -160,10 +167,11 @@ return brain_list\n
<string>content_cmp</string> <string>content_cmp</string>
<string>domain</string> <string>domain</string>
<string>_write_</string> <string>_write_</string>
<string>True</string>
<string>list</string> <string>list</string>
<string>_apply_</string> <string>_apply_</string>
<string>brain_list</string> <string>brain_list</string>
<string>value_list</string>
<string>len</string>
<string>map</string> <string>map</string>
<string>reference_list</string> <string>reference_list</string>
<string>brain_dict</string> <string>brain_dict</string>
...@@ -173,6 +181,7 @@ return brain_list\n ...@@ -173,6 +181,7 @@ return brain_list\n
<string>o</string> <string>o</string>
<string>None</string> <string>None</string>
<string>reference</string> <string>reference</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -184,9 +193,7 @@ return brain_list\n ...@@ -184,9 +193,7 @@ return brain_list\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <none/>
<int>1</int>
</tuple>
</value> </value>
</item> </item>
<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