Commit 281653f3 authored by Roque's avatar Roque Committed by Roque

erp5_web_project_ui: get project home page by publication section preference

- use global preference to get publication section value
- test updated
parent 8e24ff0a
Pipeline #7885 failed with stage
in 0 seconds
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
<list> <list>
<tuple> <tuple>
<string>state_document_domain</string> <string>state_document_domain</string>
<string>Document Status</string> <string>Document State</string>
</tuple> </tuple>
</list> </list>
</value> </value>
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: {"project_title":here.getTitle(), "jio_key": here.getRelativeUrl(), "project_reference": here.getReference()}</string> </value> <value> <string>python: {"jio_key": here.getRelativeUrl(), "publication_section": here.getPortalObject().portal_preferences.getPreferredProjectHomePagePublicationSectionCategory() }</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
return view_list.filter(d => d.name === name)[0].href; return view_list.filter(d => d.name === name)[0].href;
} }
function setLatestTestResult(gadget, project_title, svg_element, project_id) { function setLatestTestResult(gadget, svg_element, project_jio_key) {
var query = createProjectQuery(project_id, var query = createProjectQuery(project_jio_key,
[["portal_type", "Test Result"]]); [["portal_type", "Test Result"]]);
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: query, query: query,
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
function createProjectQuery(project_jio_key, key_value_list) { function createProjectQuery(project_jio_key, key_value_list) {
var i, query_list = [], id_query_list = [], id_complex_query; var i, query_list = [], id_query_list = [], id_complex_query;
if (project_jio_key) { if (project_jio_key) {
//relation to project or child project lines
id_query_list.push(new SimpleQuery({ id_query_list.push(new SimpleQuery({
key: "source_project__relative_url", key: "source_project__relative_url",
operator: "", operator: "",
...@@ -110,14 +111,17 @@ ...@@ -110,14 +111,17 @@
})); }));
} }
function getWebPageInfo(gadget, project_reference) { function getWebPageInfo(gadget, project_jio_key, publication_section) {
var id, var id,
content, content,
edit_view, edit_view,
redirector_ulr, redirector_ulr,
i,
query, query,
query_list = [], query_list = [],
valid_state_list = ["shared_alive", "released_alive", "published_alive"]; id_query_list = [],
validation_state_query_list = [],
web_page;
query_list.push(new SimpleQuery({ query_list.push(new SimpleQuery({
key: "portal_type", key: "portal_type",
operator: "=", operator: "=",
...@@ -125,48 +129,52 @@ ...@@ -125,48 +129,52 @@
value: "Web Page" value: "Web Page"
})); }));
query_list.push(new SimpleQuery({ query_list.push(new SimpleQuery({
key: "reference", key: "validation_state",
operator: "=", operator: "=",
type: "simple", type: "simple",
value: project_reference + '-Home.Page' value: ("shared", "released", "published", "shared_alive",
"released_alive", "published_alive")
})); }));
query = new ComplexQuery({ 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",
operator: "=",
type: "simple",
value: "publication_section/" + publication_section
}));
query = Query.objectToSearchText(new ComplexQuery({
operator: "AND", operator: "AND",
query_list: query_list, query_list: query_list,
type: "complex" type: "complex"
}); }));
return gadget.getUrlFor({command: 'push_history', options: {page: "project_redirector"}}) return gadget.getUrlFor({command: 'push_history', options: {page: "project_redirector"}})
.push(function (url) { .push(function (url) {
redirector_ulr = url; redirector_ulr = url;
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: Query.objectToSearchText(query), query: query,
select_list: ['validation_state', 'text_content'] select_list: ['text_content']
}); });
}) })
.push(function (result_list) { .push(function (result_list) {
if (result_list.data.rows[0]) { if (result_list.data.rows[0]) {
var i, state, web_page; web_page = result_list.data.rows[0];
for (i = 0; i < result_list.data.rows.length; i = i + 1) { id = web_page.id;
state = result_list.data.rows[i].value.validation_state; content = parseHTMLLinks(web_page.value.text_content, redirector_ulr);
if (valid_state_list.includes(state)) { return gadget.jio_getAttachment(id, "links")
web_page = result_list.data.rows[i]; .push(function (web_page_document) {
break; edit_view = getActionListByName(
} ensureArray(web_page_document._links.view),
} "view_editor"
if (web_page) { );
id = web_page.id; return {"id": id, "content": content, "edit_view": edit_view};
content = parseHTMLLinks(web_page.value.text_content, redirector_ulr); });
return gadget.jio_getAttachment(id, "links")
.push(function (web_page_document) {
edit_view = getActionListByName(
ensureArray(web_page_document._links.view),
"view_editor"
);
return {"id": id, "content": content, "edit_view": edit_view};
});
}
} }
return {"id": id, "content": content, "edit_view": edit_view}; return null;
}); });
} }
...@@ -195,8 +203,7 @@ ...@@ -195,8 +203,7 @@
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var state_dict = { var state_dict = {
jio_key: options.jio_key || "", jio_key: options.jio_key || "",
project_title: options.project_title, publication_section: options.publication_section
project_reference: options.project_reference
}; };
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
...@@ -204,32 +211,37 @@ ...@@ -204,32 +211,37 @@
.onStateChange(function (modification_dict) { .onStateChange(function (modification_dict) {
var gadget = this, var gadget = this,
web_page_info, web_page_info,
url_parameter_list,
promise_list,
editor; editor;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ promise_list = [
getWebPageInfo(gadget, modification_dict.project_reference),
gadget.getDeclaredGadget("editor"),
gadget.getSetting("hateoas_url") gadget.getSetting("hateoas_url")
]); ];
if (modification_dict.publication_section) {
promise_list.push(gadget.getDeclaredGadget("editor")),
promise_list.push(getWebPageInfo(gadget, modification_dict.jio_key, modification_dict.publication_section));
}
return RSVP.all(promise_list);
}) })
.push(function (result_list) { .push(function (result_list) {
var document_view = result_list[2] + var document_view = result_list[0] +
'/ERP5Document_getHateoas?mode=traverse&relative_url=' + '/ERP5Document_getHateoas?mode=traverse&relative_url=' +
modification_dict.jio_key + '&view=Project_viewDocumentList', modification_dict.jio_key + '&view=Project_viewDocumentList',
milestone_view = result_list[2] + milestone_view = result_list[0] +
'/ERP5Document_getHateoas?mode=traverse&relative_url=' + '/ERP5Document_getHateoas?mode=traverse&relative_url=' +
modification_dict.jio_key + '&view=Project_viewMilestoneList', modification_dict.jio_key + '&view=Project_viewMilestoneList',
activity_view = result_list[2] + activity_view = result_list[0] +
'/ERP5Document_getHateoas?mode=traverse&relative_url=' + '/ERP5Document_getHateoas?mode=traverse&relative_url=' +
modification_dict.jio_key + '&view=Project_viewActivityList'; modification_dict.jio_key + '&view=Project_viewActivityList';
web_page_info = result_list[0]; web_page_info = result_list[2];
if (web_page_info.id) { if (web_page_info) {
editor = result_list[1]; editor = result_list[1];
editor.render({"editor": "fck_editor", "editable": false, "maximize": true, editor.render({"editor": "fck_editor", "editable": false, "maximize": true,
"value": web_page_info.content}); "value": web_page_info.content});
} }
return gadget.getUrlForList([ url_parameter_list = [
getUrlParameterDict('milestone_module', milestone_view, [["stop_date", "ascending"]], getUrlParameterDict('milestone_module', milestone_view, [["stop_date", "ascending"]],
null, createProjectQuery(null, [["selection_domain_date_milestone_domain", "future"]])), null, createProjectQuery(null, [["selection_domain_date_milestone_domain", "future"]])),
getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]],
...@@ -251,11 +263,14 @@ ...@@ -251,11 +263,14 @@
null, createProjectQuery(modification_dict.jio_key, [])), null, createProjectQuery(modification_dict.jio_key, [])),
getUrlParameterDict('test_suite_module', 'view', [["creation_date", "descending"]], getUrlParameterDict('test_suite_module', 'view', [["creation_date", "descending"]],
null, createProjectQuery(modification_dict.jio_key, [["translated_validation_state_title", "validated"]])), null, createProjectQuery(modification_dict.jio_key, [["translated_validation_state_title", "validated"]])),
getUrlParameterDict(web_page_info.id, web_page_info.edit_view),
getUrlParameterDict(modification_dict.jio_key, document_view, [["modification_date", "descending"]], getUrlParameterDict(modification_dict.jio_key, document_view, [["modification_date", "descending"]],
["download", "title", "reference", "modification_date"], createProjectQuery(null, [["selection_domain_state_document_domain", "confirmed"]])), ["download", "title", "reference", "modification_date"], createProjectQuery(null, [["selection_domain_state_document_domain", "confirmed"]])),
getUrlParameterDict(modification_dict.jio_key, activity_view, [["modification_date", "descending"]]) getUrlParameterDict(modification_dict.jio_key, activity_view, [["modification_date", "descending"]])
]); ];
if (web_page_info) {
url_parameter_list.push(getUrlParameterDict(web_page_info.id, web_page_info.edit_view));
}
return gadget.getUrlForList(url_parameter_list);
}) })
.push(function (url_list) { .push(function (url_list) {
enableLink(document.getElementById("milestone_link"), url_list[0]); enableLink(document.getElementById("milestone_link"), url_list[0]);
...@@ -265,13 +280,12 @@ ...@@ -265,13 +280,12 @@
enableLink(document.getElementById("report_link"), url_list[4]); enableLink(document.getElementById("report_link"), url_list[4]);
enableLink(document.getElementById("test_result_link"), url_list[5]); enableLink(document.getElementById("test_result_link"), url_list[5]);
enableLink(document.getElementById("test_suite_link"), url_list[6]); enableLink(document.getElementById("test_suite_link"), url_list[6]);
if (web_page_info.id) { enableLink(document.getElementById("document_link"), url_list[7]);
enableLink(document.getElementById("web_page_link"), url_list[7]); enableLink(document.getElementById("activity_link"), url_list[8]);
if (web_page_info) {
enableLink(document.getElementById("web_page_link"), url_list[9]);
} }
enableLink(document.getElementById("document_link"), url_list[8]); setLatestTestResult(gadget, document.getElementById("test_result_svg"), modification_dict.jio_key);
enableLink(document.getElementById("activity_link"), url_list[9]);
setLatestTestResult(gadget, modification_dict.project_title,
document.getElementById("test_result_svg"), modification_dict.jio_key);
}); });
}) })
......
...@@ -56,12 +56,12 @@ ...@@ -56,12 +56,12 @@
<!-- Check project present --> <!-- Check project present -->
<tr> <tr>
<td>assertElementPresent</td> <td>assertElementPresent</td>
<td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project"]</td> <td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project-home"]</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project"]</td> <td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project-home"]</td>
<td></td> <td></td>
</tr> </tr>
<!-- check project quick view page elements --> <!-- check project quick view page elements -->
......
portal = context.getPortalObject() portal = context.getPortalObject()
from datetime import datetime
now = datetime.now()
date_time = now.strftime("%m-%d-%Y-%H-%M-%S")
test_id = "test-project-" + date_time
project_reference = 'test-project-home' if home_page else 'test-project'
page_reference = 'test-home-page-' + date_time
module = portal.getDefaultModule('Project')
project = module.newContent(id = test_id,
portal_type = 'Project',
reference = project_reference)
project.validate()
if home_page: if home_page:
system_preference = portal.portal_preferences.getActiveSystemPreference()
system_preference.setPreferredProjectHomePagePublicationSectionCategory("project_home_page_for_test")
publication_section = context.restrictedTraverse('portal_categories/publication_section/project_home_page_for_test')
module = portal.getDefaultModule('Web Page') module = portal.getDefaultModule('Web Page')
home_page = module.newContent(portal_type = 'Web Page', home_page = module.newContent(id = test_id,
reference = 'test-project-Home.Page') portal_type = 'Web Page',
reference = page_reference,
publication_section_value = publication_section,
follow_up_value = project)
home_page.publishAlive() home_page.publishAlive()
module = portal.getDefaultModule('Project')
project = module.newContent(portal_type = 'Project',
reference = 'test-project')
project.validate()
print "Project Created" print "Project Created"
return printed return printed
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