Commit 733ff06f authored by Fabien Morin's avatar Fabien Morin

sort composition by quantity

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29396 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bb60b7ae
...@@ -57,12 +57,19 @@ ...@@ -57,12 +57,19 @@
# it return something like "3.0 % Polyamide, 5.0 % Elasthanne"\n # it return something like "3.0 % Polyamide, 5.0 % Elasthanne"\n
\n \n
title_list = []\n title_list = []\n
cell_list = []\n
poly_list = context.ApparelFabric_asCellRange(matrixbox=1)[0]\n poly_list = context.ApparelFabric_asCellRange(matrixbox=1)[0]\n
for cat, title in poly_list:\n for cat, title in poly_list:\n
cell = context.getCell(cat, base_id=\'composition\')\n cell = context.getCell(cat, base_id=\'composition\')\n
if cell is not None:\n if cell is not None:\n
quantity = cell.getQuantity()\n cell_list.append({\'quantity\':cell.getQuantity(), \'title\':title})\n
text = \'%s %% %s\' % (quantity*100, title)\n \n
# sort by quantity\n
cell_list.sort(key=lambda x: x[\'quantity\'], reverse=True)\n
\n
for cell in cell_list:\n
quantity = cell[\'quantity\']\n
text = \'%s %% %s\' % (quantity*100, cell[\'title\'])\n
title_list.append(text)\n title_list.append(text)\n
final_text = \', \'.join(title_list)\n final_text = \', \'.join(title_list)\n
return final_text\n return final_text\n
...@@ -103,6 +110,7 @@ return final_text\n ...@@ -103,6 +110,7 @@ return final_text\n
<value> <value>
<tuple> <tuple>
<string>title_list</string> <string>title_list</string>
<string>cell_list</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
...@@ -112,6 +120,7 @@ return final_text\n ...@@ -112,6 +120,7 @@ return final_text\n
<string>title</string> <string>title</string>
<string>cell</string> <string>cell</string>
<string>None</string> <string>None</string>
<string>True</string>
<string>quantity</string> <string>quantity</string>
<string>text</string> <string>text</string>
<string>final_text</string> <string>final_text</string>
......
68 69
\ 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