Commit a9e38ec7 authored by Roque's avatar Roque

erp5_web_project_ui: fix horrible querying of web pages

parent 418f29eb
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
kw.pop('relative_url', None)
kw.pop('follow_up_uid', None)
portal_catalog=context.getPortalObject().portal_catalog
follow_up_related_document_list = portal_catalog(
portal_type=portal_type,
follow_up_uid=context.getUid(), **kw)
kw['query'] = Query(relative_url='%s/%%' % context.getRelativeUrl().replace('_', r'\_'))
if follow_up_related_document_list:
kw['query'] = ComplexQuery(
kw['query'],
Query(uid=[x.getUid() for x in follow_up_related_document_list]),
logical_operator='or')
return [x.getRelativeUrl() for x in portal_catalog(portal_type=portal_type, limit=limit, **kw)]
<?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>_params</string> </key>
<value> <string>portal_type= (), limit=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_getRelatedDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -212,7 +212,7 @@
<list>
<tuple>
<string>state_document_domain</string>
<string>Document Status</string>
<string>Document State</string>
</tuple>
</list>
</value>
......
......@@ -253,7 +253,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: {"project_title":here.getTitle(), "jio_key": here.getRelativeUrl(), "home_page_preference": "project_home_page", "project_pages": [x.replace("web_page_module/", "") for x in here.Project_getRelatedDocumentList("Web Page")]}</string> </value>
<value> <string>python: {"project_title":here.getTitle(), "jio_key": here.getRelativeUrl(), "home_page_preference": here.getPortalObject().portal_preferences.getPreferredPublicationSection() }</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -111,7 +111,7 @@
}));
}
function getWebPageInfo(gadget, home_page_preference, project_pages) {
function getWebPageInfo(gadget, project_jio_key, home_page_preference) {
var id,
content,
edit_view,
......@@ -123,9 +123,6 @@
validation_state_query_list = [],
valid_state_list = ["shared_alive", "released_alive", "published_alive"],
web_page;
if (project_pages.length === 0) {
return {"id": id, "content": content, "edit_view": edit_view};
}
query_list.push(new SimpleQuery({
key: "portal_type",
operator: "=",
......@@ -145,18 +142,11 @@
query_list: validation_state_query_list,
type: "complex"
}));
for (i = 0; i < project_pages.length; i += 1) {
id_query_list.push(new SimpleQuery({
key: "id",
type: "simple",
operator: "=",
value: project_pages[i]
}));
}
query_list.push(new ComplexQuery({
operator: "OR",
query_list: id_query_list,
type: "complex"
query_list.push(new SimpleQuery({
key: "follow_up__relative_url",
operator: "=",
type: "simple",
value: project_jio_key
}));
query_list.push(new SimpleQuery({
key: "publication_section__relative_url",
......@@ -221,8 +211,7 @@
var state_dict = {
jio_key: options.jio_key || "",
project_title: options.project_title,
home_page_preference: options.home_page_preference,
project_pages: options.project_pages
home_page_preference: options.home_page_preference
};
return this.changeState(state_dict);
})
......@@ -234,7 +223,7 @@
return new RSVP.Queue()
.push(function () {
return RSVP.all([
getWebPageInfo(gadget, modification_dict.home_page_preference, modification_dict.project_pages),
getWebPageInfo(gadget, modification_dict.jio_key, modification_dict.home_page_preference),
gadget.getDeclaredGadget("editor"),
gadget.getSetting("hateoas_url")
]);
......
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