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