diff --git a/bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Base_contribute.xml b/bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Base_contribute.xml index ed2494f248c5c9ce4e1c563a70cec2bd70e25e76..ecb935ceb2467ed25b67c2573de0bb76b3444e0c 100644 --- a/bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Base_contribute.xml +++ b/bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Base_contribute.xml @@ -86,6 +86,16 @@ if classification not in MARKER:\n if follow_up_list:\n document_kw[\'follow_up_list\'] = follow_up_list\n \n +\n +form = portal.REQUEST.form\n +# Lookup for input values in request.form or kw to try to get values in two available modes: the\n +# script coulbe be called from ERP5 Form or directly from Python.\n +# FIXME: this list of properties should not be hardcoded.\n +for key in (\'title\', \'short_title\', \'reference\', \'language\', \'version\', \'description\', ):\n + value = form.get(key, kw.get(key, None))\n + if value not in MARKER:\n + document_kw[key] = value\n +\n if attach_document_to_context:\n # attach document to current context using follow_up\n follow_up_list = document_kw.setdefault(\'follow_up_list\', [])\n @@ -126,20 +136,7 @@ if synchronous_metadata_discovery:\n input_parameter_dict=document_kw)\n is_existing_document_updated = (merged_document!=document)\n document = merged_document\n -# introspect document and find editable properties\n -# then use form or kw and try to get values in two available modes: the\n -# script coulbe be called: from ERP5 From or directly from Python script\n -document_edit_kw = {}\n -property_id_list = document.propertyIds()\n -form = context.REQUEST.form\n -for key in property_id_list:\n - value = form.get(key, kw.get(key, None))\n - if value not in MARKER:\n - document_edit_kw[key] = value\n \n -# edit document \n -if document_edit_kw is not {}:\n - document.edit(**document_edit_kw)\n document_portal_type = document.getTranslatedPortalType()\n if not is_existing_document_updated:\n message = translateString(\'${portal_type} created successfully.\',\n diff --git a/bt5/erp5_ingestion/bt/revision b/bt5/erp5_ingestion/bt/revision index acfba60953b290b6622b2d1f53721968aa77ebf9..83248fb9df4a244c41a10fa536045d5a8e759aee 100644 --- a/bt5/erp5_ingestion/bt/revision +++ b/bt5/erp5_ingestion/bt/revision @@ -1 +1 @@ -141 \ No newline at end of file +142 \ No newline at end of file diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index 6c9d7a56dac6dcf7402c6fc86bcef22854b17378..17491b2601be3947eea40d6fe624bad4de60398a 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -1411,6 +1411,27 @@ class TestDocument(TestDocumentMixin): file=makeFileUpload('TEST-en-002.odt')) self.assertEquals('PDF', contributed_document.getPortalType()) + def test_Base_contribute_input_parameter_dict(self): + """Test contributing while entering input parameters. + """ + person = self.portal.person_module.newContent(portal_type='Person') + contributed_document = person.Base_contribute( + title='user supplied title', + file=makeFileUpload('TEST-en-002.pdf')) + self.tic() + self.assertEquals('user supplied title', contributed_document.getTitle()) + + def test_Base_contribute_input_parameter_dict_request(self): + """Test contributing while entering input parameters through the dialog. + """ + person = self.portal.person_module.newContent(portal_type='Person') + self.portal.REQUEST.form['title'] = 'user supplied title' + contributed_document = person.Base_contribute( + file=makeFileUpload('TEST-en-002.pdf')) + self.tic() + self.assertEquals('user supplied title', contributed_document.getTitle()) + + def test_HTML_to_ODT_conversion_keep_enconding(self): """This test perform an PDF conversion of HTML content then to plain text.