Commit 41d082de authored by Julien Muchembled's avatar Julien Muchembled

Merge "erp5_knowledge_pad: drop complicated and broken logic to wait that new pads are indexed

parents 1cecdc02 9e551336
......@@ -37,27 +37,25 @@
<value> <unicode encoding="cdata"><![CDATA[
<tal:block metal:define-macro="global_definitions">\n
<tal:block \n
tal:define="global mode python: options.get(\'mode\', request.get(\'gadget_mode\', \'erp5_front\'));\n
global default_pad_group python: options.get(\'default_pad_group\', request.get(\'gadget_default_pad_group\', \'\'));\n
global default_pad_group python: test(default_pad_group!=\'\', context.WebSection_getDefaultPadGroup(default_pad_group), default_pad_group);\n
kw python: dict(mode=mode, default_pad_group=default_pad_group);\n
global isAnonymousKnowledgePadUsed python: options.get(\'use_anonymous_knowledge_pad\',request.get(\'use_anonymous_knowledge_pad\', False));\n
dummy python: request.set(\'is_anonymous_knowledge_pad_used\', isAnonymousKnowledgePadUsed);\n
struct python: here.ERP5Site_getActiveKnowledgePadForUser(**kw);\n
global active_knowledge_pad python: struct[0];\n
global knowledge_pads python: struct[1];\n
global columns python: options.get(\'columns\', 3);\n
global hasUserActivity python: here.ERP5Site_hasUserActivity(active_knowledge_pad, **kw);\n
global isAnon python: here.portal_membership.isAnonymousUser();\n
global waitForActivitiesOnServer python: active_knowledge_pad is None and hasUserActivity;\n
global isUserAllowedToCreateKnowledgePads context/Base_isUserAllowedToUseKnowledgePad;\n
global isKnowledgePadTemplateUsed python: request.get(\'is_knowledge_pad_template_used\', 0); \n
global createDefaultPadForUser python: options.get(\'create_default_pad\', False) and \n
len(knowledge_pads)==0 and not hasUserActivity;\n
global make_security_check python: options.get(\'make_security_check\', False);\n
global pad_column python: options.get(\'pad_column\', 0);\n
global cancel_url here/absolute_url;"></tal:block>\n
<tal:block define="\n
global mode options/mode | request/gadget_mode | string:erp5_front;\n
global default_pad_group options/default_pad_group | request/gadget_default_pad_group | string:;\n
global default_pad_group python: default_pad_group and context.WebSection_getDefaultPadGroup(default_pad_group);\n
global isAnonymousKnowledgePadUsed options/use_anonymous_knowledge_pad | python: request.get(\'use_anonymous_knowledge_pad\', False);\n
dummy python: request.set(\'is_anonymous_knowledge_pad_used\', isAnonymousKnowledgePadUsed);\n
struct python: here.ERP5Site_getActiveKnowledgePadForUser(mode=mode,\n
default_pad_group=default_pad_group or None,\n
create_default_pad=options.get(\'create_default_pad\', False));\n
global active_knowledge_pad python: struct[0];\n
global knowledge_pads python: struct[1];\n
global columns python: options.get(\'columns\', 3);\n
global isAnon python: here.portal_membership.isAnonymousUser();\n
global isUserAllowedToCreateKnowledgePads context/Base_isUserAllowedToUseKnowledgePad;\n
global isKnowledgePadTemplateUsed python: request.get(\'is_knowledge_pad_template_used\', 0);\n
global make_security_check python: options.get(\'make_security_check\', False);\n
global pad_column python: options.get(\'pad_column\', 0);\n
global cancel_url here/absolute_url;\n
" />\n
</tal:block>\n
\n
<tal:block metal:define-macro="disable_server_integration">\n
......@@ -86,15 +84,15 @@
\n
</tal:block> \n
\n
<tal:block metal:define-macro="add_new_gadget"\n
tal:define="active_knowledge_pad_relative_url active_knowledge_pad/getRelativeUrl;">\n
<a tal:condition="not: isKnowledgePadTemplateUsed"\n
tal:attributes="href string:Base_viewGadgetListDialog?reset=1&amp;cancel_url=${cancel_url}&amp;mode=${mode}&amp;active_pad_relative_url=${active_knowledge_pad_relative_url}"\n
title="Add gadgets"\n
i18n:domain="ui"\n
i18n:attributes="title"\n
id="add-gadgets"><span i18n:translate="">Add gadgets</span></a>\n
</tal:block>\n
<a metal:define-macro="add_new_gadget"\n
tal:condition="python:active_knowledge_pad is not None and not isKnowledgePadTemplateUsed"\n
tal:attributes="href string:Base_viewGadgetListDialog?reset=1&amp;cancel_url=${cancel_url}&amp;mode=${mode}&amp;active_pad_relative_url=${active_knowledge_pad/getRelativeUrl}"\n
title="Add gadgets"\n
i18n:domain="ui"\n
i18n:attributes="title"\n
id="add-gadgets">\n
<span i18n:translate="">Add gadgets</span>\n
</a>\n
\n
<tal:block metal:define-macro="stick">\n
<tal:block\n
......@@ -268,37 +266,6 @@
</tal:block>\n
\n
\n
<tal:block metal:define-macro="create_default_pad">\n
<!-- Create (asynch) default pad. -->\n
<div tal:condition="python: not waitForActivitiesOnServer and \n
isUserAllowedToCreateKnowledgePads and\n
createDefaultPadForUser">\n
<div class="wait_block">\n
<h2 i18n:translate="" i18n:domain="ui"> \n
Please wait while your home area is being prepared.\n
</h2>\n
<p i18n:translate="" i18n:domain="ui"> You will be automatically redirected.</p>\n
<script type="text/javascript"\n
tal:content="string: createDefaultPadOnServer(5000, \'${default_pad_group}\', \'view\', \'${mode}\');"/>\n
</div>\n
</div>\n
</tal:block>\n
\n
\n
<tal:block metal:define-macro="create_default_pad_started">\n
\n
<!-- Show message that default pad is being prepared. -->\n
<div tal:condition="python: waitForActivitiesOnServer and isUserAllowedToCreateKnowledgePads">\n
<div class="wait_block">\n
<h2 i18n:translate="" i18n:domain="ui"> \n
Please wait while your home area is being updated.</h2>\n
<p i18n:translate="" i18n:domain="ui"> You\'ll be automatically redirected.</p>\n
<script type="text/javascript" \n
tal:content="string: checkForActivitiesOnServer(5000, \'view\', \'${mode}\', \'${default_pad_group}\');"/>\n
</div>\n
</div>\n
</tal:block>\n
\n
<tal:block metal:define-macro="loading_message">\n
<div id="loading-wrapper" style="display:none;">\n
<img src="ajax-loader.gif" title="Loading" alt="Loading"/>\n
......
......@@ -61,8 +61,11 @@ if mode in (\'web_front\', \'web_section\',):\n
# set it as active\n
context.ERP5Site_toggleActiveKnowledgePad(pad, mode=mode, redirect=False)\n
\n
if redirect_url is not None:\n
context.REQUEST.RESPONSE.redirect(\'%s?active_pad_url=%s\' %(redirect_url, pad.getRelativeUrl()))\n
# See ERP5Site_createDefaultKnowledgePadListForUser\n
pad.immediateReindexObject()\n
\n
if redirect_url:\n
return context.REQUEST.RESPONSE.redirect(redirect_url)\n
else:\n
# adding is done though either AJAX call or programatically\n
return pad.getRelativeUrl()\n
......
......@@ -50,39 +50,31 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from json import dumps\n
\n
knowledge_pad = None\n
<value> <string>knowledge_pad = None\n
portal = context.getPortalObject()\n
system_pref = context.portal_preferences.getActiveSystemPreference()\n
user_pref = context.Base_getActiveGlobalKnowledgePadPreference()\n
tag = \'%s_%s_%s\' %(portal.portal_membership.getAuthenticatedMember(),\n
mode,\n
default_pad_group)\n
activate_kw = {\'tag\': tag}\n
\n
is_web_mode = mode in (\'web_front\', \'web_section\',)\n
if not is_web_mode:\n
# leave only those not having a publication_section\n
filter_pad = lambda x: x.getPublicationSection() is None and x.getGroup() is None\n
elif default_pad_group:\n
filter_pad = lambda x: x.getGroup() == default_pad_group\n
else:\n
# find from preferences for the same context(site, section, page)\n
filter_pad = lambda x: context in x.getPublicationSectionValueList()\n
\n
# try to find template KnowledgePad from System Preference (and user Preference\n
# for backward compatibility only).\n
for pref in (system_pref, user_pref):\n
if pref is None:\n
continue\n
# use template from preferences \n
pref_pads = pref.contentValues(portal_type=\'Knowledge Pad\')\n
if not is_web_mode:\n
# leave only those not having a publication_section\n
pref_pads = filter(lambda x: x.getPublicationSection() is None and x.getGroup() is None, \n
pref_pads)\n
else:\n
if default_pad_group in (\'\', None):\n
# find from preferences for the same context(site, section, page)\n
pref_pads = filter(lambda x: context in x.getPublicationSectionValueList(), \n
pref_pads)\n
if pref is not None:\n
# use template from preferences\n
for pref_pad in pref.objectValues(portal_type=\'Knowledge Pad\'):\n
if filter_pad(pref_pad):\n
break\n
else:\n
pref_pads = filter(lambda x: x.getGroup()==default_pad_group, \n
pref_pads)\n
if len(pref_pads):\n
pref_pad = pref_pads[0]\n
continue\n
cp = pref.manage_copyObjects(ids=[pref_pad.getId()])\n
new_id = context.knowledge_pad_module.manage_pasteObjects(\n
cb_copy_data=cp)[0][\'new_id\']\n
......@@ -93,17 +85,16 @@ for pref in (system_pref, user_pref):\n
# pad\'s visibility is fixed in ERP5Site_toggleActiveKnowledgePad()\n
for box in knowledge_pad.contentValues(portal_type=\'Knowledge Box\'):\n
box.visible()\n
\n
if knowledge_pad is None:\n
break\n
else:\n
# created empty one because no template found\n
knowledge_pad = context.knowledge_pad_module.newContent(\n
portal_type = \'Knowledge Pad\',\n
title = context.Base_translateString(\'Tab 1\'),\n
activate_kw = activate_kw)\n
title = context.Base_translateString(\'Tab 1\'))\n
if is_web_mode:\n
# in Web Mode we can have a temporary Web Site objects created based on current language\n
real_context = context.Base_getRealContext()\n
if real_context.getPortalType() == \'Web Site\' and default_pad_group in (\'\', None,):\n
if real_context.getPortalType() == \'Web Site\' and not default_pad_group:\n
# script is called within Front Page Gadgets view\n
knowledge_pad.setPublicationSectionValue(real_context)\n
\n
......@@ -121,14 +112,22 @@ if owner is not None:\n
knowledge_pad.reindexObject()\n
\n
# set default gadgets\n
context.ERP5Site_createDefaultKnowledgeBox(knowledge_pad, activate_kw=activate_kw)\n
context.ERP5Site_createDefaultKnowledgeBox(knowledge_pad)\n
\n
# Calling immediateReindexObject explicitly is a coding crime.\n
# But it\'s safe for newly created objects and this script should\n
# be called rarely enough to not cause any performance issue.\n
# Any other solution would be more complicated.\n
# See also ERP5Site_addNewKnowledgePad\n
knowledge_pad.immediateReindexObject()\n
\n
return dumps({\'knowledge_pad_relative_url\': knowledge_pad.getRelativeUrl()})\n
if REQUEST is None:\n
return knowledge_pad\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>default_pad_group=None, mode=None, owner=None</string> </value>
<value> <string>default_pad_group=None, mode=None, owner=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -50,42 +50,24 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
method_mapping = {\'erp5_front\': \'view\',\n
\'web_front\': \'view\',\n
\'web_section\': \'view\'}\n
keep_items = {}\n
pad = context.restrictedTraverse(knowledge_pad_relative_url)\n
all_knowledge_pads = context.ERP5Site_getKnowledgePadListForUser(mode=mode)\n
next_active_pad = None\n
if len(all_knowledge_pads)>1:\n
# determine next active pad (first one)\n
for item in all_knowledge_pads:\n
if item.getObject() != pad:\n
next_active_pad = item\n
break\n
<value> <string>pad = context.restrictedTraverse(knowledge_pad_relative_url)\n
try:\n
# If the current active pad is deleted, activate last one.\n
for other_pad in context.ERP5Site_getKnowledgePadListForUser(mode=mode):\n
if other_pad != pad:\n
if other_pad.getValidationState() != \'invisible\':\n
break\n
invisible = other_pad\n
else:\n
invisible.visible()\n
pad.delete()\n
pad.activate(\n
after_path = knowledge_pad_relative_url).ERP5Site_toggleActiveKnowledgePad(\n
next_active_pad.getRelativeUrl(),\n
mode = mode,\n
redirect = False)\n
msg = \'Pad removed.\'\n
# pass temporary ids of new_active and deleted pad\n
# this will help next view determine them correctly \n
# (i.e. overriding inconsistent catalog results)\n
keep_items[\'override_catalog\'] = \'%s|%s\' \\\n
%(next_active_pad.getId(), pad.getId())\n
else:\n
except UnboundLocalError:\n
msg = \'Can not remove the only one pad.\'\n
\n
keep_items[\'portal_status_message\'] = context.Base_translateString(msg)\n
context.Base_redirect(method_mapping.get(mode, \'view\'),\n
keep_items)\n
]]></string> </value>
return context.Base_redirect(form_id="view", keep_items={\n
"portal_status_message": context.Base_translateString(msg)})\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -50,56 +50,47 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>MARKER = (\'\', None,)\n
visible_state_list = [\'visible\', \'public\']\n
\n
knowledge_pads = context.ERP5Site_getKnowledgePadListForUser(mode=mode,\n
default_pad_group=default_pad_group)\n
# use info from REQUEST\n
active_pad, knowledge_pads = \\\n
context.ERP5Site_getActiveKnowledgePadForUserFromRequest(knowledge_pads,\n
\'active_pad_url\')\n
if active_pad is not None and active_pad.getValidationState() in visible_state_list:\n
return active_pad, knowledge_pads\n
\n
# use info from REQUEST\n
active_knowledge_pad, knowledge_pads = \\\n
context.ERP5Site_getActiveKnowledgePadForUserFromRequest(knowledge_pads,\n
\'override_catalog\')\n
if active_knowledge_pad is not None:\n
return active_knowledge_pad, knowledge_pads\n
\n
<value> <string>knowledge_pads = context.ERP5Site_getKnowledgePadListForUser(\n
mode=mode, default_pad_group=default_pad_group)\n
real_context = context.Base_getRealContext()\n
real_context_url = real_context.getRelativeUrl()\n
\n
visible_pads = [x for x in knowledge_pads\n
if x.getValidationState() in (\'visible\', \'public\')]\n
\n
# first filter if we have a custom Pad for the context\n
for knowledge_pad in knowledge_pads:\n
pad_state = knowledge_pad.getValidationState()\n
for knowledge_pad in visible_pads:\n
publication_section_list = knowledge_pad.getPublicationSectionList()\n
if real_context_url in publication_section_list and pad_state in visible_state_list:\n
if real_context.getPortalType() == \'Web Site\' and default_pad_group in MARKER:\n
if real_context_url in publication_section_list:\n
if real_context.getPortalType() == \'Web Site\' and not default_pad_group:\n
# ERP5 Web Site front gadget\n
return knowledge_pad, knowledge_pads\n
elif real_context_url in publication_section_list and knowledge_pad.getGroup() == default_pad_group:\n
if knowledge_pad.getGroup() == default_pad_group:\n
# some Web Section can have a customized EXPLICILY "sticked" Pad\n
return knowledge_pad, knowledge_pads\n
elif len(publication_section_list) == 0 and default_pad_group in MARKER and pad_state in visible_state_list:\n
elif not publication_section_list and not default_pad_group:\n
# ERP5 Site front gadget \n
return knowledge_pad, knowledge_pads\n
\n
# no customized version found for this context so\n
# try finding pad by group\n
for knowledge_pad in knowledge_pads:\n
if knowledge_pad.getGroup() == default_pad_group and \\\n
knowledge_pad.getValidationState() in visible_state_list:\n
return knowledge_pad, knowledge_pads\n
for knowledge_pad in visible_pads:\n
if knowledge_pad.getGroup() == default_pad_group:\n
break\n
else:\n
if create_default_pad and context.Base_isUserAllowedToUseKnowledgePad():\n
knowledge_pad = context.ERP5Site_createDefaultKnowledgePadListForUser(\n
default_pad_group=default_pad_group, mode=mode)\n
knowledge_pads.append(knowledge_pad)\n
else:\n
knowledge_pad = None\n
\n
return None, knowledge_pads\n
return knowledge_pad, knowledge_pads\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>mode = None, default_pad_group=None</string> </value>
<value> <string>mode = None, default_pad_group=None, create_default_pad=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
<?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>_body</string> </key>
<value> <string>"""\n
Get active pad from REQUEST and remove old (deleted) pad \n
from list of available pads.\n
This is done in order to provide an instant view of pads\n
without waiting for reindexing to be finished.\n
"""\n
if request_variable == \'override_catalog\':\n
path_pattern = \'knowledge_pad_module/%s\'\n
override_catalog = context.REQUEST.get(request_variable, None)\n
if override_catalog is not None:\n
new_pad_id, old_pad_id = override_catalog.split(\'|\')\n
new_pad = context.restrictedTraverse(path_pattern %new_pad_id, None)\n
old_pad = context.restrictedTraverse(path_pattern %old_pad_id, None)\n
if new_pad is not None and old_pad is not None:\n
# remove old deleted pad\n
knowledge_pads = filter(lambda x: x.getObject() != old_pad, knowledge_pads)\n
#for pad in knowledge_pads:\n
# if pad.getObject() == old_pad:\n
# #knowledge_pads.remove(pad)\n
# knowledge_pads.pop(pad)\n
return new_pad, knowledge_pads\n
else:\n
return None, knowledge_pads\n
else:\n
active_pad = context.REQUEST.get(request_variable, None)\n
if active_pad is not None:\n
active_pad = context.restrictedTraverse(active_pad, None)\n
return active_pad, knowledge_pads\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>knowledge_pads=[], request_variable=\'override_catalog\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getActiveKnowledgePadForUserFromRequest</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,85 +50,52 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>request = context.REQUEST\n
isAnon = context.portal_membership.isAnonymousUser()\n
isAnonymousKnowledgePadUsed = request.get(\'is_anonymous_knowledge_pad_used\', 0);\n
<value> <string>portal = context.getPortalObject()\n
\n
def filterKnowledgePadListForContext(results, mode, \n
default_pad_group):\n
# in Web Mode we can have a temporary object created based on current language, document by reference\n
real_context_url = context.Base_getRealContext().getRelativeUrl()\n
if mode == \'web_front\':\n
# Web Site must at least one Pad referenced by context\n
filter_pad = lambda x: real_context_url in x.getPublicationSectionList() and x.getGroup() is None\n
elif mode == \'web_section\':\n
# Web Sections, Web Pages can "reuse" tabs\n
filter_pad = lambda x: real_context_url in x.getPublicationSectionList() or x.getGroup() == default_pad_group\n
elif mode == \'erp5_front\':\n
# leave only those not having a publication_section as \n
# this means belonging to root\n
filter_pad = lambda x: x.getPublicationSection() is None and x.getGroup() is None\n
else:\n
filter_pad = lambda x: 1\n
\n
results = []\n
def search(container, *states, **kw):\n
# call getObject() explicitly so that further getter methods do not\n
# invoke getObject().\n
results = [x.getObject() for x in results]\n
# in Web Mode we can have a temporary object created based on current language, document by reference\n
real_context = context.Base_getRealContext()\n
real_context_url = real_context.getRelativeUrl()\n
if mode == \'erp5_front\':\n
# leave only those not having a publication_section as \n
# this means belonging to root\n
results = filter(lambda x: x.getPublicationSection() is None and \\\n
x.getGroup() is None, results)\n
elif mode == \'web_front\':\n
# Web Site must at least one Pad referenced by context\n
results = filter(lambda x: real_context_url in x.getPublicationSectionList() and \\\n
x.getGroup() is None, results)\n
elif mode == \'web_section\':\n
# Web Sections, Web Pages can "reuse" tabs\n
results = filter(lambda x: real_context_url in x.getPublicationSectionList() or \\\n
x.getGroup() == default_pad_group, results)\n
return results\n
\n
\n
kw = {\'portal_type\': \'Knowledge Pad\',\n
\'sort_on\': ((\'creation_date\', \'ascending\',),),\n
\'limit\': 50,}\n
for pad in container.searchFolder(validation_state=states,\n
portal_type="Knowledge Pad",\n
sort_on=(("creation_date", "ascending"),),\n
limit=50, **kw):\n
try:\n
pad = pad.getObject()\n
if filter_pad(pad) and pad.getValidationState() in states:\n
results.append(pad)\n
except Exception:\n
pass\n
\n
# first for context\n
results = context.knowledge_pad_module.searchFolder(\n
validation_state = (\'visible\', \'invisible\',),\n
local_roles = \'Owner\',\n
**kw)\n
\n
if len(results)==0 and (isAnon and isAnonymousKnowledgePadUsed):\n
# try to get default pads for anonymous users if allowed on site\n
results = context.knowledge_pad_module.searchFolder(\n
validation_state = (\'public\',),\n
**kw)\n
\n
# use REQUEST to show immediately newly created pad\n
# without waiting for reindex to be over\n
active_pad, results = \\\n
context.ERP5Site_getActiveKnowledgePadForUserFromRequest(results,\n
\'active_pad_url\')\n
if active_pad is not None and active_pad.getValidationState() != \'deleted\':\n
found = False\n
new_results = []\n
active_pad_path = active_pad.getPath()\n
for brain in results:\n
new_results.append(brain)\n
if brain.getPath() == active_pad_path:\n
found = True\n
results = new_results\n
if not found:\n
# append it only if not from Catalog results\n
results.append(active_pad)\n
\n
# filter\n
results = filterKnowledgePadListForContext(results, mode, \n
default_pad_group)\n
\n
if not len(results) and not isAnon:\n
# try getting default knowledge pads for user from global site preference\n
user_pref = context.Base_getActiveGlobalKnowledgePadPreference()\n
\n
if user_pref is not None:\n
# use template from user\'s preferences \n
results = user_pref.searchFolder(validation_state = (\'public\',),\n
**kw)\n
# filter\n
results = filterKnowledgePadListForContext(results, mode, \n
default_pad_group)\n
if len(results):\n
search(portal.knowledge_pad_module, \'visible\', \'invisible\', local_roles=\'Owner\')\n
if not results:\n
request = portal.REQUEST\n
if request.get(\'is_anonymous_knowledge_pad_used\', 1):\n
# try to get default pads for anonymous users if allowed on site\n
search(portal.knowledge_pad_module, \'public\')\n
if not portal.portal_membership.isAnonymousUser():\n
# try getting default knowledge pads for user from global site preference\n
user_pref = context.Base_getActiveGlobalKnowledgePadPreference()\n
if user_pref is not None:\n
# use template from user\'s preferences \n
search(user_pref, \'public\')\n
if results:\n
# set a REQUEST variable (this can be used in HTML views)\n
request.set(\'is_knowledge_pad_template_used\', 1)\n
\n
......
<?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>_body</string> </key>
<value> <string>from json import dumps\n
portal = context.getPortalObject()\n
\n
if active_knowledge_pad is None and js_call:\n
# only for asynchronous checks\n
active_knowledge_pad, knowledge_pads = context.ERP5Site_getActiveKnowledgePadForUser(\n
mode=mode, \n
default_pad_group=default_pad_group)\n
\n
if active_knowledge_pad is None:\n
# no pad but it may be reindexed in an activity now, check by tag\n
tag = \'%s_%s_%s\' %(portal.portal_membership.getAuthenticatedMember(),\n
mode,\n
default_pad_group)\n
is_pending_create_activities = portal.portal_activities.countMessageWithTag(tag)\n
if js_call:\n
return str(is_pending_create_activities)\n
else:\n
return is_pending_create_activities\n
\n
# we have an active pad, check if it has pending activities\n
is_pending_create_activities = active_knowledge_pad.hasActivity()\n
\n
if js_call:\n
return dumps({\'result\':str(is_pending_create_activities)})\n
\n
return is_pending_create_activities\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_knowledge_pad=None, mode=None, default_pad_group=None, js_call=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_hasUserActivity</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -65,7 +65,7 @@ if toggable_pad is not None:\n
if pad.getObject()!=toggable_pad and pad.getValidationState()==\'visible\':\n
pad.invisible()\n
if redirect:\n
context.Base_redirect(\'view\')\n
context.Base_redirect(form_id="view")\n
</string> </value>
</item>
<item>
......
......@@ -39,10 +39,6 @@
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/global_definitions"/>\n
\n
<div id="gadget_area_wrapper">\n
\n
<tal:block tal:condition="python: not createDefaultPadForUser and \n
not waitForActivitiesOnServer and\n
active_knowledge_pad is not None">\n
\n
<tal:block tal:condition="python:not (isAnon or isAnonymousKnowledgePadUsed)"> \n
<div id="pad-navigation-wrapper">\n
......@@ -63,14 +59,6 @@
</div>\n
<!-- Hidden dialogs -->\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/hidden_dialogs"/>\n
\n
</tal:block>\n
\n
<!-- Show message that default pad is being prepared. -->\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/create_default_pad_started"/>\n
\n
<!-- Create (asynch) default pad. -->\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/create_default_pad"/>\n
\n
</div>
......
......@@ -50,9 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
knowledge_pad = context.restrictedTraverse(knowledge_pad_url)\n
<value> <string>knowledge_pad = context.restrictedTraverse(knowledge_pad_url)\n
knowledge_pad_module = knowledge_pad.getParentValue()\n
\n
# copy/paste\n
......@@ -67,21 +65,16 @@ new_knowledge_pad.visible()\n
\n
# because workflow state(i.e. visibility is set to default(invisible)\n
# set manually with respect to original\n
for original_box in knowledge_pad.contentValues(\n
filter={\'portal_type\':\'Knowledge Box\'}):\n
for original_box in knowledge_pad.objectValues(portal_type="Knowledge Box"):\n
destination_box = new_knowledge_pad[original_box.getId()]\n
if original_box.getValidationState() == \'visible\':\n
destination_box.visible()\n
elif original_box.getValidationState() == \'deleted\':\n
destination_box.delete()\n
\n
url = "%s?portal_status_message=%s&active_pad_url=%s" %(cancel_url, \n
context.Base_translateString(\'Sticked.\'), \n
new_knowledge_pad.getRelativeUrl())\n
context.REQUEST.RESPONSE.redirect(url)\n
]]></string> </value>
return context.Base_redirect(cancel_url, keep_items={\n
"portal_status_message": context.Base_translateString(\'Sticked.\')})\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -53,9 +53,8 @@
<value> <string>knowledge_pad = context.restrictedTraverse(knowledge_pad_url)\n
knowledge_pad.delete()\n
\n
url = "%s?portal_status_message=%s" %(cancel_url, \n
context.Base_translateString(\'Unsticked.\'))\n
context.REQUEST.RESPONSE.redirect(url)\n
return context.Base_redirect(cancel_url, keep_items={\n
"portal_status_message": context.Base_translateString(\'Unsticked.\')})\n
</string> </value>
</item>
<item>
......
......@@ -44,37 +44,25 @@
test(current_web_section.getPortalType()==\'Web Site\', here, current_web_section);\n
current_web_section_url python: current_web_section.absolute_url();\n
cancel_url string:${current_web_section_url}/view">\n
\n
<tal:block tal:condition="python: not createDefaultPadForUser and \n
not waitForActivitiesOnServer and\n
active_knowledge_pad is not None">\n
\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"/>\n
\n
<div class="portal-column" \n
<div class="portal-column"\n
tal:condition="python:active_knowledge_pad is not None"\n
tal:attributes="class python: test(isAnon or isAnonymousKnowledgePadUsed, \n
\'portal-column-undraggable\', \n
\'portal-column\');\n
id python: \'portal-column-%s\' %pad_column"\n
tal:define="layout active_knowledge_pad/KnowledgePad_getBoxColumnLayout;">\n
id python: \'portal-column-%s\' %pad_column">\n
\n
<span tal:condition="python: len(layout)>=pad_column+1"\n
tal:replace="structure python:\n
<tal:block define="layout active_knowledge_pad/KnowledgePad_getBoxColumnLayout"\n
condition="python: len(layout)>=pad_column+1"\n
replace="structure python:\n
active_knowledge_pad.KnowledgePad_viewColumnWidget(section_layout=layout[pad_column], \n
real_context=here,\n
cancel_url=cancel_url)"/>\n
</div>\n
\n
</tal:block>\n
\n
<!-- Create (asynch) default pad. -->\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/create_default_pad"/>\n
\n
<tal:block tal:condition="make_security_check">\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/knowledge_pad_security_check"/>\n
</tal:block>\n
\n
</tal:block>
</tal:block>
]]></unicode> </value>
</item>
......
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts67855922.32</string> </value>
<value> <string>ts95081712.83</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -40,7 +40,6 @@ var is_knowledge_template_used = 0;\n
var invisible_gadgets={};\n
\n
var create_default_knowledge_pad_script_id = "ERP5Site_createDefaultKnowledgePadListForUser";\n
var check_for_activities_on_server_script_id = "ERP5Site_hasUserActivity";\n
var knowledge_box_edit_script_id = "KnowledgeBox_baseEdit";\n
var knowledge_pad_save_layout_script_id = "KnowledgePad_saveBoxColumnLayout";\n
var knowledge_pad_delete_box_script_id = "KnowledgePad_deleteBox";\n
......@@ -55,8 +54,7 @@ function createCustomKnowledgePadOnServer(){\n
$.ajax({url:create_default_knowledge_pad_script_id, \n
data:{mode: mode,\n
default_pad_group: default_pad_group},\n
dataType: "json",\n
success:function(data){window.location=cancel_url + "/view?active_pad_url=" + data.knowledge_pad_relative_url;}});\n
success:function(data){window.location=cancel_url;}});\n
}\n
\n
function showCreateDefaultKnowledgePadWarningMessage(){\n
......@@ -151,30 +149,6 @@ function updater(url, box_relative_url, dom_id, \n
}\n
}\n
\n
\n
function checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group){\n
/* check if activities are over and refresh current page */\n
window.setInterval(\n
function () {\n
$.ajax({url:check_for_activities_on_server_script_id,\n
data: {js_call: 1,\n
mode: mode,\n
default_pad_group: default_pad_group},\n
dataType: "json",\n
success: function (data){if(data.result=="False"){window.location=return_url;}}\n
});},\n
timeout);\n
}\n
\n
function createDefaultPadOnServer(timeout, default_pad_group, return_url, mode){\n
/* create default tab on server and then check if \n
activities are over and refresh current page */\n
$.ajax({url: create_default_knowledge_pad_script_id, \n
data: {default_pad_group: default_pad_group,\n
mode: mode},\n
success: function(data){checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group);}});\n
}\n
\n
function submitGadgetPreferenceFormOnEnter(event, \n
form_fields_main_prefix, \n
box_relative_url, \n
......@@ -511,7 +485,7 @@ $(document).ready(initialize);
</item>
<item>
<key> <string>size</string> </key>
<value> <int>19272</int> </value>
<value> <int>18130</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
This diff is collapsed.
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