Commit e995de3b authored by Julien Muchembled's avatar Julien Muchembled

Fix relation strings field with "my_<base_category>" id.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27364 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3efdc688
...@@ -57,27 +57,23 @@ ...@@ -57,27 +57,23 @@
Get default relation string field parameters\n Get default relation string field parameters\n
based on its id\n based on its id\n
"""\n """\n
field_id = context.getId()\n pieces = context.getId().split(\'_\')\n
if not field_id.startswith(\'my_\'): return {} # this should not happen\n if pieces.pop(0) != \'my\':\n
return {} # this should not happen\n
\n \n
is_list = 0\n if pieces[-1] == \'list\':\n
if field_id.endswith(\'_relative_url\'): idx = 2\n pieces.pop()\n
elif field_id.endswith(\'_title\'): idx = 1\n
elif field_id.endswith(\'_title_list\'):\n
idx = 2\n
is_list = 1\n
else: idx = 0\n
\n \n
# can it be translated title, or something else?\n # can it be translated title, or something else?\n
\n if pieces[-2:] == (\'relative\', \'url\'):\n
pieces = field_id.split(\'_\')\n idx = -2\n
parameter_dict = dict()\n elif pieces[-1] == \'title\':\n
parameter_dict[\'base_category\'] = \'_\'.join(pieces[1:-idx])\n idx = -1\n
if is_list == 0:\n
parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:])\n
else:\n else:\n
parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:-1]) \n idx = len(pieces)\n
return parameter_dict\n \n
return {\'base_category\': \'_\'.join(pieces[:idx]),\n
\'catalog_index\': \'_\'.join(pieces[idx:])}\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -116,14 +112,10 @@ return parameter_dict\n ...@@ -116,14 +112,10 @@ return parameter_dict\n
<tuple> <tuple>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>field_id</string>
<string>is_list</string>
<string>idx</string>
<string>pieces</string> <string>pieces</string>
<string>dict</string>
<string>parameter_dict</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>_write_</string> <string>idx</string>
<string>len</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1216 1217
\ 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