Commits

Kai Diefenbach committed afb01f1

More towards a proper property handling

Comments (0)

Files changed (7)

lfstheme/templates/lfs/cart/added_to_cart_items.html

                 {% if cart_item.product.is_configurable_product %}
                     {% for property in cart_item.get_properties %}
                         <div>
-                            {{ property.name }}: {{ property.value }} {{ property.unit|safe }}
+                            {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                             {% if property.is_select_field %}
                                 ({{ property.price|currency }})
                             {% endif %}
 
             </td>
             <td class="number">
-                {{ cart_item.amount|quantity }} {{ cart_item.product.price_unit }}
+                {{ cart_item.amount|quantity }} {{ cart_item.product.unit }}
 
                 {% if cart_item.product.active_packing_unit %}
                     <span class="packing-unit">

lfstheme/templates/lfs/cart/cart_inline.html

                         {% if cart_item.product.is_configurable_product %}
                             {% for property in cart_item.get_properties %}
                                 <div>
-                                    {{ property.name }}: {{ property.value }} {{ property.unit|safe }}
-                                    {% if property.is_select_field %}
+                                    {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
+                                    {% if property.display_price %}
                                         ({{ property.price|currency }})
                                     {% endif %}
                                 </div>
                                type="text"
                                name="amount-cart-item_{{ cart_item.id }}"
                                size="6"
-                               value="{{ cart_item.amount }}" /> {{ cart_item.product.price_unit }}
+                               value="{{ cart_item.amount }}" />
+                               {% if cart_item.product.unit %}
+                                    {{ cart_item.product.unit }}
+                               {% endif %}
 
                         {% if cart_item.product.active_packing_unit %}
                             <span class="packing-unit">

lfstheme/templates/lfs/catalog/product_base.html

 {% block content %}
 
     {{ product.static_block.html|safe }}
-	
+
     {% product_navigation product %}
 
     <div class="overview">
-		{% current_category product %}
+        {% current_category product %}
         <a href="{{current_category.get_absolute_url}}">
            {% trans 'Back to overview' %}
         </a>

lfstheme/templates/lfs/catalog/products/product_inline.html

 
     <div class="product-images">
         <div class="main-image">
-            <a href="{{ variant.get_image.url_400x400 }}"
-               class="product-image">
-                <img src="{{ variant.get_image.url_200x200 }}"
-                     alt="{{ variant.get_name}}" />
-            </a>
+            {% if variant.get_image %}
+                <a href="{{ variant.get_image.url_400x400 }}"
+                   class="product-image">
+                    <img src="{{ variant.get_image.url_200x200 }}"
+                         alt="{{ variant.get_name}}" />
+                </a>
+            {% endif %}
         </div>
         <div class="sub-images">
             {% for image in variant.get_sub_images %}
                 <tr>
                     {% if property.obj.is_select_field %}
                         <td class="property-label">
-                            {{ property.name }}:
+                            {{ property.title }}:
                         </td>
                         <td>
                             <select class="cp-property"
                                 {% for option in property.options %}
                                     <option value="{{ option.id }}"
                                         {% if option.selected %}selected="selected"{% endif %}>
-                                        {{ option.name }} /
-                                        {{ option.price|currency }}
+                                        {{ option.name }}
+                                        
+                                        {% if property.display_price %}
+                                         / {{ option.price|currency }}                                            
+                                        {% endif %}
                                     </option>
                                 {% endfor %}
                             </select>
                         </td>
-                    {% endif %}
-                    {% if property.obj.is_text_field %}
+                    {% else %}                        
                         <td class="property-label">
-                            {{ property.name }}:
+                            {{ property.title }}:
                         </td>
                         <td>
-                            <input class="product-input-field" type="input" size="6" name="property-{{ property.id }}" />{{ property.unit }}
+                            <input class="product-input-field" type="input" size="6" name="property-{{ property.id }}" />
+                        </td>
+                        <td>
+                            {{ property.unit }}
                         </td>
                     {% endif %}
                 </tr>
                 </div>
 
             {% else %}
-                {# <div class="product-quantity"> #}
-                {#     <input name="quantity" #}
-                {#            size="10" #}
-                {#            type="text" #}
-                {#            value="1" /> {{ product.price_unit }} #}
-                {# </div> #}
+                <div class="product-quantity">
+                    <input name="quantity"
+                           size="10"
+                           type="text"
+                           value="1" /> {{ product.unit }}
+                </div>
             {% endif %}
             <br clear="both">
 
     </p>
 
     {# Product with variants #}
-    
+
     {% if product.is_product_with_variants %}
 
         <div class="variants">

lfstheme/templates/lfs/checkout/checkout_cart_inline.html

                     {% for property in cart_item.get_properties %}
                         <div>
                             {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
-                            {% if property.is_select_field %}
+                            {% if property.display_price %}
                                 ({{ property.price|currency }})
                             {% endif %}                            
                         </div>
 
             </td>
             <td class="number">
-                {{ cart_item.amount }} {{ cart_item.product.price_unit }}
+                {{ cart_item.amount }} {{ cart_item.product.unit }}
                 
                 {% if cart_item.product.active_packing_unit %}
                     <span class="packing-unit">

lfstheme/templates/lfs/portlets/filter.html

 {% load lfs_tags %}
 
 {% if show %}
-	<div class="filtered-navigation-portlet portlet">
+    <div class="filtered-navigation-portlet portlet">
 
-	    <div class="portlet-header">
-	        {{ title }} <a href="{% url lfs_reset_all_product_filter category.slug %}">[x]</a>
-	    </div>
+        <div class="portlet-header">
+            {{ title }} <a href="{% url lfs_reset_all_product_filter category.slug %}">[x]</a>
+        </div>
 
-	    <div class="portlet-body">
-			{% if show_product_filters %}
-		        {% for property_group in product_filters %}
-		            {% if property_group.items %}
-		                <div class="portlet-item">
-		                    <div class="filter-title {% if forloop.first %}first{% endif %}">
-		                        <span>
-		                            {{property_group.name}}
-		                        </span>
-		                        {% if property_group.show_reset %}
-		                            <a href="{% url lfs_reset_product_filter category.slug property_group.id %}">[x]</a>
-		                        {% endif %}
-		                    </div>
-		                    {% for property in property_group.items %}
-		                        <div>
-		                            {% if property_group.object.is_number_field %}
-		                                {% if property_group.show_quantity %}
-		                                    <a href='{% url lfs_set_product_filter category.slug property_group.id property.min property.max %}'>
-		                                        {{property.min|quantity}} - {{property.max|quantity}} {{ property_group.unit|safe }} ({{ property.quantity }})
-		                                    </a>
-		                                {% else %}
-		                                    <span>
-		                                        {{property.min|quantity}} - {{property.max|quantity}} {{ property_group.unit|safe }}
-		                                    </span>
-		                                {% endif %}
-		                            {% else %}
-		                                {% if property.show_quantity %}
-		                                    <a href='{% url lfs_set_product_filter category.slug property_group.id property.value %}'>
-		                                        {{property.name}} {{ property_group.unit|safe }} ({{ property.quantity }})
-		                                    </a>
-		                                {% else %}
-		                                    <span>
-		                                        {{property.name}} {{ property_group.unit|safe }}
-		                                    </span>
-		                                {% endif %}
+        <div class="portlet-body">
+            {% if show_product_filters %}
+                {% for property_group in product_filters %}
+                    {% if property_group.items %}
+                        <div class="portlet-item">
+                            <div class="filter-title {% if forloop.first %}first{% endif %}">
+                                <span>
+                                    {{ property_group.title }}
+                                </span>
+                                {% if property_group.show_reset %}
+                                    <a href="{% url lfs_reset_product_filter category.slug property_group.id %}">[x]</a>
+                                {% endif %}
+                            </div>
+                            {% for property in property_group.items %}
+                                <div>
+                                    {% if property_group.object.is_number_field %}
+                                        {% if property_group.show_quantity %}
+                                            <a href='{% url lfs_set_product_filter category.slug property_group.id property.min property.max %}'>
+                                                {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }} ({{ property.quantity }})
+                                            </a>
+                                        {% else %}
+                                            <span>
+                                                {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }}
+                                            </span>
+                                        {% endif %}
+                                    {% else %}
+                                        {% if property.show_quantity %}
+                                            <a href='{% url lfs_set_product_filter category.slug property_group.id property.value %}'>
+                                                {{ property.name }} {{ property_group.unit|safe }} ({{ property.quantity }})
+                                            </a>
+                                        {% else %}
+                                            <span>
+                                                {{ property.name }} {{ property_group.unit|safe }}
+                                            </span>
+                                        {% endif %}
 
-		                            {% endif %}
-		                        </div>
-		                    {% endfor %}
-		                </div>
-		            {% endif %}
-		        {% endfor %}
-			{% endif %}
+                                    {% endif %}
+                                </div>
+                            {% endfor %}
+                        </div>
+                    {% endif %}
+                {% endfor %}
+            {% endif %}
 
-			{% if show_price_filters %}
-		        <div class="portlet-item">
+            {% if show_price_filters %}
+                <div class="portlet-item">
 
-		            <div class="filter-title">
-		                <span>{% trans 'Price' %}</span>
-		                {% if price_filters.show_reset %}
-		                    <a href="{% url lfs_reset_price_filter category.slug %}">[x]</a>
-		                {% endif %}
-		            </div>
+                    <div class="filter-title">
+                        <span>{% trans 'Price' %}</span>
+                        {% if price_filters.show_reset %}
+                            <a href="{% url lfs_reset_price_filter category.slug %}">[x]</a>
+                        {% endif %}
+                    </div>
 
-		            {% for price_filter in price_filters.items %}
-		                <div>
-		                    {% if price_filters.show_quantity %}
-		                        <a href="{% url lfs_set_price_filter category.slug %}?min={{ price_filter.min }}&amp;max={{ price_filter.max }}">
-		                            {% trans 'Up to' %} {{price_filter.max|number}}
-		                            ({{price_filter.quantity}})
-		                        </a>
-		                    {% else %}
-		                        <span>
-		                            {% trans 'Up to' %} {{price_filter.max|currency}}
-		                        </span>
-		                    {% endif %}
-		                </div>
-		            {% endfor %}
-		        </div>
-		        {# <form action="{% url lfs_set_price_filter category.slug %}" #}
-		        {#       method="post">         #}
-		        {#     <div> #}
-		        {#         <label>{% trans 'From' %}</label> #}
-		        {#         <input type="text" #}
-		        {#                name="min" #}
-		        {#                value="{{price_filter.min}}" #}
-		        {#                size="10" /> #}
-		        {#     </div>                    #}
-		        {#     <div> #}
-		        {#         <label>{% trans 'To' %}</label> #}
-		        {#         <input type="text" #}
-		        {#                name="max"  #}
-		        {#                value="{{price_filter.max}}" #}
-		        {#                size="10" />                                           #}
-		        {#     </div>        #}
-		        {#     <div> #}
-		        {#         <input type="submit" #}
-		        {#                value="{% trans 'Go!' %}" /> #}
-		        {#     </div> #}
-		        {# </form> #}
-			{% endif %}
-	    </div>
+                    {% for price_filter in price_filters.items %}
+                        <div>
+                            {% if price_filters.show_quantity %}
+                                <a href="{% url lfs_set_price_filter category.slug %}?min={{ price_filter.min }}&amp;max={{ price_filter.max }}">
+                                    {% trans 'Up to' %} {{ price_filter.max|number }}
+                                    ({{ price_filter.quantity }})
+                                </a>
+                            {% else %}
+                                <span>
+                                    {% trans 'Up to' %} {{ price_filter.max|currency }}
+                                </span>
+                            {% endif %}
+                        </div>
+                    {% endfor %}
+                </div>
+                {# <form action="{% url lfs_set_price_filter category.slug %}" #}
+                {#       method="post">         #}
+                {#     <div> #}
+                {#         <label>{% trans 'From' %}</label> #}
+                {#         <input type="text" #}
+                {#                name="min" #}
+                {#                value="{{ price_filter.min }}" #}
+                {#                size="10" /> #}
+                {#     </div>                    #}
+                {#     <div> #}
+                {#         <label>{% trans 'To' %}</label> #}
+                {#         <input type="text" #}
+                {#                name="max"  #}
+                {#                value="{{ price_filter.max }}" #}
+                {#                size="10" />                                           #}
+                {#     </div>        #}
+                {#     <div> #}
+                {#         <input type="submit" #}
+                {#                value="{% trans 'Go!' %}" /> #}
+                {#     </div> #}
+                {# </form> #}
+            {% endif %}
+        </div>
 
-	    <div class="portlet-footer">
-	        <a href="{% url lfs_reset_all_product_filter category.slug %}">
-	            {% trans 'Reset all filters' %}
-	        </a>
-	    </div>
-	</div>
+        <div class="portlet-footer">
+            <a href="{% url lfs_reset_all_product_filter category.slug %}">
+                {% trans 'Reset all filters' %}
+            </a>
+        </div>
+    </div>
 {% endif %}

lfstheme/templatetags/lfs_theme_tags.py

     def render(self, context):
 
         object = context.get("category") or context.get("product")
-        
+
         if object is None:
             object = lfs.core.utils.get_default_shop()
-        
+
         for slot in Slot.objects.all():
             context["Slot%s" % slot.name] = portlets.utils.has_portlets(slot, object)
 
             content_class = "span-19 padding-left last"
         elif context.get("SlotRight", None):
             content_class = "span-20 padding-right"
-        
+
         context["content_class"] = content_class
         return ''