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 @@
# it return something like "3.0 % Polyamide, 5.0 % Elasthanne"\n
\n
title_list = []\n
cell_list = []\n
poly_list = context.ApparelFabric_asCellRange(matrixbox=1)[0]\n
for cat, title in poly_list:\n
cell = context.getCell(cat, base_id=\'composition\')\n
if cell is not None:\n
quantity = cell.getQuantity()\n
text = \'%s %% %s\' % (quantity*100, title)\n
cell_list.append({\'quantity\':cell.getQuantity(), \'title\':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
final_text = \', \'.join(title_list)\n
return final_text\n
......@@ -103,6 +110,7 @@ return final_text\n
<value>
<tuple>
<string>title_list</string>
<string>cell_list</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>context</string>
......@@ -112,6 +120,7 @@ return final_text\n
<string>title</string>
<string>cell</string>
<string>None</string>
<string>True</string>
<string>quantity</string>
<string>text</string>
<string>final_text</string>
......
68
\ No newline at end of file
69
\ 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