Commits

Kai Diefenbach committed 8f1dbff

Display property options in the correct order by positions within filter portlet.

  • Participants
  • Parent commits 4bc60db

Comments (0)

Files changed (1)

File lfs/catalog/utils.py

 
         # If the property is a select field we want to display the name of the
         # option instead of the id.
+        position = 1
         if properties_mapping[row[0]].is_select_field:
             try:
                 name = options_mapping[row[1]].name
+                position = options_mapping[row[1]].position
             except KeyError:
                 name = row[1]
         else:
                     "id"       : row[0],
                     "value"    : value,
                     "name"     : name,
+                    "position": position,
                     "quantity" : amount[row[0]][row[1]],
                     "show_quantity" : False,
                 }]
                 "id"       : row[0],
                 "value"    : value,
                 "name"     : name,
+                "position": position,
                 "quantity" : amount[row[0]][row[1]],
                 "show_quantity" : True,
             })
         # Sort the values. NOTE: This has to be done here (and not via SQL) as
         # the value field of the property is a char field and can't ordered
         # properly for numbers.
-        values.sort(lambda a, b: cmp(a["value"], b["value"]))
+        values.sort(lambda a, b: cmp(a["position"], b["position"]))
 
         result.append({
             "id"    : property_id,
     """
     """
     packages = calculate_packages(product, quantity)
-    return packages * product.packing_unit
+    return packages * product.packing_unit