Commit fa2d313e authored by Fabien Morin's avatar Fabien Morin

2008-09-09 fabien

* report_section refactoring to be more generic and easier to customize with more pdf

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23525 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7a258685
...@@ -80,7 +80,7 @@ message = \'\'\n ...@@ -80,7 +80,7 @@ message = \'\'\n
# add the attachments :\n # add the attachments :\n
request = context.REQUEST\n request = context.REQUEST\n
translateString = context.Base_translateString\n translateString = context.Base_translateString\n
result, mode = context.Base_edit(\'DeclarationTVA_viewAttachmentReportSection\', silent_mode=1, field_prefix=\'your_\')\n result, mode = context.Base_edit(\'PDFDocument_viewAttachmentReportSection\', silent_mode=1, field_prefix=\'your_\')\n
attachment_count = 0\n attachment_count = 0\n
\n \n
if mode == \'edit\':\n if mode == \'edit\':\n
...@@ -99,8 +99,8 @@ if attachment_count:\n ...@@ -99,8 +99,8 @@ if attachment_count:\n
mapping = dict(attachment_count=attachment_count))\n mapping = dict(attachment_count=attachment_count))\n
\n \n
next_url_dict = {\n next_url_dict = {\n
\'DeclarationTVA_view\' : \'DeclarationTVA_viewAttachmentList\',\n \'DeclarationTVA_view\' : \'PDFDocument_viewAttachmentList\',\n
\'SubscriptionForm_view\': \'SubscriptionForm_viewAttachmentList\',\n \'SubscriptionForm_view\': \'PDFDocument_viewAttachmentList\',\n
}\n }\n
\n \n
# edit the document with the entered data before to change of state\n # edit the document with the entered data before to change of state\n
......
<?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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n
\n
# If we create one portal type per attachment... no need\n
# but if attachment can be text, image, etc. We can not\n
# A simple solution: use title to group\n
type_list = map(lambda x: x.Type(), context.allowedContentTypes())\n
file_type_list = (\'Image\', \'File\')\n
sub_form_type_list = filter(lambda x: x not in file_type_list, type_list)\n
\n
# A simple solution: use title to group\n
viewable_content_list = context.contentValues(portal_type=type_list, checked_permission=\'View\')\n
content_group_dict = {}\n
for content in viewable_content_list:\n
title = content.getTitle()\n
content_group_dict.setdefault(title, [])\n
content_group_dict[title].append(content)\n
\n
# Now sort every group by creation date (to be done)\n
# XXXX\n
\n
# Define some hard coded values\n
\n
attachement_method = getattr(context, \'%s_getApplicationIncomeDict\' % context.getPortalType().replace(\' \', \'\'))\n
attachement_type_dict = attachement_method()\n
\n
# add other group title\n
for group_title in attachement_type_dict.keys():\n
content_group_dict.setdefault(group_title,[])\n
\n
# Now create a sorted list of titles of attachments\n
title_list = content_group_dict.keys()\n
title_list.sort()\n
\n
# Now build the report sections\n
from Products.ERP5Form.Report import ReportSection\n
result = []\n
for title in title_list:\n
if attachement_type_dict.has_key(title):\n
description = attachement_type_dict[title].get(\'description\', \'No description\')\n
requirement = attachement_type_dict[title].get(\'requirement\', \'No requirement\')\n
else:\n
description = \'No description\'\n
requirement = \'Requirement not found\'\n
\n
selection_params={\'title\': title,\n
\'description\': N_(description),\n
\'attachment_list\' : content_group_dict[title]}\n
\n
# XXX display requirement word only on required attachments\n
if requirement == \'Required\':\n
selection_params.update({\'requirement\': N_(requirement)})\n
else:\n
selection_params.update({\'requirement\': \'\'})\n
\n
\n
result.append(\n
ReportSection(\n
path=context.getPhysicalPath(),\n
# title=title,\n
level=1,\n
form_id=\'PDFDocument_viewAttachmentReportSection\',\n
selection_name=\'attachment_selection\',\n
selection_params=selection_params,\n
listbox_display_mode=\'FlatListMode\')\n
)\n
\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>N_</string>
<string>map</string>
<string>type_list</string>
<string>file_type_list</string>
<string>filter</string>
<string>sub_form_type_list</string>
<string>viewable_content_list</string>
<string>content_group_dict</string>
<string>_getiter_</string>
<string>content</string>
<string>title</string>
<string>_getitem_</string>
<string>getattr</string>
<string>attachement_method</string>
<string>attachement_type_dict</string>
<string>group_title</string>
<string>title_list</string>
<string>Products.ERP5Form.Report</string>
<string>ReportSection</string>
<string>result</string>
<string>description</string>
<string>requirement</string>
<string>selection_params</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PDFDocument_getReportSectionList</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>request = context.REQUEST\n
translateString = context.Base_translateString\n
\n
result, mode = context.Base_edit(\'PDFDocument_viewAttachmentReportSection\', silent_mode=1, field_prefix=\'your_\')\n
\n
if mode == \'edit\':\n
(kw, encapsulated_editor_list) = result\n
attachment_list = zip(kw[\'attachment\'], kw[\'attachment_title\'])\n
attachment_count = 0\n
# XXX make sure it is a list\n
for attachment, title in attachment_list:\n
if attachment:\n
attachment_count += 1\n
file = context.newContent(portal_type=\'File\', file=attachment, title=title)\n
\n
if attachment_count:\n
portal_status_message = translateString("Added ${attachment_count} attachment(s) to the current form.",\n
mapping = dict(attachment_count=attachment_count))\n
else:\n
portal_status_message = translateString("No attachment was added. Please select a file to add an attachment.")\n
return context.Base_redirect(form_id, keep_items = dict(portal_status_message =portal_status_message), **kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, *args, **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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>form_id</string>
<string>args</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
<string>translateString</string>
<string>_getiter_</string>
<string>result</string>
<string>mode</string>
<string>encapsulated_editor_list</string>
<string>zip</string>
<string>_getitem_</string>
<string>attachment_list</string>
<string>attachment_count</string>
<string>attachment</string>
<string>title</string>
<string>_inplacevar_</string>
<string>file</string>
<string>dict</string>
<string>portal_status_message</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PDFDocument_uploadAttachment</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Report" module="Products.ERP5Form.Report"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This form lists all attachments which have been added or may be added</string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>white_background</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>white_background</string> </key>
<value>
<list>
<string>explanation</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PDFDocument_viewAttachmentList</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>PDFDocument_viewAttachmentList</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>report_view</string> </value>
</item>
<item>
<key> <string>report_method</string> </key>
<value> <string>PDFDocument_getReportSectionList</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Attachments</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>white_background</string>
<string>right</string>
<string>bottom</string>
<string>center</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_creation_date</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>white_background</string> </key>
<value>
<list>
<string>debug</string>
<string>section_title</string>
<string>section_state</string>
<string>missing</string>
<string>explanation</string>
<string>listbox</string>
<string>your_attachment_title</string>
<string>add_attachment</string>
<string>your_attachment</string>
<string>upload_button</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PDFDocument_viewAttachmentReportSection</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2008-09-09 fabien
* report_section refactoring to be more generic and easier to customize with more pdf
2008-08-26 fabien 2008-08-26 fabien
* add erp5_captcha skin folder * add erp5_captcha skin folder
* add portal_sessions tool * add portal_sessions tool
......
275 276
\ 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