Commit bae11843 authored by Ivan Tyagov's avatar Ivan Tyagov

Use proper activity tag to prevent creating default Knowledge Pads in...

Use proper activity tag to prevent creating default Knowledge Pads in background in case we already have such a default one Pad being indexed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32741 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1ab06076
......@@ -59,6 +59,7 @@
# knowledge_box = knowledge_pad.newContent(\n
# portal_type=\'Knowledge Box\',\n
# specialise=\'portal_gadgets/km_my_tasks\',\n
# activate_kw=activate_kw\n
# )\n
# knowledge_box.visible()\n
pass\n
......@@ -72,7 +73,7 @@ pass\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>knowledge_pad</string> </value>
<value> <string>knowledge_pad, **activate_kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -99,6 +100,7 @@ pass\n
<value>
<tuple>
<string>knowledge_pad</string>
<string>activate_kw</string>
</tuple>
</value>
</item>
......
......@@ -54,7 +54,12 @@
<item>
<key> <string>_body</string> </key>
<value> <string>knowledge_pad = None\n
portal = context.getPortalObject()\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 user_pref is not None:\n
......@@ -89,7 +94,8 @@ if knowledge_pad is None:\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
title = context.Base_translateString(\'Tab 1\'),\n
activate_kw = activate_kw)\n
if is_web_mode:\n
if context.getPortalType() == \'Web Site\' and default_pad_group in (\'\', None,):\n
# script is called within Front Page Gadgets view\n
......@@ -109,8 +115,7 @@ if owner is not None:\n
knowledge_pad.reindexObject()\n
\n
# set default gadgets\n
context.ERP5Site_createDefaultKnowledgeBox(knowledge_pad)\n
\n
context.ERP5Site_createDefaultKnowledgeBox(knowledge_pad, activate_kw=activate_kw)\n
return knowledge_pad.getRelativeUrl()\n
</string> </value>
</item>
......@@ -155,7 +160,10 @@ return knowledge_pad.getRelativeUrl()\n
<string>knowledge_pad</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>user_pref</string>
<string>tag</string>
<string>activate_kw</string>
<string>is_web_mode</string>
<string>pref_pads</string>
<string>filter</string>
......
......@@ -53,17 +53,30 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if active_knowledge_pad is None and mode is None:\n
# only if asynchronous checks\n
<value> <string>portal = context.getPortalObject()\n
\n
if active_knowledge_pad is None and js_call:\n
# only for asynchronous checks\n
knowledge_pads = context.ERP5Site_getKnowledgePadListForUser(mode=mode)\n
active_knowledge_pad,knowledge_pads = \\\n
active_knowledge_pad, knowledge_pads = \\\n
context.ERP5Site_getActiveKnowledgePadForUser(knowledge_pads)\n
\n
if active_knowledge_pad is None:\n
return \'False\'\n
pending_activities = active_knowledge_pad.hasActivity()\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
if js_call:\n
return str(pending_activities)\n
return pending_activities\n
return str(is_pending_create_activities)\n
return is_pending_create_activities\n
</string> </value>
</item>
<item>
......@@ -74,7 +87,7 @@ return pending_activities\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_knowledge_pad=None, mode=None, js_call=0</string> </value>
<value> <string>active_knowledge_pad=None, mode=None, default_pad_group=\'\', js_call=0</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -94,7 +107,7 @@ return pending_activities\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -102,13 +115,16 @@ return pending_activities\n
<tuple>
<string>active_knowledge_pad</string>
<string>mode</string>
<string>default_pad_group</string>
<string>js_call</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>None</string>
<string>knowledge_pads</string>
<string>_getiter_</string>
<string>pending_activities</string>
<string>tag</string>
<string>is_pending_create_activities</string>
<string>str</string>
</tuple>
</value>
......@@ -124,6 +140,7 @@ return pending_activities\n
<tuple>
<none/>
<none/>
<string></string>
<int>0</int>
</tuple>
</value>
......
......@@ -44,20 +44,17 @@
default_pad_group python: \'\';\n
knowledge_pads python:\n
here.ERP5Site_getKnowledgePadListForUser(mode=mode);\n
struct python:\n
here.ERP5Site_getActiveKnowledgePadForUser(\n
knowledge_pads,\n
);\n
struct python: here.ERP5Site_getActiveKnowledgePadForUser(knowledge_pads);\n
active_knowledge_pad python: struct[0];\n
knowledge_pads python: struct[1];\n
hasUserActivity python:\n
here.ERP5Site_hasUserActivity(active_knowledge_pad,\n
mode=mode);\n
mode=mode,\n
\t\t\t\t\t\t default_pad_group=default_pad_group);\n
isAnon python: here.portal_membership.isAnonymousUser();\n
createDefaultPadForUser python: len(knowledge_pads)==0 and\n
hasUserActivity;\n
waitForActivitiesOnServer python: len(knowledge_pads)>=1 and \n
active_knowledge_pad is None and\n
createDefaultPadForUser python: len(knowledge_pads)==0 and\n
not hasUserActivity;\n
waitForActivitiesOnServer python: active_knowledge_pad is None and\n
hasUserActivity;\n
isUserAllowedToCreateKnowledgePads\n
context/Base_isUserAllowedToUseKnowledgePad;\n
......@@ -95,18 +92,21 @@
\n
</tal:block>\n
\n
<div tal:condition="python: waitForActivitiesOnServer and isUserAllowedToCreateKnowledgePads">\n
<div tal:condition="python: waitForActivitiesOnServer and \n
isUserAllowedToCreateKnowledgePads">\n
<div class="wait_block">\n
<h2 i18n:translate="" i18n:domain="ui"> \n
Please wait until your home is being updated.</h2>\n
<p i18n:translate="" i18n:domain="ui"> You\'ll be automatically redirected.</p>\n
<script type="text/javascript">\n
checkForActivitiesOnServer(5000, \'view\');\n
checkForActivitiesOnServer(5000, \'view\', \'erp5_front\', \'\');\n
</script>\n
</div>\n
</div>\n
\n
<div tal:condition="python: createDefaultPadForUser and isUserAllowedToCreateKnowledgePads">\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 until your tab is being prepared.\n
......
......@@ -15,7 +15,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts60374556.81</string> </value>
<value> <string>ts66484637.32</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -111,12 +111,14 @@ function updater(url, box_relative_url, dom_id, \n
}\n
}\n
\n
function checkForActivitiesOnServer(timeout, return_url){\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
d = MochiKit.Async.doSimpleXMLHttpRequest(\'ERP5Site_hasUserActivity\',\n
{\'js_call\': 1});\n
{\'js_call\': 1,\n
\'mode\': mode,\n
\'default_pad_group\': default_pad_group});\n
d.addCallback(handleServerSuccess);\n
function handleServerSuccess(res){\n
if(res.responseText==\'False\'){window.location=return_url;}\n
......@@ -375,7 +377,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>13319</int> </value>
<value> <long>13496</long> </value>
</item>
<item>
<key> <string>title</string> </key>
......
475
\ No newline at end of file
476
\ No newline at end of file
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