Commit e2a51a97 authored by Roque's avatar Roque

erp5_officejs: more common config elements

parent 81159a7e
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Base ERP5 Form view for rendering in renderjs UI</string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_fields_raw_properties</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Form_viewAsDefinition</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ERP5Form_viewAsJio</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Log import log
def getRealRelativeUrl(document):
return '/'.join(context.getPortalObject().portal_url.getRelativeContentPath(document))
def getFieldRawProperties(field, meta_type=None, key=None, key_prefix=None):
""" Return the raw properties of the field """
if meta_type is None:
meta_type = field.meta_type
if key is None:
key = field.generate_field_key(key_prefix=key_prefix)
if meta_type == "ProxyField":
meta_type = field.getRecursiveTemplateField().meta_type
result = {
"type": meta_type,
"key": key,
"values": {},
"overrides": field.overrides,
"message_values": field.message_values
}
# these patchs change the field property names as are required by js rendering
form_list_patch = False
gadget_field_patch = False
for key in field.values.keys():
# sometimes, field.values returns a key as string and also as a tuple
if type(key) is str:
result["values"][key] = field.values[key]
if key == "columns":
form_list_patch = True
if key == "gadget_url":
gadget_field_patch = True
if form_list_patch:
try:
result["values"]["column_list"] = result["values"]["columns"]
result["values"]["sort_column_list"] = result["values"]["sort_columns"]
result["values"]["search_column_list"] = result["values"]["search_columns"]
portal_type = result["values"]["portal_types"][0][0] if "portal_types" in result["values"] else False
if not portal_type:
portal_type = result["values"]["portal_type"][0][0] if "portal_type" in result["values"] else False
query = "portal_type%3A%22" + portal_type + "%22" if portal_type else ""
full_query = "urn:jio:allDocs?query=" + query
result["values"]["query"] = full_query
except KeyError:
log("error while patching form list definition")
if gadget_field_patch:
try:
result["values"]["url"] = result["values"]["gadget_url"]
result["values"]["renderjs_extra"] = result["values"]["renderjs_extra"][0][0]
except (ValueError, KeyError, IndexError):
log("error while patching form gadget list definition")
return result
if REQUEST.get("view") == "definition_view":
traversed_document = context
traversed_document_portal_type = traversed_document.getPortalType()
fields_raw_properties = {}
if traversed_document_portal_type in ("ERP5 Form", "ERP5 Report"):
custom_action_script = False
for group in traversed_document.Form_getGroupTitleAndId():
if 'hidden' in group["gid"]:
for field in traversed_document.get_fields_in_group(group["goid"]):
if field.id == "gadget_field_action_js_script":
custom_action_script = True
fields_raw_properties[field.id] = getFieldRawProperties(field, key_prefix=None)
continue
for field in traversed_document.get_fields_in_group(group["goid"]):
if field.id == "gadget_field_action_js_script":
custom_action_script = True
fields_raw_properties[field.id] = getFieldRawProperties(field, key_prefix=None)
if custom_action_script:
fields_raw_properties['_actions'] = {
'put': {
"href": "%(traversed_document_url)s/%(action_id)s" % {
"traversed_document_url": context.getPortalObject().absolute_url() + "/" + getRealRelativeUrl(traversed_document),
"action_id": "Base_edit"
},
"action": "Base_edit",
"method": "POST",
}
}
if fields_raw_properties:
return fields_raw_properties
<?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>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Form_getFieldsRawProperties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Redirect to domain specified as layout property on website
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
import binascii
import base64
result_dict = {"error":"url missing definition view path"}
base_64 = False
try:
name = context.REQUEST.other['source_path']
except KeyError:
return result_dict
try:
encoded = name.replace("definition_view/", "", 1)
name = base64.decodestring(encoded)
base_64 = True
except binascii.Error:
pass
if name.startswith("definition_view/") or name.startswith("portal_types/") or base_64:
relative_url = name.replace("%2F", "/").replace("%20", " ")
relative_url = relative_url.replace("definition_view/", "", 1)
context.REQUEST.set("view", "definition_view")
context.REQUEST.set("current_web_section", None)
try:
result_dict = context.getPortalObject().ERP5Document_getHateoas(mode="traverse", relative_url=relative_url, view="definition_view")
except Exception as e:
result_dict = {"error":"error while getting hateoas script for relative_url %s: %s" % (relative_url, str(e))}
return result_dict
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>StaticWebSite_getRedirectSourceUrlForOfficeJSApplication</string> </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