Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
41d082de
Commit
41d082de
authored
Mar 24, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Plain Diff
Merge "erp5_knowledge_pad: drop complicated and broken logic to wait that new pads are indexed
parents
1cecdc02
9e551336
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
199 additions
and
550 deletions
+199
-550
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/Base_viewKnowledgePadMacroLibrary.xml
.../erp5_knowledge_pad/Base_viewKnowledgePadMacroLibrary.xml
+28
-61
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_addNewKnowledgePad.xml
..._skins/erp5_knowledge_pad/ERP5Site_addNewKnowledgePad.xml
+5
-2
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_createDefaultKnowledgePadListForUser.xml
...dge_pad/ERP5Site_createDefaultKnowledgePadListForUser.xml
+31
-32
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_deleteKnowledgePad.xml
..._skins/erp5_knowledge_pad/ERP5Site_deleteKnowledgePad.xml
+14
-32
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getActiveKnowledgePadForUser.xml
...5_knowledge_pad/ERP5Site_getActiveKnowledgePadForUser.xml
+22
-31
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getActiveKnowledgePadForUserFromRequest.xml
..._pad/ERP5Site_getActiveKnowledgePadForUserFromRequest.xml
+0
-98
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getKnowledgePadListForUser.xml
...rp5_knowledge_pad/ERP5Site_getKnowledgePadListForUser.xml
+41
-74
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_hasUserActivity.xml
...tal_skins/erp5_knowledge_pad/ERP5Site_hasUserActivity.xml
+0
-97
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_toggleActiveKnowledgePad.xml
.../erp5_knowledge_pad/ERP5Site_toggleActiveKnowledgePad.xml
+1
-1
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_viewHomeAreaRenderer.xml
...kins/erp5_knowledge_pad/ERP5Site_viewHomeAreaRenderer.xml
+0
-12
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_stickKnowledgePad.xml
...skins/erp5_knowledge_pad/WebSection_stickKnowledgePad.xml
+5
-12
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_unStickKnowledgePad.xml
...ins/erp5_knowledge_pad/WebSection_unStickKnowledgePad.xml
+2
-3
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_viewKnowledgePadColumn.xml
.../erp5_knowledge_pad/WebSection_viewKnowledgePadColumn.xml
+7
-19
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/erp5_knowledge_box.js.xml
...portal_skins/erp5_knowledge_pad/erp5_knowledge_box.js.xml
+3
-29
product/ERP5/tests/testKM.py
product/ERP5/tests/testKM.py
+40
-47
No files found.
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/Base_viewKnowledgePadMacroLibrary.xml
View file @
41d082de
...
...
@@ -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
<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(**kw);\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 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 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;"
></tal:block>
\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&cancel_url=${cancel_url}&mode=${mode}&active_pad_relative_url=${active_knowledge_pad_relative_url}"
\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&cancel_url=${cancel_url}&mode=${mode}&active_pad_relative_url=${active_knowledge_pad/getRelativeUrl}"
\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
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
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_addNewKnowledgePad.xml
View file @
41d082de
...
...
@@ -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
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_createDefaultKnowledgePadListForUser.xml
View file @
41d082de
...
...
@@ -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
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
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
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 Non
e:\n
break
\n
els
e:\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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_deleteKnowledgePad.xml
View file @
41d082de
...
...
@@ -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
<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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getActiveKnowledgePadForUser.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getActiveKnowledgePadForUserFromRequest.xml
deleted
100644 → 0
View file @
1cecdc02
<?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>
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_getKnowledgePadListForUser.xml
View file @
41d082de
...
...
@@ -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
# 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
# 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
results = filter(lambda x: real_context_url in x.getPublicationSectionList() and \\\n
x.getGroup() is None, results)\n
elif mode == \'web_section\':\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
results = filter(lambda x: real_context_url in x.getPublicationSectionList() or \\\n
x.getGroup() == default_pad_group, results)\n
return results\n
\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
kw = {\'portal_type\': \'Knowledge Pad\',\n
\'sort_on\': ((\'creation_date\', \'ascending\',),),\n
\'limit\': 50,}\n
results = []\n
def search(container, *states, **kw):\n
# call getObject() explicitly so that further getter methods do not\n
# invoke getObject().\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
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
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
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
\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(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
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_hasUserActivity.xml
deleted
100644 → 0
View file @
1cecdc02
<?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>
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_toggleActiveKnowledgePad.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/ERP5Site_viewHomeAreaRenderer.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_stickKnowledgePad.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_unStickKnowledgePad.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/WebSection_viewKnowledgePadColumn.xml
View file @
41d082de
...
...
@@ -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>
...
...
bt5/erp5_knowledge_pad/SkinTemplateItem/portal_skins/erp5_knowledge_pad/erp5_knowledge_box.js.xml
View file @
41d082de
...
...
@@ -12,7 +12,7 @@
</item>
<item>
<key>
<string>
_EtagSupport__etag
</string>
</key>
<value>
<string>
ts
67855922.32
</string>
</value>
<value>
<string>
ts
95081712.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>
1
9272
</int>
</value>
<value>
<int>
1
8130
</int>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
...
...
product/ERP5/tests/testKM.py
View file @
41d082de
...
...
@@ -134,6 +134,8 @@ class TestKM(TestKMMixIn):
mode
=
'web_section'
)
self
.
web_section_content_knowledge_pad
=
portal
.
restrictedTraverse
(
self
.
web_section_content_knowledge_pad_relative_url
)
self
.
web_front_knowledge_pad
.
visible
()
self
.
web_section_knowledge_pad
.
visible
()
self
.
tic
()
# Publish all knowledge pad gadgets
for
gadget
in
self
.
portal
.
portal_gadgets
.
objectValues
():
...
...
@@ -149,8 +151,8 @@ class TestKM(TestKMMixIn):
def
test_02
(
self
):
""" Check Gadgets """
portal
=
self
.
getPortal
()
knowledge_pad_module
=
getattr
(
portal
,
'knowledge_pad_module'
)
portal
=
self
.
portal
knowledge_pad_module
=
portal
.
knowledge_pad_module
# remove created by login method pads
knowledge_pad_module
.
manage_delObjects
(
list
(
knowledge_pad_module
.
objectIds
()))
self
.
tic
()
...
...
@@ -422,11 +424,8 @@ class TestKM(TestKMMixIn):
def
test_04WebFrontGadgets
(
self
):
""" Check different Web / KM Gadgets """
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
# all known so far gadgets
portal_gadgets
=
portal
.
portal_gadgets
portal_gadgets
=
self
.
portal
.
portal_gadgets
km_my_tasks_gadget
=
portal_gadgets
.
km_my_tasks
km_my_documents_gadget
=
portal_gadgets
.
km_my_documents
km_my_contacts_gadget
=
portal_gadgets
.
km_my_contacts
...
...
@@ -439,7 +438,7 @@ class TestKM(TestKMMixIn):
# Web Front gadgets
web_front_gadgets
=
[
km_my_tasks_gadget
,
km_my_documents_gadget
,
km_my_contacts_gadget
]
for
gadget
in
web_front_gadgets
:
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
gadget
.
getUid
()]
)
self
.
tic
()
# check that gadgets are added to web front page view
...
...
@@ -453,7 +452,7 @@ class TestKM(TestKMMixIn):
km_my_tasks_gadget
=
portal
.
portal_gadgets
.
km_my_tasks
# add gadget
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_my_tasks_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
km_my_tasks_gadget
.
getUid
()]
)
# "My Tasks" gadget (add a new document which should be shown shown in it)
project
=
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
,
\
...
...
@@ -492,7 +491,7 @@ class TestKM(TestKMMixIn):
km_my_documents_gadget
=
portal
.
portal_gadgets
.
km_my_documents
# add gadget
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_my_documents_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
km_my_documents_gadget
.
getUid
()]
)
# "My Documents" gadget (add a new document which should be shown shown in it)
web_page
=
portal
.
web_page_module
.
newContent
(
\
...
...
@@ -535,7 +534,7 @@ class TestKM(TestKMMixIn):
km_my_contacts_gadget
=
portal
.
portal_gadgets
.
km_my_contacts
# add gadget
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_my_contacts_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
km_my_contacts_gadget
.
getUid
()]
)
# "My Contacts" gadget (add a new document which should be shown shown in it)
person
=
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -567,22 +566,19 @@ class TestKM(TestKMMixIn):
def
test_08WebSectionGadget
(
self
):
""" Check Web Section Gadgets """
portal
=
self
.
getPortal
()
km_subsection_gadget
=
portal
.
portal_gadgets
.
km_subsection
km_latest_documents_gadget
=
portal
.
portal_gadgets
.
km_latest_documents
km_assigned_member_gadget
=
portal
.
portal_gadgets
.
km_assigned_member
km_document_relations_gadget
=
portal
.
portal_gadgets
.
km_document_relations
web_section_gadgets
=
[
km_subsection_gadget
,
km_latest_documents_gadget
,
km_assigned_member_gadget
]
portal_gadgets
=
self
.
portal
.
portal_gadgets
pad
=
self
.
web_section_knowledge_pad
web_section_gadgets
=
(
portal_gadgets
.
km_subsection
,
portal_gadgets
.
km_latest_documents
,
portal_gadgets
.
km_assigned_member
)
for
gadget
in
web_section_gadgets
:
self
.
web_section_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
gadget
.
getUid
()]})
pad
.
KnowledgePad_addBoxList
(
uids
=
[
gadget
.
getUid
()])
self
.
portal
.
ERP5Site_toggleActiveKnowledgePad
(
pad
)
self
.
tic
()
# check that gadgets are added to web section page view
response
=
self
.
publish
(
'%s/WebSection_viewKnowledgePadColumn?active_pad_url=%s'
\
%
(
self
.
web_section_url
,
self
.
web_section_knowledge_pad
.
getRelativeUrl
())
,
self
.
auth
)
response
=
self
.
publish
(
self
.
web_section_url
+
'/WebSection_viewKnowledgePadColumn?gadget_mode='
,
self
.
auth
)
for
gadget
in
web_section_gadgets
:
self
.
assertTrue
(
gadget
.
getTitle
()
in
response
.
getBody
())
...
...
@@ -595,7 +591,7 @@ class TestKM(TestKMMixIn):
# add gadget
self
.
web_section_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_latest_documents_gadget
.
getUid
()]}
)
uids
=
[
km_latest_documents_gadget
.
getUid
()]
)
# "Latest Content" gadget
gadget_view_form_id
=
km_latest_documents_gadget
.
view_form_id
...
...
@@ -637,12 +633,11 @@ class TestKM(TestKMMixIn):
def
test_11AssignedMembersGadget
(
self
):
""" Check Assigned Members Gadgets """
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
km_assigned_member_gadget
=
portal
.
portal_gadgets
.
km_assigned_member
# add gadget
self
.
web_section_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_assigned_member_gadget
.
getUid
()]}
)
uids
=
[
km_assigned_member_gadget
.
getUid
()]
)
gadget_view_form_id
=
km_assigned_member_gadget
.
view_form_id
project
=
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
,
...
...
@@ -682,18 +677,17 @@ class TestKM(TestKMMixIn):
def
test_11WebSectionContentGadget
(
self
):
""" Check Web Section Content Gadgets """
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
km_document_relations_gadget
=
portal
.
portal_gadgets
.
km_document_relations
web_section_content_gadgets
=
[
km_document_relations_gadget
]
pad
=
self
.
web_section_content_knowledge_pad
web_section_content_gadgets
=
(
self
.
portal
.
portal_gadgets
.
km_document_relations
,)
for
gadget
in
web_section_content_gadgets
:
self
.
web_section_content_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
gadget
.
getUid
()]})
pad
.
KnowledgePad_addBoxList
(
uids
=
[
gadget
.
getUid
()])
self
.
portal
.
ERP5Site_toggleActiveKnowledgePad
(
pad
)
self
.
tic
()
# check that gadgets are added to web section page view
response
=
self
.
publish
(
'%s/WebSection_viewKnowledgePadColumn?active_pad_url=%s'
\
%
(
self
.
web_page_url
,
self
.
web_section_content_knowledge_pad
.
getRelativeUrl
())
,
self
.
auth
)
response
=
self
.
publish
(
self
.
web_section_url
+
'/WebSection_viewKnowledgePadColumn?gadget_mode='
,
self
.
auth
)
for
gadget
in
web_section_content_gadgets
:
self
.
assertTrue
(
gadget
.
getTitle
()
in
response
.
getBody
())
...
...
@@ -706,7 +700,7 @@ class TestKM(TestKMMixIn):
# add gadget
self
.
web_section_content_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_document_relations_gadget
.
getUid
()]}
)
uids
=
[
km_document_relations_gadget
.
getUid
()]
)
self
.
tic
()
# "Relation" gadget
...
...
@@ -757,7 +751,6 @@ class TestKM(TestKMMixIn):
nothing is raised but a message is shown to user.
"""
portal
=
self
.
getPortal
()
request
=
self
.
app
.
REQUEST
portal_gadgets
=
portal
.
portal_gadgets
url
=
'%s/ERP5Site_viewHomeAreaRenderer?gadget_mode=web_front'
%
self
.
web_site_url
...
...
@@ -765,7 +758,7 @@ class TestKM(TestKMMixIn):
self
.
assertTrue
(
self
.
web_front_knowledge_pad
.
getTitle
()
in
response
.
getBody
())
gadget
=
portal_gadgets
.
km_latest_documents
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
gadget
.
getUid
()]
)
self
.
tic
()
# check that gadgets are added to web front page view
...
...
@@ -798,7 +791,7 @@ class TestKM(TestKMMixIn):
web_site_browser_gadget
=
portal
.
portal_gadgets
.
web_site_browser
# add gadget
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
web_site_browser_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
web_site_browser_gadget
.
getUid
()]
)
self
.
tic
()
self
.
changeSkin
(
'KM'
)
...
...
@@ -833,7 +826,7 @@ class TestKM(TestKMMixIn):
km_my_contacts_gadget
=
portal
.
portal_gadgets
.
km_my_contacts
# test directly adding a gadget
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_my_contacts_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
km_my_contacts_gadget
.
getUid
()]
)
self
.
tic
()
self
.
assertSameSet
([
km_my_contacts_gadget
],
[
x
.
getSpecialiseValue
()
for
x
in
self
.
web_front_knowledge_pad
.
objectValues
()])
...
...
@@ -847,7 +840,7 @@ class TestKM(TestKMMixIn):
selection_name
=
'gadget_tool_view_gadget_add_dialog'
self
.
app
.
REQUEST
.
set
(
'list_selection_name'
,
selection_name
)
portal
.
portal_selections
.
setSelectionParamsFor
(
selection_name
,
{
'uids'
:[
km_my_documents_gadget
.
getUid
()]})
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
**
{
'uids'
:[
km_my_contacts_gadget
.
getUid
()]}
)
self
.
web_front_knowledge_pad
.
KnowledgePad_addBoxList
(
uids
=
[
km_my_contacts_gadget
.
getUid
()]
)
self
.
tic
()
# now even though we explicitly add only one gadget KnowledgePad_addBoxList should check and add one
# in listbox selection as well
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment