Commit bbdc8185 authored by Fabien Morin's avatar Fabien Morin

improve WebSection_getDocumentValue to be more precise

remove condition on captcha displaying

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23622 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e0d172a5
......@@ -53,31 +53,37 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># get some information about the context\n
<value> <string>\'\'\'\n
This script generate some web page name related to the context\n
ex :\n
DeclarationTVA-Draft-PDFDocument_viewAttachmentList-Upload.Button-Citizen\n
\'\'\'\n
\n
# get some information about the context\n
absolute_url = context.getAbsoluteUrl()\n
portal_type = context.getPortalType()\n
request = context.REQUEST\n
form_id = request.get(\'form_id\', None)\n
\n
# remove spaces\n
portal_type = portal_type.replace(\' \', \'\')\n
id = context.getId()\n
\n
# redirect to the good help webpage using context informations\n
help_page_name = []\n
help_page_name.append(\'HelpOn\')\n
web_page_name = []\n
web_page_name.append(portal_type)\n
if getattr(context, \'getValidationStateTitle\', None) and context.getValidationStateTitle():\n
web_page_name.append(context.getValidationStateTitle())\n
\n
if portal_type != \'Web Site\':\n
state = context.getValidationState()\n
\n
#make the name of the page to link to\n
pt_name = portal_type.replace(\' \', \'_\')\n
pt_name = pt_name.lower()\n
# in a first version, we don\'t use portal type to not have so much\n
# documentation to write\n
#help_page_name.append(pt_name)\n
help_page_name.append(state)\n
if form_id:\n
web_page_name.append(form_id)\n
\n
else:\n
help_page_name.append(id)\n
help_page_name = \'_\'.join(help_page_name)\n
web_site_id = context.getWebSiteValue().getId()\n
if web_site_id == \'dgid\':\n
web_page_name.append(\'Agent\')\n
if web_site_id == \'egov_portal\':\n
web_page_name.append(\'Citizen\')\n
\n
return help_page_name\n
return \'-\'.join(web_page_name)\n
</string> </value>
</item>
<item>
......@@ -118,10 +124,13 @@ return help_page_name\n
<string>context</string>
<string>absolute_url</string>
<string>portal_type</string>
<string>request</string>
<string>None</string>
<string>form_id</string>
<string>id</string>
<string>help_page_name</string>
<string>state</string>
<string>pt_name</string>
<string>web_page_name</string>
<string>getattr</string>
<string>web_site_id</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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
This script is part of ERP5 Web\n
\n
ERP5 Web is a business template of ERP5 which provides a way\n
to create web sites which can display selected\n
ERP5 contents through multiple custom web layouts.\n
\n
The default implementation searches for\n
documents which are in the user language if any\n
and which reference is equal to the name parameter.\n
\n
Other implementations are possible: ex. display the last\n
version in the closest language rather than\n
the latest version in the user language.\n
\n
NOTE:\n
- the portal parameter was introduced to\n
fix acquisition issues within the _aq_dynamic\n
lookup from WebSection class.\n
"""\n
if portal is None: portal = context.getPortalObject()\n
portal_catalog = portal.portal_catalog\n
# The list of portal types here should be large enough to include\n
# all portal_types defined in the various sections so that\n
# href tags which point to a document by reference can still work.\n
valid_portal_type_list = portal.getPortalDocumentTypeList()\n
\n
# Find the applicable language\n
if language is None:\n
language = portal.Localizer.get_selected_language()\n
\n
if validation_state is None:\n
validation_state = (\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'shared\', \'shared_alive\', \'public\', \'validated\')\n
\n
# Search the catalog for all documents matching the reference\n
# this will only return documents which are accessible by the user\n
web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
language=language,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0 and language != \'en\':\n
# Search again with English as a fallback.\n
web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
language=\'en\',\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
# Search again without the language\n
web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
name_without_web_site = \'-\'.join(name.split(\'-\')[:-1])+\'%\'\n
# Search again without the website\n
web_page_list = portal_catalog(reference=name_without_web_site,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
name_without_portal_type = \'%\'+\'-\'.join(name.split(\'-\')[1:])\n
# Search again without the portal_type\n
web_page_list = portal_catalog(reference=name_without_portal_type,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
name_without_portal_type_and_web_site = \'%\'+\'-\'.join(name.split(\'-\')[1:-1])+\'%\'\n
# Search again without the portal_type and web_site\n
web_page_list = portal_catalog(reference=name_without_portal_type_and_web_site,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
name_without_web_site_and_view = \'-\'.join(name.split(\'-\')[:-2])+\'%\'\n
# Search again without the portal_type and view\n
web_page_list = portal_catalog(reference=name_without_web_site_and_view,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
state = \'%\'+name.split(\'-\')[1]+\'%\'\n
# Search only with state\n
web_page_list = portal_catalog(reference=state,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
limit=1,\n
**kw)\n
\n
if len(web_page_list) == 0:\n
# Default returns None\n
web_page = None\n
else:\n
# Try to get the first page on the list\n
web_page = web_page_list[0]\n
web_page = web_page.getObject()\n
\n
# return the web page\n
return web_page\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>name, portal=None, language=None, validation_state=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>name</string>
<string>portal</string>
<string>language</string>
<string>validation_state</string>
<string>kw</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_catalog</string>
<string>valid_portal_type_list</string>
<string>_apply_</string>
<string>web_page_list</string>
<string>len</string>
<string>_getitem_</string>
<string>name_without_web_site</string>
<string>name_without_portal_type</string>
<string>name_without_portal_type_and_web_site</string>
<string>name_without_web_site_and_view</string>
<string>state</string>
<string>web_page</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getDocumentValue</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -82,7 +82,7 @@ Description:\n
<input type="hidden" name="current_action" value="" \n
tal:attributes="value request/current_action" />-->\n
<div class="onright">\n
<div class="erp5_captcha" tal:condition="python: here.portal_membership.isAnonymousUser()">\n
<div class="erp5_captcha">\n
<img src="Captcha_getCaptchaFile?display=thumbnail&amp;format=&amp;resolution=75" alt="captcha"/>\n
<input class="captcha_text" type="text" size="6" name="captcha_text"/>\n
</div>\n
......
304
\ No newline at end of file
305
\ 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