1. Kai Diefenbach
  2. django-lfs

Commits

Maciej Wiśniowski  committed 85a250b

add simple support for manufacturer at product page; assume that it has no sense for variant to have another manufacturer - do not show editable manufacturer field for variants

  • Participants
  • Parent commits 85ba93f
  • Branches default

Comments (0)

Files changed (3)

File lfs/catalog/models.py

View file
         else:
             return self.sku
 
+    def get_manufacturer(self):
+        """Always return parent manufacturer for variants.
+        """
+        if self.is_variant():
+            return self.parent.manufacturer
+        else:
+            return self.manufacturer
+
     def get_tax_rate(self, request):
         """Returns the tax rate of the product.
         """

File lfs/manage/views/product/product.py

View file
 
     class Meta:
         model = Product
-        fields = ("active", "name", "slug", "sku", "sku_manufacturer", "price", "tax", "price_calculator",
+        fields = ("active", "name", "slug", "manufacturer", "sku", "sku_manufacturer", "price", "tax", "price_calculator",
             "short_description", "description", "for_sale", "for_sale_price", "static_block", "template",
             "active_price_calculation", "price_calculation", "price_unit", "unit")
 
 
     class Meta:
         model = Product
-        fields = ("active", "active_name", "name", "slug", "active_sku", "sku", "sku_manufacturer",
+        fields = ("active", "active_name", "name", "slug", "manufacturer", "active_sku", "sku", "sku_manufacturer",
             "active_price", "price", "price_calculator", "active_short_description", "short_description", "active_description",
             "description", "for_sale", "for_sale_price", "active_for_sale", "active_for_sale_price",
             "active_related_products", "active_static_block", "static_block", "template")

File lfs/templates/manage/product/data.html

View file
                         {% endif %}
                     </div>                                        
                 {% endif %}
-            </div>            
+            </div>
+
+            <div class="field">
+                <div class="label">
+                    {{ form.manufacturer.label_tag }}:
+                </div>
+
+                {% if form.manufacturer.errors %}
+                    <div class="error">
+                        {{ form.manufacturer }}
+                        {{ form.manufacturer.errors }}
+                    </div>
+                {% else %}
+                    <div>
+                        {% if product.is_variant %}
+                            {{ product.get_manufacturer }}
+                        {% else %}
+                            {{ form.manufacturer }}
+                        {% endif %}
+                    </div>
+                {% endif %}
+            </div>
         </fieldset>
 
         <fieldset>