Commit 938f4bc7 authored by Ivan Tyagov's avatar Ivan Tyagov

Merge branch 'master' into cache

Conflicts:
	bt5/erp5_dms_conversion_catalog/SkinTemplateItem/portal_skins/erp5_dms_conversion_catalog/WebPage_preConvertReferencedImageList.xml
	bt5/erp5_dms_conversion_catalog/bt/revision
	product/ERP5OOo/tests/testDmsWithPreConversion.py
parents 1ad62b2b 0be4533e
......@@ -132,9 +132,20 @@ def getTaxLineList(order):\n
return tax_line_list\n
\n
\n
\n
line_base_contribution_list = []\n
number = 0\n
line_novat_totalprice = 0\n
line_list = []\n
line_not_vat = []\n
line_vat = []\n
line_not_vat_has_no_vat = {}\n
total_price = 0.0\n
total_vat = 0.0\n
total_vat_price = 0.0\n
vat_total_list = []\n
taxnumber = 0\n
taxname = \'\'\n
\n
def unicodeDict(d):\n
for k, v in d.items():\n
......@@ -176,8 +187,23 @@ for line in getSubLineList(context):\n
display_id = \'translated_title\'\n
if request.get(\'international_form\'):\n
display_id = \'title\'\n
desc = (\', \'.join([x[0] for x in\n
line.getVariationCategoryItemList(display_id=display_id)]),)\n
desc = (\', \'.join([x[0] for x in line.getVariationCategoryItemList(display_id=display_id)]),)\n
is_vat=0\n
portal_preferences = context.getPortalObject().portal_preferences\n
if portal_preferences.getPreferredTaxUseList()==[] :\n
vat="use/trade/tax"\n
is_vat=line.isMemberOf(vat) \n
else:\n
vatlist=portal_preferences.getPreferredTaxUseList() \n
for vat in vatlist:\n
is_vat = is_vat or line.isMemberOf(vat)\n
if not is_vat:\n
if line.getBaseContribution() not in line_base_contribution_list:\n
line_base_contribution_list.append(line.getBaseContribution())\n
taxnumber=line_base_contribution_list.index(line.getBaseContribution())+1\n
else:\n
taxname=line.getBaseContribution()\n
\n
line_dict = {\n
\'style_name\': \'Table_20_Contents\',\n
\'left_style_name\': \'Table_20_Contents_20_Left\',\n
......@@ -187,16 +213,44 @@ for line in getSubLineList(context):\n
\'reference\': line.getResource() is not None\\\n
and line.getResourceValue().getReference() or \'\',\n
\'description\': desc,\n
\'base_contribution\':line.getBaseContribution() or None,\n
\'use_type\':line.getResourceValue().getUse() or \'\',\n
\'use_type_tax\':is_vat,\n
\'total_quantity\': line.getTotalQuantity() or \'\',\n
\'tax_name\':taxname or \'\',\n
\'tax_number\':taxnumber or \'\',\n
\'quantity_unit\': line.getQuantityUnitTranslatedTitle() or (\n
line.getResource() and line.getResourceValue().getQuantityUnitTranslatedTitle()) or \'\',\n
\'stop_date\': getOrderedDate(line.getStopDate()) or \'\',\n
\'base_price\': line.getPrice() or \'\',\n
\'total_price\': line.getTotalPrice() or \'\',\n
\'total_price\': line.getTotalPrice() or 0,\n
\'specialise_title\' : line.getProperty(\'specialise_title\', \'\'),\n
}\n
\n
if line_dict[\'use_type_tax\']:\n
total_vat_price+=line.getTotalPrice() or 0.0\n
line_vat.append(unicodeDict(line_dict.copy()))\n
else:\n
total_price += line.getTotalPrice() or 0.0\n
line_not_vat.append(unicodeDict(line_dict.copy()))\n
if line_dict[\'base_contribution\'] is None:\n
line_novat_totalprice = line_novat_totalprice + line_dict[\'total_price\']\n
line_not_vat_has_no_vat = {\n
\'tax_name\': None ,\n
\'total_quantity\': line_novat_totalprice,\n
\'base_price\': 0.00 ,\n
\'total_price\': 0.00 ,\n
}\n
line_list.append(unicodeDict(line_dict.copy()))\n
if line_not_vat_has_no_vat != {} :\n
line_vat.append(unicodeDict(line_not_vat_has_no_vat.copy()))\n
for line_each in line_vat:\n
if line_each[\'tax_name\'] in line_base_contribution_list :\n
vatNumber=line_base_contribution_list.index(line_each[\'tax_name\'])+1\n
else:\n
vatNumber=0\n
line_each.update({\'vat_number\': vatNumber})\n
line_vat.sort(key=lambda obj:obj.get(\'vat_number\'))\n
\n
inch_cm_ratio = 2.54 / 100.0\n
\n
......@@ -397,11 +451,15 @@ data_dict = {\n
\'delivery_mode\': context.getDeliveryModeTranslatedTitle() or \'\',\n
\'incoterm\': context.getIncoterm() and context.getIncotermValue().getCodification() or \'\',\n
\n
\'vat_name_list\':line_base_contribution_list,\n
\'total_price\':total_price+total_vat_price,\n
\'total_price_novat\': total_price,\n
\'vat_list\': getTaxLineList(context),\n
\'vat_list\': total_vat,\n
\'vat_total_price\':total_vat_price,\n
\'description\': getFieldAsLineList(context.getDescription()),\n
\'specialise_title\': context.getProperty(\'specialise_title\',\'\'),\n
\n
\'line_vat\':line_vat,\n
\'line_not_vat\':line_not_vat,\n
\'line_list\': line_list,\n
}\n
\n
......
......@@ -211,7 +211,8 @@ system_prefs = dict(\n
preferred_client_role_list = [\'client\'],\n
preferred_sale_use_list = [\'trade/sale\'],\n
preferred_purchase_use_list = [\'trade/purchase\'],\n
preferred_packing_use_list = [\'trade/container\'])\n
preferred_packing_use_list = [\'trade/container\'],\n
preferred_tax_use_list=[\'trade/tax\'])\n
\n
configuration_save.addConfigurationItem(\n
\'System Preference Configurator Item\',\n
......
......@@ -367,6 +367,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
self.assertEquals(['trade/sale'], preference_tool.getPreferredSaleUseList())
self.assertEquals(['trade/purchase'], preference_tool.getPreferredPurchaseUseList())
self.assertEquals(['trade/container'], preference_tool.getPreferredPackingUseList())
self.assertEquals(['trade/tax']), preference_tool.getPreferredTaxUseList())
def stepCheckModulesBusinessApplication(self, sequence=None, sequence_list=None, **kw):
"""
......
......@@ -50,33 +50,37 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>transition = state_change[\'transition\'].id[len(\'user_\'):]\n
<value> <string encoding="cdata"><![CDATA[
"""\n
Generate reference from a string by escaping all non ascii characters.\n
XXX: add support for non-ascii characters using unidecode python library\n
"""\n
transliterate_list = [\'?\', \':\', \';\', \'/\', \'&\', \'=\', \'^\', \'@\', \'>\', \'<\', \']\', \'[\', \'^\', \'\\\\\']\n
\n
def TestTitle(object):\n
"""\n
This is the test for this particular action\n
"""\n
if object.getTitle() == \'truc\':\n
return 1\n
return 0\n
def removeNonAscii(s): \n
return "".join(i for i in s if ord(i)>44 and ord(i)<123)\n
\n
object = state_change[\'object\']\n
# reference can be used for permanent URL so be friendly to spaces (SEO)\n
s = s.strip()\n
s =s.replace(\' \', \'-\')\n
\n
if TestTitle(object):\n
method = getattr(context, transition)\n
method()\n
else:\n
kw = {\'error_message\':\'Why do you want to do this ?????\'}\n
state_change.setWorkflowVariable(object, **kw)\n
</string> </value>
s = removeNonAscii(s)\n
for item in transliterate_list:\n
s = s.replace(item, \'-\')\n
\n
return s.strip(\'-\')\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
<value> <string>s</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_error_message</string> </value>
<value> <string>Base_generateReferenceFromString</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -59,7 +59,7 @@
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>left reply-dialog</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
......@@ -90,7 +90,7 @@
</value>
</item>
<item>
<key> <string>left</string> </key>
<key> <string>left reply-dialog</string> </key>
<value>
<list>
<string>your_title</string>
......
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
<value> <string>"""\n
This script allows to create a new Discussion Thread.\n
"""\n
from zExceptions import Unauthorized\n
\n
MARKER = [\'\', None, []]\n
\n
portal = context.getPortalObject()\n
......@@ -62,7 +62,13 @@ person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n
version = \'001\'\n
language = portal.Localizer.get_selected_language()\n
user_assignment_dict = portal.ERP5Site_getPersonAssignmentDict()\n
\n
try:\n
user_assignment_dict = portal.ERP5Site_getPersonAssignmentDict()\n
except Unauthorized:\n
# not in all cases current logged in user may access its details\n
user_assignment_dict = {\'group_list\': [], \'site_list\':[]}\n
\n
if group_list in MARKER:\n
group_list = user_assignment_dict[\'group_list\']\n
if site_list in MARKER:\n
......@@ -72,7 +78,8 @@ if site_list in MARKER:\n
membership_criterion_category_list = context.getMembershipCriterionCategoryList()\n
multimembership_criterion_base_category_list = context.getMultimembershipCriterionBaseCategoryList()\n
\n
reference = title.replace(\' \', \'-\').replace(\'?\', \'\').replace(\':\', \'\').replace(\'/\', \'\').replace(\'&\', \'\').replace(\'=\', \'\')\n
reference = context.Base_generateReferenceFromString(title)\n
\n
existing_document = context.getDocumentValue(reference)\n
if existing_document is not None:\n
# if there are other document which reference duplicates just add some random part\n
......@@ -154,9 +161,7 @@ if send_notification_text not in (\'\', None):\n
\n
return context.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=context.Base_translateString(portal_status_message)))\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -59,7 +59,7 @@
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>left reply-dialog</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
......@@ -90,7 +90,7 @@
</value>
</item>
<item>
<key> <string>left</string> </key>
<key> <string>left reply-dialog</string> </key>
<value>
<list>
<string>your_title</string>
......
119
\ No newline at end of file
122
\ No newline at end of file
......@@ -62,10 +62,7 @@ if address not in MARKER and port not in MARKER:\n
for index_uid in range(len(uid)):\n
document_relative_url = getRelativeUrl[index_uid]\n
document = portal.restrictedTraverse(document_relative_url)\n
# XXX: we do check if "data" methods exists on pretending to be Document portal types\n
# we need a way to do this by introspection\n
if ((getattr(document, "getData", None) is not None and document.getData() not in MARKER) or \\\n
(getattr(document, "getBaseData", None) is not None and document.getBaseData() not in MARKER)):\n
if document.Base_isConvertible():\n
document.activate(priority=4, tag="conversion").Base_callPreConvert()\n
</string> </value>
</item>
......
......@@ -56,11 +56,8 @@
"""\n
portal = context.getPortalObject()\n
\n
portal_type = context.getPortalType()\n
allowed_portal_type_list = portal.getPortalDocumentTypeList() + portal.getPortalEmbeddedDocumentTypeList()\n
\n
if portal_type not in allowed_portal_type_list:\n
# no need to convert any non DMS types\n
if not context.Base_isConvertible():\n
# no need to convert any non convertible types\n
return\n
\n
if kw=={}:\n
......
<?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
Return true or false based on if document is convertible or not.\n
"""\n
MARKER = (None, \'\',)\n
portal = context.getPortalObject()\n
\n
portal_type = context.getPortalType()\n
allowed_portal_type_list = portal.getPortalDocumentTypeList() + portal.getPortalEmbeddedDocumentTypeList()\n
\n
if portal_type not in allowed_portal_type_list:\n
return False\n
\n
# XXX: we do check if "data" methods exists on pretending to be Document portal types\n
# we need a way to do this by introspection\n
return (getattr(context, "getData", None) is not None and context.getData() not in MARKER) or \\\n
(getattr(context, "getBaseData", None) is not None and context.getBaseData() not in MARKER)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_isConvertible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,7 +58,7 @@
portal = context.getPortalObject()\n
\n
MARKER = (None, \'\',)\n
API_ARGUMENT_LIST = [\'format\', \'display\', \'quality\', \'resolution\']\n
API_ARGUMENT_LIST = [\'format\', \'display\', \'display_list\', \'quality\', \'resolution\']\n
validation_state = (\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'shared\', \'shared_alive\', \'public\', \'validated\')\n
\n
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3243,6 +3243,12 @@ msgstr "関連する出荷明細書がありません"
msgid "No Trade Condition."
msgstr "取引条件がありません。"
msgid "No result !"
msgstr "見つかれませんでした!"
msgid "No result."
msgstr "見つかれませんでした。"
msgid "No such document was found."
msgstr "ドキュメントが見つかりませんでした。"
......
2012-10-16 arnaud.fontaine
* Add missing translations for 'No result.' and 'No result !'.
2010-07-09 tatuya
* Fix the translations of Internal Packing List. Because they were not consistent.
......
39
\ No newline at end of file
40
\ No newline at end of file
......@@ -65,7 +65,6 @@ class PaypalService(XMLObject):
def navigate(self, REQUEST=None, **kw):
"""See Payment Service Interface Documentation"""
self.Base_checkConsistency()
page_template = kw.pop("page_template")
paypal_dict = kw.get("paypal_dict", {})
temp_document = newTempDocument(self, 'id')
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>NVP Url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>nvp_link_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Email of account</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>service_email_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -100,6 +100,7 @@
<string>my_title</string>
<string>my_reference</string>
<string>my_link_url_string</string>
<string>my_nvp_link</string>
</list>
</value>
</item>
......@@ -110,6 +111,7 @@
<string>my_service_username</string>
<string>my_service_password</string>
<string>my_service_signature</string>
<string>my_service_email</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_nvp_link</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_link_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>NVP URL</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_service_email</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Email</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,7 +9,9 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
<list>
<string>default</string>
</list>
</value>
</item>
<item>
......@@ -50,6 +52,10 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -69,6 +75,10 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_password</string> </value>
......
3
\ No newline at end of file
5
\ No newline at end of file
......@@ -62,20 +62,12 @@ if bt5 is None:\n
\n
active_result = ActiveResult()\n
\n
template_tool.updateRepositoryBusinessTemplateList(\n
template_tool.getRepositoryList())\n
bt5_list = bt5.split()\n
bt5_list.extend(template_tool.getInstalledBusinessTemplateTitleList())\n
\n
try:\n
bt5_list = [x[1] for x in template_tool.resolveBusinessTemplateListDependency(\n
bt5.split(),\n
newest_only=True)]\n
\n
bt5_list.extend([x.getTitle() for x in \\\n
template_tool.getUpdatedRepositoryBusinessTemplateList()])\n
\n
bt5_list = list(set(bt5_list))\n
severity = len(bt5_list)\n
\n
message_list = template_tool.upgradeSite(bt5_list, dry_run=True)\n
severity = len(message_list)\n
except BusinessTemplateUnknownError, error:\n
severity = -1\n
detail = str(error)\n
......@@ -83,13 +75,13 @@ except BusinessTemplateUnknownError, error:\n
if severity == -1:\n
severity = 5\n
summary = "Unable to resolve bt5 dependencies"\n
\n
elif severity == 0:\n
summary = "Nothing to do."\n
detail = ""\n
else:\n
summary = "Upgrade needed"\n
detail = "Needed to install %s" % \', \'.join(bt5_list)\n
summary = "Upgrade needed."\n
detail = "Information: %s" % ",".join(message_list)\n
\n
\n
active_result.edit(\n
summary=summary, \n
......
......@@ -56,12 +56,9 @@ bt5 = portal.getPromiseParameter(\'portal_templates\', \'expected_bt5\')\n
if bt5 is None:\n
return\n
\n
bt5_list = [x[1] for x in portal.portal_templates.resolveBusinessTemplateListDependency(bt5.split(), newest_only=True)]\n
bt5_list.extend([x.getTitle() for x in portal.portal_templates.getUpdatedRepositoryBusinessTemplateList()])\n
bt5_list = list(set(bt5_list))\n
\n
portal.portal_templates.installBusinessTemplateListFromRepository(\n
bt5_list, activate=True, install_dependency=True)\n
bt5_list = bt5.split()\n
bt5_list.extend(portal.portal_templates.getInstalledBusinessTemplateTitleList())\n
portal.portal_templates.upgradeSite(bt5_list)\n
</string> </value>
</item>
<item>
......
18
\ No newline at end of file
19
\ No newline at end of file
......@@ -303,6 +303,7 @@
<string>my_view_mode_preferred_internal_use_list</string>
<string>my_view_mode_listbox_read_only_effective_date</string>
<string>my_view_mode_listbox_read_only_expiration_date</string>
<string>my_view_mode_preferred_tax_use_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_view_mode_preferred_tax_use_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_multi_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Tax Uses</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: getattr(here.portal_categories.use, preferences.getPreference(\'preferred_category_child_item_list_method_id\', \'getCategoryChildCompactLogicalPathItemList\'))(base=1, local_sort_id=(\'int_index\', \'translated_title\'), checked_permission=\'View\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -96,6 +96,7 @@
<string>my_preferred_supplier_role_list</string>
<string>my_preferred_client_role_list</string>
<string>my_preferred_trade_base_amount_list</string>
<string>my_preferred_tax_use_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_tax_use_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_preferred_tax_use_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -42,6 +42,7 @@ from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping
from Products.ERP5Type.DiffUtils import DiffFile
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type.Cache import transactional_cached
from Products.ERP5Type import Permissions
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency
from Acquisition import aq_base
......@@ -881,6 +882,10 @@ class TemplateTool (BaseTool):
Return the list of missing dependencies for a business
template, given a tuple : (repository, id)
"""
# use by using "self" on transactional_cached decorator
# breaks ERP5Site creation due aq_base.
@transactional_cached(lambda bt: (bt))
def _getDependency(bt):
# We do not take into consideration the dependencies
# for meta business templates
if bt[0] == 'meta':
......@@ -890,7 +895,7 @@ class TemplateTool (BaseTool):
if repository == bt[0]:
for property_dict in property_dict_list:
if property_dict['id'] == bt[1]:
dependency_list = property_dict['dependency_list']
dependency_list = [q for q in property_dict['dependency_list'] if q]
for dependency_couple in dependency_list:
# dependency_couple is like "erp5_xhtml_style (>= 0.2)"
dependency_couple_list = dependency_couple.split(' ', 1)
......@@ -902,34 +907,23 @@ class TemplateTool (BaseTool):
# Something like "(>= 1.0rc6)".
version_restriction = version_restriction[1:-1]
require_update = False
installed_bt = self.getInstalledBusinessTemplate(dependency)
if version_restriction is not None:
if installed_bt is not None:
# Check if the installed version require an update
if not self.compareVersionStrings(installed_bt.getVersion(), version_restriction):
operator = version_restriction.split(' ')[0]
if operator in ('<', '<<', '<='):
raise BusinessTemplateMissingDependency, '%s (%s) is present but %s require: %s (%s)'%(dependency, installed_bt.getVersion(), property_dict['title'], dependency, version_restriction)
else:
require_update = True
if (require_update or installed_bt is None) \
and dependency not in result_list:
if dependency not in result_list:
# Get the lastest version of the dependency on the
# repository that meet the version restriction
provider_installed = False
bt_dep = None
try:
bt_dep = self.getLastestBTOnRepos(dependency, version_restriction)
except BusinessTemplateUnknownError:
raise BusinessTemplateMissingDependency, 'The following dependency could not be satisfied: %s (%s)\nReason: Business Template could not be found in the repositories'%(dependency, version_restriction or '')
raise BusinessTemplateMissingDependency, 'While analysing %s the following dependency could not be satisfied: %s (%s)\nReason: Business Template could not be found in the repositories'%(bt[1], dependency, version_restriction or '')
except BusinessTemplateIsMeta:
provider_list = self.getProviderList(dependency)
for provider in provider_list:
if self.portal_templates.getInstalledBusinessTemplate(provider) is not None:
provider_installed = True
bt_dep = self.getLastestBTOnRepos(provider)
break
if not provider_installed:
if bt_dep is None:
bt_dep = ('meta', dependency)
if not provider_installed:
sub_dep_list = self.getDependencyList(bt_dep)
for sub_dep in sub_dep_list:
if sub_dep not in result_list:
......@@ -938,6 +932,8 @@ class TemplateTool (BaseTool):
return result_list
raise BusinessTemplateUnknownError, 'The Business Template %s could not be found on repository %s'%(bt[1], bt[0])
return _getDependency(bt)
def findProviderInBTList(self, provider_list, bt_list):
"""
Find one provider in provider_list which is present in
......@@ -1061,22 +1057,32 @@ class TemplateTool (BaseTool):
security.declareProtected( Permissions.AccessContentsInformation,
'getRepositoryBusinessTemplateList' )
def getRepositoryBusinessTemplateList(self, update_only=False,
newest_only=False, **kw):
template_list=None, **kw):
"""Get the list of Business Templates in repositories.
update_only: return only bt that needs to be updated
template_list: only returns bt within the given list
"""
version_state_title_dict = { 'new' : 'New', 'present' : 'Present',
'old' : 'Old' }
from Products.ERP5Type.Document import newTempBusinessTemplate
template_list = []
result_list = []
template_set = None
if template_list is not None:
template_set = set(template_list)
template_item_list = []
if update_only or newest_only:
# First of all, filter Business Templates in repositories.
template_item_dict = {}
for repository, property_dict_list in self.repository_dict.items():
for property_dict in property_dict_list:
title = property_dict['title']
if template_set and not(title in template_set):
continue
if not update_only:
template_item_list.append((repository, property_dict))
else:
if title not in template_item_dict:
# If this is the first time to see this business template,
# insert it.
......@@ -1095,8 +1101,8 @@ class TemplateTool (BaseTool):
and property_dict['revision'] \
and int(previous_property_dict['revision']) < int(property_dict['revision']):
template_item_dict[title] = (repository, property_dict)
if update_only:
# Next, select only updated business templates.
if update_only:
for repository, property_dict in template_item_dict.values():
installed_bt = \
self.getInstalledBusinessTemplate(property_dict['title'], strict=True)
......@@ -1110,11 +1116,7 @@ class TemplateTool (BaseTool):
and property_dict['revision'] \
and int(installed_bt.getRevision()) < int(property_dict['revision']):
template_item_list.append((repository, property_dict))
else:
template_item_list = template_item_dict.values()
else:
for repository, property_dict_list in self.repository_dict.items():
for property_dict in property_dict_list:
elif template_list is not None:
template_item_list.append((repository, property_dict))
# Create temporary Business Template objects for displaying.
......@@ -1123,14 +1125,14 @@ class TemplateTool (BaseTool):
id = property_dict['id']
filename = property_dict['id']
del property_dict['id']
version = property_dict['version']
revision = property_dict['revision']
version_state = 'new'
installed_bt = \
self.getInstalledBusinessTemplate(property_dict['title'])
if installed_bt is not None:
installed_version = installed_bt.getVersion()
installed_revision = installed_bt.getRevision()
result = self.compareVersions(version, installed_version)
result = self.compareVersions(installed_revision, revision)
if result == 0:
version_state = 'present'
elif result < 0:
......@@ -1148,9 +1150,9 @@ class TemplateTool (BaseTool):
installed_revision = installed_revision,
repository = repository, **property_dict)
obj.setUid(uid)
template_list.append(obj)
template_list.sort(key=lambda x: x.getTitle())
return template_list
result_list.append(obj)
result_list.sort(key=lambda x: x.getTitle())
return result_list
security.declareProtected( Permissions.AccessContentsInformation,
'getUpdatedRepositoryBusinessTemplateList' )
......@@ -1227,16 +1229,14 @@ class TemplateTool (BaseTool):
install_dependency=False):
"""Deprecated.
"""
DeprecationWarning('getInstalledBusinessTemplatesList is deprecated; Use getInstalledBusinessTemplateList instead.', DeprecationWarning)
DeprecationWarning('installBusinessTemplatesFromRepositories is deprecated; Use self.installBusinessTemplateListFromRepository instead.', DeprecationWarning)
return self.installBusinessTemplateListFromRepository(template_list,
only_newer, update_catalog, activate, install_dependency)
security.declareProtected(Permissions.ManagePortal,
'resolveBusinessTemplateListDependency')
def resolveBusinessTemplateListDependency(self, template_title_list,
newest_only=True):
available_bt5_list = self.getRepositoryBusinessTemplateList(
newest_only=newest_only)
def resolveBusinessTemplateListDependency(self, template_title_list):
available_bt5_list = self.getRepositoryBusinessTemplateList()
template_title_list = set(template_title_list)
installed_bt5_title_list = self.getInstalledBusinessTemplateTitleList()
......@@ -1245,29 +1245,36 @@ class TemplateTool (BaseTool):
for available_bt5 in available_bt5_list:
if available_bt5.title in template_title_list:
template_title_list.remove(available_bt5.title)
document = self.getInstalledBusinessTemplate(available_bt5.title,
strict=True)
if not newest_only or document is None or (document is not None and \
(int(document.getRevision()) < int(available_bt5.getRevision()))):
bt5 = self.decodeRepositoryBusinessTemplateUid(available_bt5.uid)
bt5_set.add(bt5)
meta_dependency_set = set()
for dep_repository, dep_id in self.getDependencyList(bt5):
if dep_repository != 'meta':
bt5_set.add((dep_repository, dep_id))
else:
meta_dependency_set.add((dep_repository, dep_id))
for dep_repository, dep_id in meta_dependency_set:
provider_list = self.getProviderList(dep_id)
provider_installed = False
provider_title = None
for provider in provider_list:
if provider in [i[1].replace(".bt5", "") for i in bt5_set] or \
provider in installed_bt5_title_list or \
provider in template_title_list:
provider_installed = True
provider_title = provider
for candidate in available_bt5_list:
if candidate.title == provider:
bt5_set.add(\
self.decodeRepositoryBusinessTemplateUid(
candidate.uid))
break
if not provider_installed:
if len(provider_list) == 1:
break
if provider_title is None and len(provider_list) == 1:
provider_title = provider_list[0]
LOG('resolveBT, provider_title', 0, provider_title)
if provider_title:
for candidate in available_bt5_list:
if candidate.title == provider_list[0]:
if candidate.title == provider_title:
bt5_set.add(\
self.decodeRepositoryBusinessTemplateUid(
candidate.uid))
......@@ -1294,11 +1301,15 @@ class TemplateTool (BaseTool):
operation_log = []
resolved_template_list = self.resolveBusinessTemplateListDependency(
template_list, newest_only=only_newer)
template_list)
if not install_dependency:
installed_bt5_set = set([x.title
for x in self.getInstalledBusinessTemplatesList()])
def checkAvailability(bt_title):
return bt_title in template_list or bt_title in installed_bt5_set
missing_dependency_list = [i[1] for i in resolved_template_list
if i[1].replace(".bt5", "") not in template_list]
if not checkAvailability(i[1].replace(".bt5", ""))]
if len(missing_dependency_list) > 0:
raise BusinessTemplateMissingDependency,\
"Impossible to install, please install the following dependencies before: %s" \
......@@ -1471,4 +1482,68 @@ class TemplateTool (BaseTool):
'%s.' % (bt5_title, base_url_list))
return None
security.declareProtected(Permissions.ManagePortal,
'upgradeSite')
def upgradeSite(self, bt5_list, deprecated_after_script_dict=None,
deprecated_reinstall_set=None, dry_run=False,
delete_orphaned=False,
keep_bt5_id_set=None):
"""
Upgrade many business templates at a time. bt5_list should
contains only final business templates, then all dependencies
are calculated, and missing business templates will be added,
old business templates will be updated, and orphelin business
templates will be deleted
keep_bt5_id_set: business template that should not be deleted.
This is useful if we want to keep an old business
template without updating it and without removing it
deprecated_reinstall_set: this parameter needs to be removed
by setting it at business template level.
It list all business templates who needs
reinstall
"""
# make sure that we updated informations on repository
self.updateRepositoryBusinessTemplateList(self.getRepositoryList())
# do upgrade
message_list = []
deprecated_reinstall_set = deprecated_reinstall_set or set()
def append(message):
message_list.append(message)
LOG('upgradeSite', 0, message)
dependency_list = [x[1] for x in \
self.resolveBusinessTemplateListDependency(bt5_list)]
update_bt5_list = self.getRepositoryBusinessTemplateList(
template_list=dependency_list)
update_bt5_list.sort(key=lambda x: dependency_list.index(x.title))
for bt5 in update_bt5_list:
reinstall = bt5.title in deprecated_reinstall_set
if not(reinstall) and bt5.version_state == 'present':
continue
append("Update %s business template in state %s%s" % \
(bt5.title, bt5.version_state, (reinstall and ' (reinstall)') or ''))
if not(dry_run):
bt5_url = "%s/%s" % (bt5.repository, bt5.title)
self.updateBusinessTemplateFromUrl(bt5_url)
if delete_orphaned:
if keep_bt5_id_set is None:
keep_bt5_id_set = set()
to_remove_bt5_list = [x for x in self.getInstalledBusinessTemplateList()
if x.title not in dependency_list]
sorted_to_remove_bt5_id_list = self.sortDownloadedBusinessTemplateList(
[x.id for x in to_remove_bt5_list])
sorted_to_remove_bt5_id_list.reverse()
to_remove_bt5_list.sort(
key=lambda x: sorted_to_remove_bt5_id_list.index(x.id))
for bt in to_remove_bt5_list:
if bt.title in keep_bt5_id_set:
continue
append("Uninstall business template %s" % bt.title)
if not(dry_run):
# XXX Here is missing parameters to really remove stuff
bt.uninstall()
return message_list
InitializeClass(TemplateTool)
......@@ -98,7 +98,7 @@
<string>my_title</string>
<string>my_role_name_list</string>
<string>my_condition</string>
<string>my_local_roles_group_id</string>
<string>my_local_role_group</string>
</list>
</value>
</item>
......
......@@ -71,6 +71,7 @@ if len(uids) == 0:\n
id_list = []\n
portal_status_message = \'\'\n
current_uid_list=[]\n
installed_business_template_title_list = context.getInstalledBusinessTemplateTitleList()\n
for uid in uids:\n
current_uid_list.append(uid)\n
repository, id = context.decodeRepositoryBusinessTemplateUid(uid)\n
......@@ -79,8 +80,11 @@ for uid in uids:\n
# Check for missing dependencies\n
for uid in uids:\n
repository, id = context.decodeRepositoryBusinessTemplateUid(uid)\n
dependency_list = context.getDependencyList((repository, id));\n
dependency_list = context.getDependencyList((repository, id))\n
for dep_repository, dep_id in dependency_list:\n
if dep_id != id and \\\n
dep_id in installed_business_template_title_list:\n
continue\n
if dep_id not in id_list:\n
id_list.append(dep_id)\n
if dep_repository != \'meta\':\n
......
41047
\ No newline at end of file
41048
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Uses of taxes</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_tax_use_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -94,15 +94,10 @@ for f in form.get_fields():\n
listbox = request.get(\'listbox\') # XXX: hardcoded field name\n
if listbox is not None:\n
listbox_line_list = []\n
listbox = getattr(request,\'listbox\',None) # XXX: hardcoded field name\n
listbox_keys = listbox.keys()\n
listbox_keys.sort()\n
for key in listbox_keys:\n
listbox_line = listbox[key]\n
listbox_line[\'listbox_key\'] = key\n
listbox_line_list.append(listbox[key])\n
listbox_line_list = tuple(listbox_line_list)\n
doaction_param_list[\'listbox\'] = listbox_line_list # XXX: hardcoded field name\n
for key, value in sorted(listbox.iteritems()):\n
value[\'listbox_key\'] = key\n
listbox_line_list.append(value)\n
doaction_param_list[\'listbox\'] = tuple(listbox_line_list)\n
\n
try:\n
context.portal_workflow.doActionFor(\n
......@@ -123,10 +118,11 @@ except ValidationFailed, error_message:\n
# that would become an error.\n
log("Status message has been truncated")\n
message = "%s ..." % message[:(2000 - 4)]\n
return context.Base_redirect(form_id,\n
keep_items={\'portal_status_message\': message}, **kw)\n
\n
portal_status_message = request.get(\'portal_status_message\', translateString(\'Status changed.\'))\n
else:\n
message = request.get(\'portal_status_message\')\n
if message is None:\n
message = translateString(\'Status changed.\')\n
kw.clear() # useful ?\n
\n
# Allow to redirect to another document\n
redirect_document_path = request.get(\'redirect_document_path\', None)\n
......@@ -137,7 +133,7 @@ else:\n
redirect_document = context\n
\n
return redirect_document.Base_redirect(form_id,\n
keep_items={\'portal_status_message\': portal_status_message})\n
keep_items={\'portal_status_message\': message}, **kw)\n
]]></string> </value>
......
......@@ -425,11 +425,15 @@ div.listbox-content-fixed-width{\n
}\n
\n
table.listbox td.listbox-table-no-result-row{\n
background-color:#DAE6F6;\n
color:#001730;\n
border: 1px solid #3D6474;\n
text-align:center;\n
}\n
\n
table.listbox tr.listbox-stat-line{\n
background-color:#C1DAEB;\n
color:#001730;\n
border-top: 1px solid #3D6474;\n
}\n
\n
......
2012-10-16 arnaud.fontaine
* Fix background color of stat and no cell ListBox lines.
2012-08-07 Kazuhiko
* update FCKeditor to 2.6.8.
......
1085
\ No newline at end of file
1086
\ No newline at end of file
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors.
......@@ -148,6 +149,10 @@ class TestERP5Discussion(ERP5TypeTestCase):
self.assertSameSet([], web_section2.getDocumentValueList())
def test_02_ReferenceGenerationFromString(self):
s = "a test by ivan !@#$%^&*()[]\\é"
self.assertEqual('a-test-by-ivan', self.portal.Base_generateReferenceFromString(s))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Discussion))
......
......@@ -30,6 +30,8 @@
Tests invoice creation from simulation.
"""
import sys, zipfile, xml.dom.minidom
import StringIO
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload, DummyMailHost
......@@ -1574,12 +1576,15 @@ class TestInvoice(TestInvoiceMixin):
self.assertEquals(DateTime(2002, 03, 04),
invoice_transaction_movement.getStopDate())
def test_Invoice_viewAsODT(self):
resource = self.portal.getDefaultModule(
self.resource_portal_type).newContent(
portal_type=self.resource_portal_type,
title='Resource',)
resource_tax = self.portal.getDefaultModule(
self.resource_portal_type).newContent(
portal_type=self.resource_portal_type,
title='Resource Tax',)
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client')
vendor = self.portal.organisation_module.newContent(
......@@ -1593,14 +1598,78 @@ class TestInvoice(TestInvoiceMixin):
source_section_value=vendor,
destination_value=client,
destination_section_value=client)
line = invoice.newContent(portal_type=self.invoice_line_portal_type,
product_line1 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=10,
base_contribution='tax1',
price=3)
product_line2 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=20,
base_contribution='tax1',
price=5)
product_line3 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=60,
base_contribution='tax2',
price=5)
product_line4 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=60,
price=3)
product_line5 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=7,
price=20)
tax_line1 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax,
use='trade/tax',
base_contribution='tax1',
quantity=130,
price=0.2)
tax_line2 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax,
use='trade/tax',
base_contribution='tax2',
quantity=300,
price=0.05)
tax_line3 = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax,
use='trade/tax',
base_contribution='tax3',
quantity=20,
price=0.1)
invoice.confirm()
self.tic()
odt = invoice.Invoice_viewAsODT()
import cStringIO
output = cStringIO.StringIO()
output.write(odt)
m = OpenDocumentTextFile(output)
text_content=m.toString().encode('ascii','replace')
if text_content.find('Resource Tax') != -1 :
self.fail('fail to delete the vat line in product line')
if text_content.find('Vat Code') == -1 :
self.fail('fail to add the vat code')
if text_content.find('Amount') == -1 :
self.fail('fail to add the amount for each tax')
if text_content.find('Rate') == -1 :
self.fail('fail to add the Rate for each tax')
tax1_product_total_price=str(10*3+20*5)
if text_content.find(tax1_product_total_price) == -1 :
self.fail('fail to get the total price of products which tax1')
tax2_product_total_price=str(60*5)
if text_content.find(tax2_product_total_price) == -1 :
self.fail('fail to get the total price of products which tax2')
no_tax_product_total_price=str(60*3+7*20)
if text_content.find(no_tax_product_total_price) == -1 :
self.fail('fail to get the total price of products which have no tax')
product_total_price_no_tax=str(10*3+20*5+60*5+60*3+7*20)
if text_content.find(product_total_price_no_tax) == -1 :
self.fail('fail to get the total price of the products without tax')
product_total_price=str(10*3+20*5+60*5+60*3+7*20+130*0.2+300*0.05+20*0.1)
if text_content.find(product_total_price) == -1 :
self.fail('fail to get the total price of the products with tax')
from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator()
err_list = odf_validator.validate(odt)
......@@ -3502,6 +3571,28 @@ class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase):
stepTic
"""
class OpenDocumentTextFile :
def __init__ (self, filelikeobj) :
zip = zipfile.ZipFile(filelikeobj)
self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
def toString (self) :
""" Converts the document to a string. """
buffer = u""
for val in ["text:p", "text:h", "text:list"]:
for paragraph in self.content.getElementsByTagName(val) :
buffer += self.textToString(paragraph) + "\n"
return buffer
def textToString(self, element) :
buffer = u""
for node in element.childNodes :
if node.nodeType == xml.dom.Node.TEXT_NODE :
buffer += node.nodeValue
elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
buffer += self.textToString(node)
return buffer
import unittest
def test_suite():
suite = unittest.TestSuite()
......
......@@ -50,14 +50,18 @@ class TestTemplateTool(ERP5TypeTestCase):
test_tool_id = 'test_portal_templates'
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_csv_style')
return ('erp5_core_proxy_field_legacy',
'erp5_full_text_myisam_catalog',
'erp5_base',
'erp5_csv_style')
def getTitle(self):
return "Template Tool"
def afterSetUp(self):
self.templates_tool = self.portal.portal_templates
self.setupAutomaticBusinessTemplateRepository()
self.setupAutomaticBusinessTemplateRepository(
searchable_business_template_list=["erp5_core", "erp5_base"])
if getattr(self.portal, self.test_tool_id, None) is not None:
self.portal.manage_delObjects(ids=[self.test_tool_id])
self.portal.newContent(portal_type='Template Tool',
......@@ -68,8 +72,7 @@ class TestTemplateTool(ERP5TypeTestCase):
self.tic()
mark_replaced_bt_list = ["erp5_odt_style", "erp5_pdm", 'erp5_accounting',
'erp5_workflow', 'erp5_configurator', 'erp5_configurator_ung',
'erp5_ingestion_mysql_innodb_catalog', "erp5_configurator_standard",
'erp5_full_text_myisam_catalog']
'erp5_ingestion_mysql_innodb_catalog', "erp5_configurator_standard"]
for bt_name in mark_replaced_bt_list:
bt = self.templates_tool.getInstalledBusinessTemplate(bt_name)
if (bt is not None) and bt.getInstallationState() in ['installed',
......@@ -408,38 +411,39 @@ class TestTemplateTool(ERP5TypeTestCase):
addRepositoryEntry(title='biz', dependency_list=()),
addRepositoryEntry(title='ca1', provision_list=('sql',)),
addRepositoryEntry(title='ca2', provision_list=('sql',)),
addRepositoryEntry(title='end', dependency_list=('baz','sql')),
addRepositoryEntry(title='a', dependency_list=()),
addRepositoryEntry(title='b', dependency_list=('a'), revision='5'),
addRepositoryEntry(title='end', dependency_list=('baz','sql', 'b')),
)
# Simulate that we have some installed bt.
for bt_id in ('foo', 'ca1'):
for bt_id in ('foo', 'ca1', 'b'):
bt = template_tool.newContent(portal_type='Business Template',
title=bt_id, revision='4', id=bt_id)
bt.install()
bt5_id_list = ['baz']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([(repository, 'bar.bt5'),
self.assertEquals([(repository, 'foo.bt5'),
(repository, 'bar.bt5'),
(repository, 'baz.bt5')], bt5_list)
bt5_id_list = ['foo']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([], bt5_list)
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list,
newest_only=True)
self.assertEquals([], bt5_list)
bt5_list = template_tool.resolveBusinessTemplateListDependency(
bt5_id_list, False)
bt5_id_list)
self.assertEquals([(repository, 'foo.bt5')], bt5_list)
bt5_id_list = ['biz', 'end']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([(repository, 'bar.bt5'),
self.assertEquals([(repository, 'foo.bt5'),
(repository, 'a.bt5'),
(repository, 'bar.bt5'),
(repository, 'b.bt5'),
(repository, 'ca1.bt5'),
(repository, 'baz.bt5'),
(repository, 'biz.bt5'),
(repository, 'end.bt5')], bt5_list)
(repository, 'end.bt5'),
(repository, 'biz.bt5')], bt5_list)
# By removing ca1, we remove the choice for the "sql" provider.
# Therefore template tool does not know any more what to take for "sql".
......@@ -447,12 +451,12 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertRaises(BusinessTemplateMissingDependency,
template_tool.resolveBusinessTemplateListDependency,
bt5_id_list, False)
bt5_id_list)
bt5_id_list = ['erp5_do_not_exist']
self.assertRaises(BusinessTemplateUnknownError,
template_tool.resolveBusinessTemplateListDependency,
bt5_id_list, False)
bt5_id_list)
def test_installBusinessTemplatesFromRepository_simple(self):
""" Simple test for portal_templates.installBusinessTemplatesFromRepository
......@@ -463,7 +467,7 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertEquals(bt, None)
operation_log = \
self.templates_tool.installBusinessTemplateListFromRepository([bt5_name])
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
self.assertTrue("Installed %s with" % bt5_name in operation_log[-1])
bt = self.templates_tool.getInstalledBusinessTemplate(bt5_name, strict=True)
self.assertNotEquals(bt, None)
self.assertEquals(bt.getTitle(), bt5_name)
......@@ -477,7 +481,7 @@ class TestTemplateTool(ERP5TypeTestCase):
operation_log = self.templates_tool.installBusinessTemplateListFromRepository(
[bt5_name], only_newer=False)
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
self.assertTrue("Installed %s with" % bt5_name in operation_log[-1])
bt_new = self.templates_tool.getInstalledBusinessTemplate(bt5_name,
strict=True)
self.assertNotEquals(bt.getId(), bt_new.getId())
......@@ -509,20 +513,8 @@ class TestTemplateTool(ERP5TypeTestCase):
bt5_name = 'erp5_odt_style'
operation_log = template_tool.installBusinessTemplateListFromRepository([bt5_name],
only_newer=False, update_catalog=1)
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertEquals(bt.getTitle(), bt5_name)
self.commit()
self.checkFolderReindexAllActivityPresense()
self.tic()
bt5_name = 'erp5_full_text_myisam_catalog'
operation_log = template_tool.installBusinessTemplateListFromRepository(
[bt5_name], only_newer=False)
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
self.assertTrue("Installed %s with" % bt5_name in operation_log[-1])
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertNotEquals(bt, None)
self.assertEquals(bt.getTitle(), bt5_name)
self.commit()
self.checkFolderReindexAllActivityPresense()
......@@ -531,7 +523,7 @@ class TestTemplateTool(ERP5TypeTestCase):
# Install again should not force catalog to be updated
operation_log = template_tool.installBusinessTemplateListFromRepository(
[bt5_name], only_newer=False)
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
self.assertTrue("Installed %s with" % bt5_name in operation_log[-1])
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertNotEquals(bt, None)
self.assertEquals(bt.getTitle(), bt5_name)
......@@ -574,7 +566,9 @@ class TestTemplateTool(ERP5TypeTestCase):
"""
bt5_name_list = ['erp5_configurator_ung', 'erp5_configurator_standard']
template_tool = self.portal.portal_templates
repository = template_tool.getRepositoryList()[0]
for repos in template_tool.getRepositoryList():
if "bootstrap" not in repos:
repository = repos
self.tic()
for bt5_name in bt5_name_list:
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
......@@ -615,18 +609,9 @@ class TestTemplateTool(ERP5TypeTestCase):
def test_sortBusinessTemplateList(self):
"""Check sorting of a list of business template by their dependencies
"""
repository = "http://www.erp5.org/dists/snapshot/bt5/"
template_tool = self.portal.portal_templates
# XXX This test requires the usage of the public repository due ".bt5" usage
if repository not in template_tool.getRepositoryList():
self.portal.portal_templates.updateRepositoryBusinessTemplateList([repository])
bt5list = template_tool.resolveBusinessTemplateListDependency(('erp5_credential',))
# because erp5_base is already installed, it is not returned
# by resolveBusinessTemplateListDependency, so append it manualy
bt5list.append((repository, "erp5_base.bt5"))
# add some entropy by disorder bt5list returned by
# resolveBusinessTemplateListDependency
position_list = range(len(bt5list))
......@@ -638,19 +623,27 @@ class TestTemplateTool(ERP5TypeTestCase):
ordered_list = template_tool.sortBusinessTemplateList(new_bt5_list)
# group orders
first_group = range(0, 2)
second_group = range(2, 4)
third_group = range(4, 7)
fourth_group = range(7, 8)
expected_position_dict = dict((('erp5_ingestion_mysql_innodb_catalog.bt5',
first_group),
('erp5_base.bt5', first_group),
('erp5_jquery.bt5', second_group),
('erp5_ingestion.bt5', second_group),
('erp5_xhtml_jquery_style.bt5', third_group),
('erp5_web.bt5', third_group),
('erp5_crm.bt5', third_group),
('erp5_credential.bt5', fourth_group)))
first_group = range(0, 6)
second_group = range(6, 8)
third_group = range(8, 10)
fourth_group = range(10, 13)
fifth_group = range(13, 14)
expected_position_dict = dict((('erp5_property_sheets', first_group),
('erp5_core_proxy_field_legacy', first_group),
('erp5_mysql_innodb_catalog', first_group),
('erp5_core', first_group),
('erp5_full_text_myisam_catalog', first_group),
('erp5_xhtml_style', first_group),
('erp5_ingestion_mysql_innodb_catalog', second_group),
('erp5_base', second_group),
('erp5_jquery', third_group),
('erp5_ingestion', third_group),
('erp5_xhtml_jquery_style', fourth_group),
('erp5_web', fourth_group),
('erp5_crm', fourth_group),
('erp5_credential', fifth_group)))
for bt in ordered_list:
self.assertTrue(ordered_list.index(bt) in expected_position_dict[bt[1]],
'Expected positions for %r: %r, got %r' % (bt[1],
......
......@@ -27,13 +27,10 @@
#
##############################################################################
import time
from AccessControl import ClassSecurityInfo
from Globals import PersistentMapping
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet
from zLOG import LOG, INFO
from cStringIO import StringIO
from Products.ERP5Configurator.Tool.ConfiguratorTool import _validateFormToRequest
from Products.ERP5.Document.Item import Item
......@@ -262,19 +259,6 @@ class BusinessConfiguration(Item):
form = getattr(self, self.getNextTransition().getTransitionFormId())
return _validateFormToRequest(form, REQUEST, **kw)
#############
## misc ##
#############
security.declarePrivate('_getConfigurationStack')
def _getConfigurationStack(self):
""" Return list of created by client configuration save objects
sort on id which is an integer. """
result = self.objectValues('ERP5 Configuration Save')
result = map(None, result)
result.sort(lambda x, y: cmp(x.getIntIndex(x.getIntId()),
y.getIntIndex(y.getIntId())))
return result
security.declarePrivate('_getConfSaveForStateFromWorkflowHistory')
def _getConfSaveForStateFromWorkflowHistory(self):
""" Get from workflow history configuration save for this state """
......@@ -282,8 +266,7 @@ class BusinessConfiguration(Item):
current_state = self.getCurrentStateValue()
transition = self.getNextTransition()
next_state = self.unrestrictedTraverse(transition.getDestination())
workflow_history = current_state.getWorkflowHistory(self)
for wh in workflow_history:
for wh in current_state.getWorkflowHistory(self):
if next_state == self.unrestrictedTraverse(wh['current_state']):
configuration_save = self.unrestrictedTraverse(wh['configuration_save_url'])
return configuration_save
......@@ -339,12 +322,11 @@ class BusinessConfiguration(Item):
security.declareProtected(Permissions.View, 'getGlobalConfigurationAttr')
def getGlobalConfigurationAttr(self, key, default=None):
""" Get global business configuration attribute. """
global_configuration_attributes = getattr(self, '_global_configuration_attributes', {})
return global_configuration_attributes.get(key, default)
return getattr(self, '_global_configuration_attributes', {}).get(key, default)
############# Instance and Business Configuration ########################
security.declareProtected(Permissions.ModifyPortalContent, 'buildConfiguration')
def buildConfiguration(self, execute_after_setup_script=1):
def buildConfiguration(self):
"""
Build list of business templates according to already saved
Configuration Saves (i.e. user input).
......@@ -355,13 +337,13 @@ class BusinessConfiguration(Item):
after_method_id=["updateBusinessTemplateFromUrl",
"recursiveImmediateReindexObject",
"immediateReindexObject"])
start = time.time()
LOG("CONFIGURATOR", INFO,
'Build process started for %s' % self.getRelativeUrl())
# build
for configuration_save in self._getConfigurationStack():
configuration_save_list = self.contentValues(portal_type='Configuration Save')
configuration_save_list.sort(lambda x, y: cmp(x.getIntIndex(x.getIntId()),
y.getIntIndex(y.getIntId())))
for configuration_save in configuration_save_list:
# XXX: check which items are configure-able
configuration_item_list = [x for x in configuration_save.contentValues()]
configuration_item_list = configuration_save.contentValues()
configuration_item_list.sort(lambda x, y: cmp(x.getIntId(), y.getIntId()))
for configurator_item in configuration_item_list:
configurator_item.activate(**kw).build(self.getRelativeUrl())
......@@ -369,11 +351,6 @@ class BusinessConfiguration(Item):
kw["tag"] = "configurator_item_%s_%s" % (configurator_item.getId(),
configurator_item.getUid())
LOG('CONFIGURATOR', INFO,
'Build process started for %s ended after %.02fs' % (self.getRelativeUrl(),
time.time() - start))
if execute_after_setup_script:
kw["tag"] = "final_configuration_step_%s" % self.getId()
kw["after_method_id"] = ["build", 'immediateReindexObject', \
"recursiveImmediateReindexObject"]
......
......@@ -113,7 +113,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self.stepCleanUpRequest()
self.restricted_security = 0
self.setupAutomaticBusinessTemplateRepository()
self.setupAutomaticBusinessTemplateRepository(
searchable_business_template_list=["erp5_core", "erp5_base"])
# it is required by SecurityTestCase
self.workflow_tool = self.portal.portal_workflow
......
......@@ -83,15 +83,12 @@ class EditorWidget(Widget.TextAreaWidget):
"""
here = REQUEST['here']
text_editor = field.get_value('text_editor')
if text_editor == 'text_area':
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
elif text_editor == 'bespin':
if text_editor == 'bespin':
# XXX The usage of bespin editor depends of erp5_bespin bt5
# installed and still experimental. If erp5_bespin is not installed, it
# render standard an standard editor field.
bespin_support = getattr(here, 'bespin_support',None)
if bespin_support is None:
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
if bespin_support is not None:
return bespin_support.pt_render(
extra_context= {
'field' : field,
......@@ -100,8 +97,7 @@ class EditorWidget(Widget.TextAreaWidget):
})
elif text_editor == "xinha":
xinha_support = getattr(here, 'xinha_support', None)
if xinha_support is None:
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
if xinha_support is not None:
return xinha_support.pt_render(
extra_context= {
'field' : field,
......@@ -110,27 +106,25 @@ class EditorWidget(Widget.TextAreaWidget):
})
elif text_editor == "svg_editor":
svg_editor_support = getattr(here, 'svg_editor_support', None)
if svg_editor_support is None:
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
if svg_editor_support is not None:
return svg_editor_support.pt_render()
elif text_editor == "spreadsheet_editor":
sheet_editor_support = getattr(here, 'sheet_editor_support', None)
if sheet_editor_support is None:
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
if sheet_editor_support is not None:
return sheet_editor_support.pt_render()
elif text_editor == 'ace':
ace_editor_support = getattr(here, 'ace_editor_support', None)
if ace_editor_support is None:
return Widget.TextAreaWidth.render(self, field, key, value, REQUEST)
if ace_editor_support is not None:
return ace_editor_support.pt_render(extra_context={'field': field,
'content': value,
'id': key})
else:
elif text_editor != 'text_area':
return here.fckeditor_wysiwyg_support.pt_render(
extra_context= {
'inputvalue' : value,
'inputname' : key
})
return Widget.TextAreaWidget.render(self, field, key, value, REQUEST)
def render_view(self, field, value, REQUEST=None, render_prefix=None):
"""
......
......@@ -2746,7 +2746,7 @@ class ListBoxValidator(Validator.Validator):
editable_columns = field.get_value('editable_columns')
column_ids = [x[0] for x in columns]
editable_column_ids = [x[0] for x in editable_columns]
editable_field_dict = dict()
editable_field_dict = {}
for sql in editable_column_ids:
alias = sql.replace('.', '_')
editable_field_dict[alias] = ListBoxRenderer(
......@@ -2754,55 +2754,52 @@ class ListBoxValidator(Validator.Validator):
selection_name = field.get_value('selection_name')
#LOG('ListBoxValidator', 0, 'field = %s, selection_name = %s' % (repr(field), repr(selection_name)))
params = here.portal_selections.getSelectionParamsFor(
portal = here.getPortalObject()
params = portal.portal_selections.getSelectionParamsFor(
selection_name,
REQUEST=REQUEST)
portal_url = getToolByName(here, 'portal_url')
portal = portal_url.getPortalObject()
portal_url = portal.portal_url
result = {}
error_result = {}
MARKER = []
listbox_uids = REQUEST.get('%s_uid' % field.id, MARKER)
if listbox_uids is MARKER:
raise KeyError, 'Field %s is not present in request object.' % (field.id, )
try:
listbox_uids = REQUEST['%s_uid' % field.id]
except KeyError:
raise KeyError('Field %s is not present in request object.'
% field.id)
select = field.get_value('select')
if select:
selected_uid_set = set(REQUEST.get('uids', ()))
#LOG('ListBox.validate: REQUEST',0,REQUEST)
errors = []
object_list = []
object_list = None
# We have two things to do in the case of temp objects,
# the first thing is to create a list with new temp objects
# then try to validate some data, and then create again
# the list with a listbox as parameter. Like this we
# can use tales expression
listbox = {}
for uid in listbox_uids:
if str(uid).find('new') == 0:
if uid[:4] == 'new_':
if object_list is None:
list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name)
#LOG('ListBoxValidator', 0, 'call %s' % repr(list_method))
object_list = list_method(REQUEST=REQUEST, **params)
row_key = uid[4:]
for o in object_list:
if o.getUid() == uid:
break
listbox = {}
for uid in listbox_uids:
if str(uid).find('new') == 0:
o = None
for object in object_list:
if object.getUid()==uid:
o = object
if o is None:
else:
# First case: dialog input to create new objects
o = newTempBase(portal, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
o = newTempBase(portal, row_key) # Arghhh - XXX acquisition problem - use portal root
o.uid = uid
listbox[uid[4:]] = {}
listbox[row_key] = row_result = {}
# We first try to set a listbox corresponding to all things
# we can validate, so that we can use the same list
# as the one used for displaying the listbox
for sql in editable_column_ids:
alias = sql.replace('.', '_')
if '.' in sql:
property_id = '.'.join(sql.split('.')[1:]) # Only take trailing part
else:
property_id = alias
editable_field = editable_field_dict.get(alias)
editable_field = editable_field_dict.get(sql.replace('.', '_'))
if editable_field is not None:
error_result_key = '%s_%s' % (editable_field.id, o.uid)
key = 'field_' + error_result_key
......@@ -2810,39 +2807,31 @@ class ListBoxValidator(Validator.Validator):
try:
value = editable_field._validate_helper(key, REQUEST) # We need cell
# Here we set the property
listbox[uid[4:]][sql] = value
row_result[sql] = value
except ValidationError, err:
pass
except KeyError:
pass
# Here we generate again the object_list with listbox the listbox we
# have just created
if len(listbox)>0:
if listbox:
list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name)
REQUEST.set(field.id, listbox)
object_list = list_method(REQUEST=REQUEST, **params)
for uid in listbox_uids:
if str(uid).find('new') == 0:
# First case: dialog input to create new objects
#o = newTempBase(here, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
#o.uid = uid
o = None
for object in object_list:
if object.getUid()==uid:
o = object
if o is None:
row_result = {}
if uid[:4] == 'new_':
# First case: dialog input to create new objects
o = newTempBase(portal, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
row_key = uid[4:]
for o in object_list:
if o.getUid() == uid:
break
else:
o = newTempBase(portal, row_key) # Arghhh - XXX acquisition problem - use portal root
o.uid = uid
result[uid[4:]] = {}
for sql in editable_column_ids:
alias = sql.replace('.', '_')
if '.' in sql:
property_id = '.'.join(sql.split('.')[1:]) # Only take trailing part
else:
property_id = alias
editable_field = editable_field_dict.get(alias)
editable_field = editable_field_dict.get(sql.replace('.', '_'))
if editable_field is not None:
REQUEST.set('cell', o)
editable = editable_field.get_value('editable', REQUEST=REQUEST)
......@@ -2851,8 +2840,8 @@ class ListBoxValidator(Validator.Validator):
error_result_key = '%s_%s' % (editable_field.id, o.uid)
key = 'field_' + error_result_key
try:
value = editable_field._validate_helper(key, REQUEST) # We need cell
result[uid[4:]][sql] = value
row_result[sql] = editable_field._validate_helper(
key, REQUEST) # We need cell
except ValidationError, err:
#LOG("ListBox ValidationError",0,str(err))
err.field_id = error_result_key
......@@ -2869,43 +2858,34 @@ class ListBoxValidator(Validator.Validator):
# because sometimes, we can be provided bad uids
try :
o = here.portal_catalog.getObject(uid)
except (KeyError, NotFound, ValueError):
o = None
if o is None:
except (KeyError, NotFound, ValueError), err:
# It is possible that this object is not catalogged yet. So
# the object must be obtained from ZODB.
if not object_list:
if object_list is None:
list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name)
object_list = list_method(REQUEST=REQUEST, **params)
for object in object_list:
for o in object_list:
try:
if object.getUid() == int(uid):
o = object
if o.getUid() == int(uid):
break
except ValueError:
if str(object.getUid()) == uid:
o = object
if str(o.getUid()) == uid:
break
for sql in editable_column_ids:
alias = sql.replace('.', '_')
if '.' in sql:
property_id = '.'.join(sql.split('.')[1:]) # Only take trailing part
else:
property_id = alias
editable_field = editable_field_dict.get(alias)
raise err
row_key = o.getUrl()
for sql in editable_column_ids:
editable_field = editable_field_dict.get(sql.replace('.', '_'))
if editable_field is not None:
REQUEST.set('cell', o) # We need cell
if editable_field.get_value('editable', REQUEST=REQUEST) \
and field.need_validate(REQUEST):
if editable_field.get_value('editable', REQUEST=REQUEST) and \
editable_field.need_validate(REQUEST):
error_result_key = '%s_%s' % (editable_field.id, o.uid)
key = 'field_' + error_result_key
try:
value = editable_field._validate_helper(key, REQUEST)
error_result[error_result_key] = value
if not result.has_key(o.getUrl()):
result[o.getUrl()] = {}
result[o.getUrl()][sql] = value
row_result[sql] = error_result[error_result_key] = \
editable_field._validate_helper(key, REQUEST)
except ValidationError, err:
err.field_id = error_result_key
errors.append(err)
......@@ -2916,6 +2896,9 @@ class ListBoxValidator(Validator.Validator):
#except:
else:
LOG("ListBox WARNING",0,"Object uid %s could not be validated" % uid)
result[row_key] = row_result
if select:
row_result['listbox_selected'] = uid in selected_uid_set
if len(errors) > 0:
#LOG("ListBox FormValidationError",0,str(error_result))
#LOG("ListBox FormValidationError",0,str(errors))
......
......@@ -64,6 +64,23 @@ class TestDocumentWithPreConversion(TestDocument):
'Embedded-XXX?format=jpeg&display=large&quality=75'],
web_page.Base_extractImageUrlList())
def test_Base_isConvertible(self):
"""
Test pre converion only happens on proper documents.
"""
print "da"
image = self.portal.image_module.newContent(portal_type='Image',
reference='Embedded-XXX',
version='001',
language='en')
# empty image is not convertible
self.assertEqual(False, image.Base_isConvertible())
# image with data is convertible
upload_file = makeFileUpload('cmyk_sample.jpg')
image.edit(file=upload_file)
self.tic()
self.assertEqual(True, image.Base_isConvertible())
def test_suite():
suite = unittest.TestSuite()
......
......@@ -400,8 +400,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
sci = StateChangeInfo(
ob, self, status, tdef, old_sdef, new_sdef, kwargs)
# put the error message in the workflow history
sci.setWorkflowVariable(ob, workflow_id=self.id,
error_message = before_script_error_message)
sci.setWorkflowVariable(error_message=before_script_error_message)
if validation_exc :
# reraise validation failed exception
raise validation_exc, None, validation_exc_traceback
......
......@@ -30,19 +30,14 @@ from Products.DCWorkflow.Expression import StateChangeInfo
from Products.PythonScripts.Utility import allow_class
allow_class(StateChangeInfo)
def setWorkflowVariable(self, object, workflow_id='edit_workflow',**kw):
def setWorkflowVariable(self, **kw):
"""
Allows to go through security checking and let a
script allows to modify a workflow variable
"""
workflow_history = object.workflow_history
for workflow in workflow_history.keys():
if len(workflow_history[workflow])!= 0 and workflow==workflow_id:
last_status = workflow_history[workflow][-1]
for variable in kw.keys():
if last_status.has_key(variable):
last_status[variable]=kw[variable]
history = self.object.workflow_history[self.workflow.id]
history[-1].update(kw)
history._p_changed = 1
StateChangeInfo.setWorkflowVariable = setWorkflowVariable
......@@ -608,7 +608,7 @@ def main(argument_list=None):
opts, args = getopt.getopt(sys.argv[1:],
"hpvD", ["help", "verbose", "profile", "coverage=", "portal_id=",
"data_fs_path=",
"bt5_path",
"bt5_path=",
"firefox_bin=",
"xvfb_bin=",
"recreate_catalog=", "erp5_sql_connection_string=",
......
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