Commit ed3e5222 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Knowledge Pad can have several publication_section relations.

also fix a bug in getting real context logic where url is like web_site/lang/referefnce.
parent 98a7b308
......@@ -100,7 +100,7 @@
<tal:block\n
tal:condition="not: isKnowledgePadTemplateUsed"\n
tal:define="is_customized_pad python:\n
active_knowledge_pad.getPublicationSectionValue()==context and\n
context in active_knowledge_pad.getPublicationSectionValueList() and\n
active_knowledge_pad.getGroup()==default_pad_group">\n
\n
<a tal:condition="not: is_customized_pad"\n
......
......@@ -76,7 +76,7 @@ for pref in (system_pref, user_pref):\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: x.getPublicationSectionValue()==context, \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
......
......@@ -69,23 +69,24 @@ active_knowledge_pad, knowledge_pads = \\\n
if active_knowledge_pad is not None:\n
return active_knowledge_pad, knowledge_pads\n
\n
# in Web Mode we can have a temporary Web Site objects created based on current language\n
# in Web Mode we can have a temporary object created based on current language, document by reference\n
real_context = context\n
if context.isTempObject():\n
real_context = context.getParentValue()\n
while real_context.isTempObject():\n
real_context = real_context.getParentValue()\n
real_context_url = real_context.getRelativeUrl()\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
publication_section = knowledge_pad.getPublicationSectionValue()\n
if publication_section == real_context and pad_state in visible_state_list:\n
if publication_section.getPortalType() == \'Web Site\' and default_pad_group in MARKER:\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
# ERP5 Web Site front gadget\n
return knowledge_pad, knowledge_pads\n
elif publication_section == real_context and knowledge_pad.getGroup() == default_pad_group:\n
elif real_context_url in publication_section_list and 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 publication_section == None and default_pad_group in MARKER and pad_state in visible_state_list:\n
elif len(publication_section_list) == 0 and default_pad_group in MARKER and pad_state in visible_state_list:\n
# ERP5 Site front gadget \n
return knowledge_pad, knowledge_pads \n
\n
......
......@@ -57,12 +57,10 @@ from zExceptions import Unauthorized\n
\n
def filterKnowledgePadListForContext(results, mode, \n
default_pad_group):\n
# when we use URL as a way to determine site\'s language do not\n
# use (especially for Web Site\'s root) current context which is the language\n
# code. Instead we use its parent value which is the real context \n
# in Web Mode we can have a temporary object created based on current language, document by reference\n
real_context = context\n
if context.getId() in context.Localizer.get_supported_languages():\n
real_context = context.getParentValue() \n
while real_context.isTempObject():\n
real_context = real_context.getParentValue()\n
real_context_url = real_context.getRelativeUrl()\n
\n
if mode == \'erp5_front\':\n
......@@ -72,11 +70,11 @@ def filterKnowledgePadListForContext(results, mode, \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: x.getPublicationSection() == real_context_url and \\\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: x.getPublicationSection() == real_context_url or \\\n
results = filter(lambda x: real_context_url in x.getPublicationSectionList() or \\\n
x.getGroup() == default_pad_group, results)\n
return results\n
\n
......
2012-12-14 Kazuhiko
* Knowledge Pad can have several publication_section relations.
2012-12-10 Kazuhiko
* support predicate in Knowled Box for more flexibility.
......
753
\ No newline at end of file
754
\ 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