Kai Diefenbach avatar Kai Diefenbach committed b06f2cd Merge

Merged in pigletto/django-lfs-0.7-raw (pull request #17)

Comments (0)

Files changed (4)


                 "display_price": property.display_price,
                 "value": value,
                 "price": price,
+                "obj": property
         return properties


 import lfs.core.utils
 from lfs.caching.utils import lfs_get_object_or_404
 from lfs.cart.views import add_to_cart
-from lfs.catalog.models import Category
+from lfs.catalog.models import Category, Property
 from lfs.catalog.models import File
 from lfs.catalog.models import Product
 from lfs.catalog.models import ProductPropertyValue
     for key, option_id in request.POST.items():
         if key.startswith("property"):
-                po = PropertyOption.objects.get(pk=option_id)
-            except (ValueError, PropertyOption.DoesNotExist):
+                property_id = int(key.split('-')[1])
+                property = Property.objects.get(pk=property_id)
+                if property.is_select_field:
+                    po = PropertyOption.objects.get(property=property, pk=option_id)
+                    if property.add_price:
+                        po_price = float(po.price)
+                        property_price += po_price
+            except (IndexError, ValueError, TypeError, PropertyOption.DoesNotExist, Property.DoesNotExist):
-            else:
-                if po.property.add_price:
-                    try:
-                        po_price = float(po.price)
-                    except (TypeError, ValueError):
-                        pass
-                    else:
-                        property_price += po_price
     if product.for_sale:
         for_sale_standard_price = product.get_standard_price(request, with_properties=False)


                 "unit": property_value.property.unit,
                 "display_price": property_value.property.display_price,
                 "value": value,
-                "price": price
+                "price": price,
+                "obj": property_value.property
         return properties


     if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
         xhr.setRequestHeader("X-CSRFToken", $.cookie("csrftoken"));
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.