Commit bb0d3b62 authored by Ivan Tyagov's avatar Ivan Tyagov

First select pads for current user, then if it's anonymous user and it's...

First select pads for current user, then if it's anonymous user and it's preferred so return public knowledge pads for context. This change allows logged in users to have their own customized pads independently from value of a web site preference : "Force Anonymous Gadget " and still we can show or hide public pads for context for anonymous.

In case still we want to show default pads for logged in users we can use preferences which can contain knowledge pads templates. The templates can itself be customized which allows a KM or ERP5 UI site to show a set of default pads for any context which with a single click can be adjusted by user to his needs.
parent fc3fa3ab
......@@ -60,8 +60,8 @@ list_mode = request.get(\'list_mode\', False)\n
dialog_mode = request.get(\'dialog_mode\', False)\n
isAnonymousKnowledgePadUsed = request.get(\'is_anonymous_knowledge_pad_used\', False)\n
\n
if portal.portal_membership.isAnonymousUser() or \\\n
isAnonymousKnowledgePadUsed or \\\n
if (portal.portal_membership.isAnonymousUser() and \\\n
isAnonymousKnowledgePadUsed) or \\\n
list_mode == True or \\\n
dialog_mode == True:\n
return False\n
......
......@@ -53,7 +53,6 @@
<value> <string>request = context.REQUEST\n
isAnon = context.portal_membership.isAnonymousUser()\n
isAnonymousKnowledgePadUsed = request.get(\'is_anonymous_knowledge_pad_used\', 0);\n
from zExceptions import Unauthorized\n
\n
def filterKnowledgePadListForContext(results, mode, \n
default_pad_group):\n
......@@ -79,15 +78,19 @@ def filterKnowledgePadListForContext(results, mode, \n
kw = {\'portal_type\': \'Knowledge Pad\',\n
\'sort_on\': ((\'creation_date\', \'ascending\',),),\n
\'limit\': 50,}\n
if isAnon or isAnonymousKnowledgePadUsed:\n
results = context.knowledge_pad_module.searchFolder(\n
validation_state = (\'public\',),\n
**kw)\n
else:\n
results = context.knowledge_pad_module.searchFolder(\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
......
758
\ No newline at end of file
759
\ 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