Commit 35ee93cc authored by Yusei Tahara's avatar Yusei Tahara

There is a difference between field name and metadata name.

Replace field name list  with field->metadata dictionary.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18419 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 42f35ca7
...@@ -74,12 +74,21 @@ XXX - This script must be verified, written with clean syntax\n ...@@ -74,12 +74,21 @@ XXX - This script must be verified, written with clean syntax\n
"""\n """\n
document = state_change[\'object\']\n document = state_change[\'object\']\n
kw = state_change[\'kwargs\']\n kw = state_change[\'kwargs\']\n
metadata_field_list = (\'title\', \'subject\', \'description\', \'reference\', \'version\', \'language\') # XXX hardcoded?\n \n
# XXX hardcoded?\n
# key is a name of erp5 field.\n
# value is a name of document metadata.\n
metadata_field_mapping_dict = {\'title\':\'title\',\n
\'subject\':\'keyword\',\n
\'description\':\'description\',\n
\'reference\':\'reference\',\n
\'version\':\'version\',\n
\'language\':\'language\'}\n
\n \n
# edit metadata (only if we have OOo file)\n # edit metadata (only if we have OOo file)\n
if document.hasBaseData():\n if document.hasBaseData():\n
new_metadata = {}\n new_metadata = {}\n
for field in metadata_field_list:\n for field in metadata_field_mapping_dict.keys():\n
value = kw.get(field, None)\n value = kw.get(field, None)\n
if value is None:\n if value is None:\n
value_list = kw.get(\'%s_list\' % field, None)\n value_list = kw.get(\'%s_list\' % field, None)\n
...@@ -89,7 +98,8 @@ if document.hasBaseData():\n ...@@ -89,7 +98,8 @@ if document.hasBaseData():\n
else:\n else:\n
value = \'\'\n value = \'\'\n
if value is not None:\n if value is not None:\n
new_metadata[field] = value \n metadata_key = metadata_field_mapping_dict[field]\n
new_metadata[metadata_key] = value\n
if new_metadata:\n if new_metadata:\n
# edit metadata via server\n # edit metadata via server\n
document.activate().updateBaseMetadata(**new_metadata)\n document.activate().updateBaseMetadata(**new_metadata)\n
...@@ -147,7 +157,7 @@ if document.hasBaseData():\n ...@@ -147,7 +157,7 @@ if document.hasBaseData():\n
<string>_getitem_</string> <string>_getitem_</string>
<string>document</string> <string>document</string>
<string>kw</string> <string>kw</string>
<string>metadata_field_list</string> <string>metadata_field_mapping_dict</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>new_metadata</string> <string>new_metadata</string>
<string>_getiter_</string> <string>_getiter_</string>
...@@ -158,6 +168,7 @@ if document.hasBaseData():\n ...@@ -158,6 +168,7 @@ if document.hasBaseData():\n
<string>len</string> <string>len</string>
<string>map</string> <string>map</string>
<string>str</string> <string>str</string>
<string>metadata_key</string>
<string>_write_</string> <string>_write_</string>
<string>_apply_</string> <string>_apply_</string>
</tuple> </tuple>
......
775 777
\ 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