Commits

Kai Diefenbach committed 7e36f98

A lot of changes towards a proper property management

Comments (0)

Files changed (14)

lfstheme/templates/lfs/cart/added_to_cart_items.html

             </td>
             <td>
                 {{ cart_item.product.get_name }}
-                {% for option in cart_item.product.get_options %}
-                    {% if option.property.display_on_product %}
-                        <div>
-                            {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                        </div>
-                    {% endif %}
+                {% for property in cart_item.product.get_displayed_properties %}
+                    <div>
+                        {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                    </div>
                 {% endfor %}
 
                 {% if cart_item.product.is_configurable_product %}
-                    {% for property in cart_item.properties.all %}
+                    {% for property in cart_item.get_properties %}
                         <div>
-                            {{ property.property.name }} : {{ property|option_name_for_property_value }} {{ property.property.unit|safe }}
+                            {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                         </div>
                     {% endfor %}
                 {% endif %}

lfstheme/templates/lfs/cart/cart_inline.html

                         <span class="product-title">
                             {{ cart_item.product.get_name }}
                         </span>
-                        {% for option in cart_item.product.get_options %}
-                            {% if option.property.display_on_product %}
-                                <div>
-                                    {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                                </div>
-                            {% endif %}
+                        {% for property in cart_item.product.get_displayed_properties %}
+                            <div>
+                                {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                            </div>
                         {% endfor %}
 
                         {% if cart_item.product.is_configurable_product %}
                             {% for property in cart_item.get_properties %}
                                 <div>
-                                    {{ property.name }} : {{ property.value }} {{ property.unit|safe }} {{ property.price }}
+                                    {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                                 </div>
                             {% endfor %}
                         {% endif %}
                                name="amount-cart-item_{{ cart_item.id }}"
                                size="6"
                                value="{{ cart_item.amount }}" /> {{ cart_item.product.price_unit }}
-                               
+
                         {% if cart_item.product.active_packing_unit %}
                             <span class="packing-unit">
                                 ({{ cart_item|packages }} {{ cart_item.product.packing_unit_unit }})

lfstheme/templates/lfs/catalog/packing_result.html

+{% load i18n %}
 {% load lfs_tags %}
 <div>
-Das entspricht {{ packs }} Paket/e ({{ real_quantity|decimal_l10n }} qm)
-</div>
-<div>
-und kostet {{ price|currency }}
+   This complies to {{ packs }} {{ unit }} ({{ real_quantity|decimal_l10n }} 
+   {% if product.unit %}{{ product.unit }}{% else %}{% trans "Pieces" %}{% endif %})
+   {% trans "and costs" %} {{ price|currency }}.
 </div>

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

         {{ variant.get_name }}
     </h1>
 
-    {% if not product.is_configurable_product %}
-        <div class="product-properties">
-            {% for option in variant.get_options %}
-                {% if option.property.display_on_product %}
-                    <div>
-                        {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                    </div>
-                {% endif %}
-            {% endfor %}
-        </div>
-    {% endif %}
+    {# Displayed properties #}
+    <div class="product-properties">
+        {% for property in variant.get_displayed_properties %}
+            <div>
+                {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+            </div>
+        {% endfor %}
+    </div>
 
     {% shipping variant %}
 
     {% average_for_instance variant %}
 
+    {# Prices #}
     <div class="prices">
         {% if variant.get_for_sale %}
             <div>
                 <span class="for-sale-standard-price" nowrap="nowrap">
                     <span class="for-sale-standard-price-value">
-                        {{ variant.get_standard_price|currency }} 
+                        {{ variant.get_standard_price|currency }}
                     </span>
                     * {% if product.price_unit %}/ {{ product.price_unit }}{% endif %}</span>
                 <span class="for-sale-price" nowrap="nowrap">
                     <span class="for-sale-price-value">
-                        {{ variant.get_price|currency }} 
+                        {{ variant.get_price|currency }}
                     </span>
                     * {% if product.price_unit %}/ {{ product.price_unit }}{% endif %}
                 </span>
 
     </div>
 
-    {# Configurable Product  #}
+    {# Configurable properties #}
     {% if product.is_configurable_product %}
         <table class="cp-properties"
                id="cp-url"
                data="{% url lfs_calculate_price product.id %}">
 
-            {% for property in product.get_property_input_fields %}
-                <td class="property-label">
-                    {{ property.name }}:
-                </td>
-                <td>
-                    <input class="product-input-field" style="margin: 0 6px" type="input" size="6" name="property-{{ property.id }}" />{{ property.unit }}
-                </td>
-            {% endfor %}
-
             {% for property in properties %}
                 <tr>
-                    <td class="property-label">
-                        {{ property.name }}:
-                    </td>
-                    <td>
-                        <select class="cp-property"
-                                name="property-{{ property.id }}">
-                            {% for option in property.options %}
-                                <option value="{{ option.id }}"
-                                    {% if option.selected %}selected="selected"{% endif %}>
-                                    {{ option.name }} /
-                                    {{ option.price|currency }}
-                                </option>
-                            {% endfor %}
-                        </select>
-                    </td>
+                    {% if property.obj.is_select_field %}
+                        <td class="property-label">
+                            {{ property.name }}:
+                        </td>
+                        <td>
+                            <select class="cp-property"
+                                    name="property-{{ property.id }}">
+                                {% if not property.obj.required %}
+                                    <option>---</option>
+                                {% endif %}
+                                {% for option in property.options %}
+                                    <option value="{{ option.id }}"
+                                        {% if option.selected %}selected="selected"{% endif %}>
+                                        {{ option.name }} /
+                                        {{ option.price|currency }}
+                                    </option>
+                                {% endfor %}
+                            </select>
+                        </td>
+                    {% endif %}
+                    {% if property.obj.is_input_field %}
+                        <td class="property-label">
+                            {{ property.name }}:
+                        </td>
+                        <td>
+                            <input class="product-input-field" type="input" size="6" name="property-{{ property.id }}" />{{ property.unit }}
+                        </td>
+                    {% endif %}
                 </tr>
             {% endfor %}
         </table>
                 <div class="product-quantity packing-unit"
                     id="packing-url"
                     data="{% url lfs_calculate_packing product.id %}">
-                    <input class="number product-quantity" 
-                           name="quantity" 
-                           size="10" 
-                           type="text" 
+                    <input class="number product-quantity"
+                           name="quantity"
+                           size="10"
+                           type="text"
                            value="1" /> {{ product.price_unit }}
                 </div>
-                
+
                 <div class="packing-result">
                     {{ packing_result }}
                 </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.price_unit }} #}
+                {# </div> #}
             {% endif %}
             <br clear="both">
 
 
         {% endif %}
     </div>
+
     <p class="product-description">
         {{ variant.get_description|safe}}
     </p>
 
-    <div class="variants">
-        {# Product with variants #}
+    {# Product with variants #}
+    
+    {% if product.is_product_with_variants %}
 
-        {% ifequal product.sub_type "1" %}
+        <div class="variants">
             <h1 class="section">{% trans 'Variants' %}</h1>
 
+            {# List #}
             {% ifequal product.variants_display_type 0 %}
                 <table class="product-variants lfs-default"
                        data="{% url lfs_select_variant %}">
                             <td>
                                 {{ product_variant.get_name }}
                             </td>
-                            {% for option in product_variant.get_options %}
+                            {% for property in product_variant.get_variant_properties %}
                                 <td>
-                                    {{ option.value|option_name }}
+                                    {{ property.value }}
                                 </td>
                             {% endfor %}
                             <td class="number"
                 </table>
             {% endifequal %}
 
+            {# Select field #}
             {% ifequal product.variants_display_type 1 %}
 
                 <div>
                             </select>
                         </div>
                     {% endfor %}
+                </div>
+            {% endifequal %}
+        </div>
+    {% endif %}
 
-                    <noscript>
-                        <input type="submit"
-                               name="refresh-options"
-                               value="{% trans 'Refresh options' %}"/>
-                    </noscript>
-                </div>
-
-            {% endifequal %}
-        {% endifequal %}
-    </div>
-
+    {# Accessories #}
     {% if product_accessories %}
         <div class="accessories">
             <h1 class="section">{% trans 'Accessories' %}</h1>

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

                             <td>
                                 {{ product_variant.get_name }}
                             </td>
-                            {% for option in product_variant.get_options %}
+                            {% for property in product_variant.get_variant_properties %}
                                 <td>
-                                    {{ option.value|option_name }}
+                                    {{ property.value }}
                                 </td>
                             {% endfor %}
                             <td class="number"

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

                             <td>
                                 {{ product_variant.get_name }}
                             </td>
-                            {% for option in product_variant.get_options %}
+                            {% for property in product_variant.get_variant_properties %}
                                 <td>
-                                    {{ option.value|option_name }}
+                                    {{ property.value }}
                                 </td>
                             {% endfor %}
                             <td class="number"

lfstheme/templates/lfs/checkout/checkout_cart_inline.html

             </td>
             <td>
                 {{ cart_item.product.get_name }}
-                {% for option in cart_item.product.get_options %}
-                    {% if option.property.display_on_product %}
-                        <div>
-                            {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                        </div>
-                    {% endif %}
+                {% for property in cart_item.product.get_displayed_properties %}
+                    <div>
+                        {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                    </div>
                 {% endfor %}
 
                 {% if cart_item.product.is_configurable_product %}
-                    {% for property in cart_item.properties.all %}
+                    {% for property in cart_item.get_properties %}
                         <div>
-                            {{ property.property.name }} : {{ property|option_name_for_property_value }} {{ property.property.unit|safe }}
+                            {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                         </div>
                     {% endfor %}
                 {% endif %}

lfstheme/templates/lfs/mail/order_received_mail.html

                        {{ item.product_sku }}
                     </td>
                     <td>
-                       {{ item.product_name }}
-                       {% for option in item.product.get_options %}
-                            {% if option.property.display_on_product %}
-                               <div>
-                                   {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                               </div>
-                            {% endif %}
-                       {% endfor %}
+                        {{ item.product_name }}
+                        {% for property in item.product.get_displayed_properties %}
+                            <div>
+                                {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                            </div>
+                        {% endfor %}
 
                         {% if item.product.is_configurable_product %}
-                            {% for property in item.properties.all %}
+                            {% for property in item.get_properties %}
                                 <div>
-                                    {{ property.property.name }} : {{ property.value|quantity }} {{ property.property.unit|safe }}
+                                    {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                                 </div>
                             {% endfor %}
                         {% endif %}

lfstheme/templates/lfs/mail/order_received_mail.txt

 {% trans 'Order' %}: 
 ==============================================================================
 {% for item in order.items.all %}{% trans 'SKU' %}:  {{ item.product_sku }}
-{% trans 'Name' %}: {{ item.product_name }} {% for option in item.product.get_options %}{% if option.property.display_on_product %}{{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}\n{% endif %}{% endfor %}
+{% trans 'Name' %}: {{ item.product_name }} {% for property in item.product.get_displayed_properties %}{{ property.name }} : {{ property.value }} {{ property.unit|safe }}\n{% endfor %}
 {% trans 'Amount' %}: {{ item.product_amount }} {{ item.product.price_unit }} {% if item.product.active_packing_unit %}{{ item|packages }} {{ item.product.packing_unit_unit }}{% endif %} 
 {% trans 'Price' %}: {{ item.product_price_gross|currency }}
 {% trans 'Total' %}: {{ item.price_gross|currency }}

lfstheme/templates/lfs/mail/order_sent_mail.html

                     </td>
                     <td>
                        {{ item.product_name }}
-                       {% for option in item.product.get_options %}
-                            {% if option.property.display_on_product %}
-                               <div>
-                                   {{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}
-                               </div>
-                            {% endif %}
-                       {% endfor %}
+                        {% for property in item.product.get_displayed_properties %}
+                            <div>
+                                {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                            </div>
+                        {% endfor %}
 
                         {% if item.product.is_configurable_product %}
-                            {% for property in item.properties.all %}
+                            {% for property in item.get_properties %}
                                 <div>
-                                    {{ property.property.name }} : {{ property.value|quantity }} {{ property.property.unit|safe }}
+                                    {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                                 </div>
                             {% endfor %}
                         {% endif %}

lfstheme/templates/lfs/mail/order_sent_mail.txt

 {% trans 'Order' %}: 
 ==============================================================================
 {% for item in order.items.all %}{% trans 'SKU' %}:  {{ item.product_sku }}
-{% trans 'Name' %}: {{ item.product_name }} {% for option in item.product.get_options %}{% if option.property.display_on_product %}{{ option.property.name }} : {{ option.value|option_name }} {{ option.property.unit|safe }}\n{% endif %}{% endfor %}
+{% trans 'Name' %}: {{ item.product_name }} {% for property in item.product.get_displayed_properties %}{{ property.name }} : {{ property.value }} {{ property.unit|safe }}\n{% endfor %}
 {% trans 'Amount' %}: {{ item.product_amount }} {{ item.product.price_unit }} {% if item.product.active_packing_unit %}{{ item|packages }} {{ item.product.packing_unit_unit }}{% endif %} 
 {% trans 'Price' %}: {{ item.product_price_gross|currency }}
 {% trans 'Total' %}: {{ item.price_gross|currency }}

lfstheme/templates/lfs/order/lfs_order_tmpl.html

             {% trans 'Customer name' %}:
         </td>
         <td>
-            {{current_order.customer_firstname}} {{current_order.customer_lastname}}
+            {{ current_order.customer_firstname }} {{ current_order.customer_lastname }}
         </td>
         <td class="label">
             {% trans 'Date' %}:
         </td>
         <td>
-            {{current_order.created|date:_("DATETIME_FORMAT")}}
+            {{ current_order.created|date:_("DATETIME_FORMAT") }}
         </td>
     </tr>
     <tr>
             {% trans 'E-mail' %}:
         </td>
         <td>
-            <a href="mailto:{{current_order.customer_email}}">
-                {{current_order.customer_email}}
+            <a href="mailto:{{ current_order.customer_email }}">
+                {{ current_order.customer_email }}
             </a>                
         </td>
         <td class="label">
             {% trans 'State' %}:
         </td>
         <td>
-            {{current_order.get_state_display}}
+            {{ current_order.get_state_display }}
         </td>
     </tr>
     <tr>
             {% trans 'Phone' %}:
         </td>
         <td>
-            {{current_order.shipping_phone}}
+            {{ current_order.shipping_phone }}
         </td>
         <td class="label">
             {% trans 'Total' %}:
         </td>
         <td>
-            {{current_order.price|currency}}
+            {{ current_order.price|currency }}
         </td>
     </tr>
     
     <tr>
         <td>
             <div>
-                {{current_order.invoice_firstname}}
+                {{ current_order.invoice_firstname }}
             </div>
             <div>
-                {{current_order.invoice_lastname}}
+                {{ current_order.invoice_lastname }}
             </div>
             <div>
-                {{current_order.invoice_company_name}}
+                {{ current_order.invoice_company_name }}
             </div>
             <div>
-                {{current_order.invoice_street}}
+                {{ current_order.invoice_street }}
             </div>
             <div>
-                {{current_order.invoice_zip_code}} {{current_order.invoice_city}}
+                {{ current_order.invoice_zip_code }} {{ current_order.invoice_city }}
             </div>
             <div>
-                {{current_order.invoice_country}}
+                {{ current_order.invoice_country }}
             </div>
             <div>
-                {{current_order.invoice_phone}}
+                {{ current_order.invoice_phone }}
             </div>
         </td>
         <td>
             <div>
-                {{current_order.shipping_firstname}}
+                {{ current_order.shipping_firstname }}
             </div>
             <div>
-                {{current_order.shipping_lastname}}
+                {{ current_order.shipping_lastname }}
             </div>
             <div>
-                {{current_order.shipping_company_name}}
+                {{ current_order.shipping_company_name }}
             </div>            
             <div>
-                {{current_order.shipping_street}}
+                {{ current_order.shipping_street }}
             </div>
             <div>
-                {{current_order.shipping_zip_code}} {{current_order.shipping_city}}
+                {{ current_order.shipping_zip_code }} {{ current_order.shipping_city }}
             </div>
             <div>
-                {{current_order.shipping_country}}
+                {{ current_order.shipping_country }}
             </div>                
             <div>
-                {{current_order.shipping_phone}}
+                {{ current_order.shipping_phone }}
             </div>
         </td>        
         <td>
             <div>
-                {{current_order.shipping_method}}
+                {{ current_order.shipping_method }}
             </div>
         </td>
         <td>
             <div>
-                {{current_order.payment_method.name}}
+                {{ current_order.payment_method.name }}
             </div>
             {% ifequal current_order.payment_method.id 1 %}
                 <div>
-                    {{current_order.account_number}}
+                    {{ current_order.account_number }}
                 </div>
                 <div>
-                    {{current_order.bank_identification_code}}
+                    {{ current_order.bank_identification_code }}
                 </div>
                 <div>
-                    {{current_order.bank_name}}
+                    {{ current_order.bank_name }}
                 </div>
                 <div>
-                    {{current_order.depositor}}
+                    {{ current_order.depositor }}
                 </div>
             {% endifequal %}
         </td>
     {% for item in current_order.items.all %}
         <tr>
             <td>
-               {{item.product_sku}} 
+               {{ item.product_sku }} 
             </td>
             <td>
-               {{item.product_name}} 
-                {% for option in item.product.get_options %}
-                    {% if option.property.display_on_product %}
-                        <div>
-                            {{option.property.name}} : {{option.value|option_name}} {{ option.property.unit|safe }}
-                        </div>
-                    {% endif %}
+                {{ item.product_name }} 
+                {% for property in item.product.get_displayed_properties %}
+                    <div>
+                        {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                    </div>
                 {% endfor %}
                 
                 {% if item.product.is_configurable_product %}
-                    {% for property in item.properties.all %}
+                    {% for property in item.get_properties %}
                         <div>
-                            {{ property.property.name }} : {{ property.value }} {{ property.property.unit|safe }}
+                            {{ property.name }} : {{ property.value }} {{ property.unit|safe }} ({{ property.price|currency }})
                         </div>
                     {% endfor %}
                 {% endif %}
                 
             </td>
             <td class="number">
-               {{item.product_amount}} 
+               {{ item.product_amount }} 
             </td>
             <td class="number">
-               {{item.product_price_gross|currency}} 
+               {{ item.product_price_gross|currency }} 
             </td>
             <td class="number">
-               {{item.price_gross|currency}}
+               {{ item.price_gross|currency }}
             </td>
         </tr>
     {% endfor %}        
     <tr>
         <td></td>
         <td>
-            {% trans 'Shipping' %} ({{current_order.shipping_method}})
+            {% trans 'Shipping' %} ({{ current_order.shipping_method }})
         </td>
         <td class="number">
             1
         </td>
         <td class="number">
-            {{current_order.shipping_price|currency}}
+            {{ current_order.shipping_price|currency }}
         </td>
         <td class="number">
-            {{current_order.shipping_price|currency}}
+            {{ current_order.shipping_price|currency }}
         </td>
     </tr>
     <tr>
         <td></td>
         <td>
-            {% trans 'Payment' %} ({{current_order.payment_method}})
+            {% trans 'Payment' %} ({{ current_order.payment_method }})
         </td>
         <td class="number">
             1
         </td>
         <td class="number">
-            {{current_order.payment_price|currency}}
+            {{ current_order.payment_price|currency }}
         </td>
         <td class="number">
-            {{current_order.payment_price|currency}}
+            {{ current_order.payment_price|currency }}
         </td>
     </tr>
     <tr class="total">
         <td colspan="5"
             class="number total">
-            {{current_order.price|currency}}
+            {{ current_order.price|currency }}
         </td>
     </tr>
     <tr>
         <td colspan="5"
             class="number tax">
             <span class="total-label">{% trans 'Inclusive VAT' %}:</span>
-            {{current_order.tax|currency}}
+            {{ current_order.tax|currency }}
         </td>
     </tr>        
 </table>
         </tr>
         <tr>
             <td colspan="5">
-                {{current_order.message}}
+                {{ current_order.message }}
             </td>
         </tr>
     </table>

lfstheme/templates/lfs/search/livesearch_results.html

                 onclick="window.location='{{ product.get_absolute_url }}'">
                 <td class="image">
                     {% if product.get_image %}
-                        <a href="{{product.get_absolute_url}}">
-                            <img src="{{product.get_image.url_60x60}}"
-                                 alt="{{product.get_name}}"
-                                 title="{{product.get_name}}" />
+                        <a href="{{ product.get_absolute_url }}">
+                            <img src="{{ product.get_image.url_60x60 }}"
+                                 alt="{{ product.get_name }}"
+                                 title="{{ product.get_name }}" />
                         </a>
                     {% endif %}
                 </td>
                 <td class="text">
-                    <a href="{{product.get_absolute_url}}">
+                    <a href="{{ product.get_absolute_url }}">
                         {{ product.get_name }} 
                     </a>
-                    {% for option in product.get_options %}
-                        {% if option.property.display_on_product %}
-                            <div>
-                                {{option.property.name}} : {{option.value|option_name}} {{ option.property.unit|safe }}
-                            </div>
-                        {% endif %}
+                    {% for property in product.get_displayed_properties %}
+                        <div>
+                            {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                        </div>
                     {% endfor %}
                 </td>
                 <td class="number"
         <tr>
             <td class="all-results"
                 colspan="3">
-                <a href="{% url lfs_search %}?phrase={{phrase}}">
+                <a href="{% url lfs_search %}?phrase={{ phrase }}">
                     {% trans 'All results' %} ({{ total }})
                 </a>
             </td>

lfstheme/templates/lfs/search/search_results.html

 
     <p class="search-results-description">
         {% trans 'You searched for' %} <span class="search-results-phrase">"{{ phrase }}"</span>.
-        {% blocktrans count total as counter %}There has been found 1 product.{% plural %}There has been found {{  counter  }} products.{% endblocktrans %}
+        {% blocktrans count total as counter %}There has been found 1 product.{% plural %}There has been found {{ counter }} products.{% endblocktrans %}
     </p>
 
     {% if products %}
                     <a href="{{ product.get_absolute_url }}">
                         {{ product.get_name }}
                     </a>
-                    {% for option in product.get_options %}
-                        {% if option.property.display_on_product %}
-                            <div>
-                                {{ option.property.name }} : {{ option.value|option_name }} {{  option.property.unit|safe  }}
-                            </div>
-                        {% endif %}
+                    {% for property in product.get_displayed_properties %}
+                        <div>
+                            {{ property.name }} : {{ property.value }} {{ property.unit|safe }}
+                        </div>
                     {% endfor %}
                 </div>