Commit bd9af427 authored by Roque's avatar Roque

erp5_hal_json_style: WIP on moving form definition to hateoas script

parent 3b15ad3d
......@@ -66,6 +66,7 @@ from Products.ERP5Type.Utils import UpperCase
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
from collections import OrderedDict
log("################################################################")
log("[DEBUG] ERP5Document_getHateoas script was called!!!!!!")
MARKER = []
......@@ -953,7 +954,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
# Go through all groups ("left", "bottom", "hidden" etc.) and add fields from
# them into form.
for group in form.Form_getGroupTitleAndId():
group_list = []
try:
form_groups = form.Form_getGroupTitleAndId()
except:
form_groups = []
for group in form_groups: #form.Form_getGroupTitleAndId():
# Skipping hidden group could be problematic but see MatrixBox Field above
if 'hidden' in group['gid']:
continue
......@@ -1091,7 +1097,11 @@ def renderFormDefinition(form, response_dict):
Dialog Form such as dialog_id.
"""
group_list = []
for group in form.Form_getGroupTitleAndId():
try:
form_groups = form.Form_getGroupTitleAndId()
except:
form_groups = []
for group in form_groups: #form.Form_getGroupTitleAndId():
if group['gid'].find('hidden') < 0:
field_list = []
......@@ -1294,29 +1304,25 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
if (view == view_action['id']):
current_action = parseActionUrl('%s' % view_action['url']) # current action/view being rendered
if current_action.get('view_id', None) is not None:
log("[DEBUG] current_action['view_id'] after iterate on Base_filterDuplicateActions")
log("[DEBUG] " + str(current_action['view_id']))
if is_context_appcache:
current_action['url'] = 'https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/portal_skins/erp5_officejs_jio_connector/HTMLPost_viewAsJio/ERP5Form_viewAsJio'
current_action['view_id'] = "ERP5Form_viewAsJio"
current_action['params'] = {}
log("[DEBUG] current_action['view_id'] after hardcoded is_context_appcache")
log("[DEBUG] " + str(current_action['view_id']))
log("[DEBUG] current_action and view_id stuff with current_action: ")
log(current_action)
#if is_context_appcache:
# current_action['url'] = 'https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/portal_skins/erp5_officejs_jio_connector/HTMLPost_viewAsJio/ERP5Form_viewAsJio'
# current_action['view_id'] = "ERP5Form_viewAsJio"
# current_action['params'] = {}
if view and (view != 'view') and (current_action.get('view_id', None) is None):
# XXX Allow to directly render a form
current_action['view_id'] = view
current_action['url'] = '%s/%s' % (traversed_document.getRelativeUrl(), view)
current_action['params'] = {}
log("[DEBUG] current_action['view_id'] after assign view")
log("[DEBUG] " + str(current_action['view_id']))
if current_action.get('view_id', None) is not None:
log("[DEBUG] FINAL current_action['view_id']")
log("[DEBUG] " + str(current_action['view_id']))
if is_context_appcache:
current_action['view_id'] = "ERP5Form_viewAsJio"
log("[DEBUG] FINAL current_action['view_id']: " + str(current_action['view_id']))
log("")
# If we have current action definition we are able to render embedded view
# which should be a "ERP5 Form" but in reality can be anything
......@@ -1447,7 +1453,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
##############
# XXX Custom slapos code
##############
##############a
if is_site_root:
result_dict['default_view'] = 'view'
......@@ -2181,11 +2187,6 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
}
return result_dict
log(" ")
log("[DEBUG] beggining of script -sentences after function definition-")
log(" ")
mime_type = 'application/hal+json'
portal = context.getPortalObject()
sql_catalog = portal.portal_catalog.getSQLCatalog()
......@@ -2202,6 +2203,7 @@ else:
context.Base_prepareCorsResponse(RESPONSE=response)
# Check if traversed_document is the site_root
if relative_url:
temp_traversed_document = site_root.restrictedTraverse(relative_url, None)
......@@ -2217,6 +2219,11 @@ temp_is_portal = (temp_traversed_document.getPath() == portal.getPath())
response.setHeader('Content-Type', mime_type)
log(" ")
log("[DEBUG] relative_url: " + str(relative_url))
log("[DEBUG] temp_traversed_document: " + str(temp_traversed_document))
log("[DEBUG] temp_traversed_document.getPath(): " + temp_traversed_document.getPath())
log("[DEBUG] site_root.getPath(): " + site_root.getPath())
log("[DEBUG] portal.getPath(): " + portal.getPath())
log("[DEBUG] calling calculateHateoas method from beggining")
log(" ")
hateoas = calculateHateoas(is_portal=temp_is_portal, is_site_root=temp_is_site_root,
......
......@@ -29,7 +29,6 @@
gadget.getSetting('hateoas_url'),
gadget.getSetting('default_view_reference'),
gadget.jio_get(jio_key)
//gadget.jio_get("portal_skins/erp5_hal_json_style/roquetest")
]);
})
.push(function (setting_list) {
......@@ -76,7 +75,7 @@
return new RSVP.Queue()
.push(function () {
var xmlHttp = new XMLHttpRequest(),
url = "https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/app/portal_skins/erp5_hal_json_style/roquetest";
url = "https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/app/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view";
xmlHttp.open("GET", url, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.60782.51516.51131</string> </value>
<value> <string>973.62473.36343.1126</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>1551184466.38</float>
<float>1551285840.61</float>
<string>UTC</string>
</tuple>
</state>
......
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