Browse Source

Rename template references to variants

Where I previously thought that renaming HTML/CSS is more hassle than
it's worth, @mbertheau convinced me that to update a codebase, a general
search-and-replace is the best approach already and will catch any
HTML/CSS changes.

I also missed to deprecate the min_variant_price properties.
master
Maik Hoepfel 11 years ago
parent
commit
1b2574dd3d

+ 1
- 1
Makefile View File

15
 	sites/sandbox/manage.py syncdb --noinput
15
 	sites/sandbox/manage.py syncdb --noinput
16
 	sites/sandbox/manage.py migrate
16
 	sites/sandbox/manage.py migrate
17
 	# Import some fixtures. Order is important as JSON fixtures include primary keys
17
 	# Import some fixtures. Order is important as JSON fixtures include primary keys
18
-	sites/sandbox/manage.py loaddata sites/sandbox/fixtures/variants.json
18
+	sites/sandbox/manage.py loaddata sites/sandbox/fixtures/child_products.json
19
 	sites/sandbox/manage.py oscar_import_catalogue sites/sandbox/fixtures/*.csv
19
 	sites/sandbox/manage.py oscar_import_catalogue sites/sandbox/fixtures/*.csv
20
 	sites/sandbox/manage.py oscar_import_catalogue_images sites/sandbox/fixtures/images.tar.gz
20
 	sites/sandbox/manage.py oscar_import_catalogue_images sites/sandbox/fixtures/images.tar.gz
21
 	sites/sandbox/manage.py oscar_populate_countries
21
 	sites/sandbox/manage.py oscar_populate_countries

+ 9
- 1
docs/source/releases/v0.8.rst View File

214
 Product structure
214
 Product structure
215
 ~~~~~~~~~~~~~~~~~
215
 ~~~~~~~~~~~~~~~~~
216
 
216
 
217
-Generally, backwards compatibility has been preserved. Two changes are
217
+Generally, backwards compatibility has been preserved. Those changes are
218
 unavoidable:
218
 unavoidable:
219
 
219
 
220
 * You now need to explicitly set product structure when creating a product;
220
 * You now need to explicitly set product structure when creating a product;
224
   deprecation warning), but if you used the old related name in a query lookup
224
   deprecation warning), but if you used the old related name in a query lookup
225
   (e.g. ``products.filter(variants__title='foo')``, you will have to change it
225
   (e.g. ``products.filter(variants__title='foo')``, you will have to change it
226
   to ``children``.
226
   to ``children``.
227
+* Template blocks and CSS classes have been renamed.
227
 
228
 
228
 The following methods and properties have been deprecated:
229
 The following methods and properties have been deprecated:
229
 
230
 
236
 * ``Strategy.select_variant_stockrecords`` - Use
237
 * ``Strategy.select_variant_stockrecords`` - Use
237
   ``select_children_stockrecords`` instead.
238
   ``select_children_stockrecords`` instead.
238
 
239
 
240
+Furthermore, CSS classes and template blocks have been updated. Please follow
241
+the following renaming pattern:
242
+* ``variant-product`` becomes ``child-product``
243
+* ``product_variants`` becomes ``child_products``
244
+* ``variants`` becomes ``children``
245
+* ``variant`` becomes ``child``
246
+
239
 Shipping
247
 Shipping
240
 ~~~~~~~~
248
 ~~~~~~~~
241
 
249
 

+ 30
- 13
oscar/apps/catalogue/abstract_models.py View File

418
         return ", ".join(pairs)
418
         return ", ".join(pairs)
419
 
419
 
420
     @property
420
     @property
421
-    def min_variant_price_incl_tax(self):
421
+    def min_child_price_incl_tax(self):
422
         """
422
         """
423
-        Return minimum variant price including tax
423
+        Return minimum child product price including tax
424
         """
424
         """
425
-        return self._min_variant_price('price_incl_tax')
425
+        return self._min_child_price('price_incl_tax')
426
 
426
 
427
     @property
427
     @property
428
-    def min_variant_price_excl_tax(self):
428
+    def min_child_price_excl_tax(self):
429
         """
429
         """
430
-        Return minimum variant price excluding tax
430
+        Return minimum child product price excluding tax
431
         """
431
         """
432
-        return self._min_variant_price('price_excl_tax')
432
+        return self._min_child_price('price_excl_tax')
433
 
433
 
434
-    def _min_variant_price(self, property):
434
+    def _min_child_price(self, property):
435
         """
435
         """
436
-        Return minimum variant price
436
+        Return minimum child product price
437
         """
437
         """
438
         prices = []
438
         prices = []
439
-        for variant in self.variants.all():
440
-            if variant.has_stockrecords:
441
-                prices.append(getattr(variant.stockrecord, property))
439
+        for child in self.children.all():
440
+            if child.has_stockrecords:
441
+                prices.append(getattr(child.stockrecord, property))
442
         if not prices:
442
         if not prices:
443
             return None
443
             return None
444
         prices.sort()
444
         prices.sort()
445
         return prices[0]
445
         return prices[0]
446
 
446
 
447
-    # Deprecated properties
447
+    # The properties below are based on deprecated naming conventions
448
 
448
 
449
     @property
449
     @property
450
     @deprecated
450
     @deprecated
466
     @deprecated
466
     @deprecated
467
     def is_group(self):
467
     def is_group(self):
468
         """
468
         """
469
-        Test if this is a top level product and has more than 0 variants
469
+        Test if this is a parent product
470
         """
470
         """
471
         return self.is_parent
471
         return self.is_parent
472
 
472
 
473
     @property
473
     @property
474
+    @deprecated
474
     def is_variant(self):
475
     def is_variant(self):
475
         """Return True if a product is not a top level product"""
476
         """Return True if a product is not a top level product"""
476
         return self.is_child
477
         return self.is_child
477
 
478
 
479
+    @property
480
+    @deprecated
481
+    def min_variant_price_incl_tax(self):
482
+        """
483
+        Return minimum variant price including tax
484
+        """
485
+        return self._min_child_price('price_incl_tax')
486
+
487
+    @property
488
+    @deprecated
489
+    def min_variant_price_excl_tax(self):
490
+        """
491
+        Return minimum variant price excluding tax
492
+        """
493
+        return self._min_child_price('price_excl_tax')
494
+
478
     # Wrappers
495
     # Wrappers
479
 
496
 
480
     def get_title(self):
497
     def get_title(self):

+ 1
- 1
oscar/apps/partner/importers.py View File

184
 
184
 
185
         if is_child:
185
         if is_child:
186
             product.structure = Product.CHILD
186
             product.structure = Product.CHILD
187
-            # Assign parent for variants
187
+            # Assign parent for children
188
             product.parent = self.parent
188
             product.parent = self.parent
189
         elif is_parent:
189
         elif is_parent:
190
             product.structure = Product.PARENT
190
             product.structure = Product.PARENT

+ 1
- 1
oscar/static/oscar/css/responsive.css View File

1080
     padding-right: 10px;
1080
     padding-right: 10px;
1081
   }
1081
   }
1082
 }
1082
 }
1083
-@media (min-width: 767px + 1) {
1083
+@media (min-width: 768px) {
1084
   .nav-collapse.collapse {
1084
   .nav-collapse.collapse {
1085
     height: auto !important;
1085
     height: auto !important;
1086
     overflow: visible !important;
1086
     overflow: visible !important;

+ 3
- 3
oscar/templates/oscar/dashboard/catalogue/product_delete.html View File

47
         {% endblocktrans %}
47
         {% endblocktrans %}
48
 
48
 
49
         {% if product.is_parent %}
49
         {% if product.is_parent %}
50
-            <p> {% trans "This will also delete the following variant products:" %}
50
+            <p> {% trans "This will also delete the following child products:" %}
51
                 <ul>
51
                 <ul>
52
-                    {% for variant in product.children.all %}
53
-                        <li><strong>{{ variant.title }}</strong></li>
52
+                    {% for child in product.children.all %}
53
+                        <li><strong>{{ child.title }}</strong></li>
54
                     {% endfor %}
54
                     {% endfor %}
55
                 </ul>
55
                 </ul>
56
             </p>
56
             </p>

+ 12
- 12
oscar/templates/oscar/dashboard/catalogue/product_update.html View File

46
                             <li{% if not product %} class="active"{% endif %}><a href="#product_details" data-toggle="tab">{% trans 'Product details' %}</a></li>
46
                             <li{% if not product %} class="active"{% endif %}><a href="#product_details" data-toggle="tab">{% trans 'Product details' %}</a></li>
47
                             <li><a href="#product_recommended" data-toggle="tab">{% trans 'Recommended Products' %}</a></li>
47
                             <li><a href="#product_recommended" data-toggle="tab">{% trans 'Recommended Products' %}</a></li>
48
                             {% if product.children.exists %}
48
                             {% if product.children.exists %}
49
-                                <li><a href="#product_variants" data-toggle="tab">{% trans 'Product variants' %}</a></li>
49
+                                <li><a href="#child_products" data-toggle="tab">{% trans 'Child products' %}</a></li>
50
                             {% endif %}
50
                             {% endif %}
51
                             <li><a href="#product_attributes" data-toggle="tab">{% trans 'Product attributes' %}</a></li>
51
                             <li><a href="#product_attributes" data-toggle="tab">{% trans 'Product attributes' %}</a></li>
52
                             <li><a href="#product_category" data-toggle="tab">{% trans 'Product category' %}</a></li>
52
                             <li><a href="#product_category" data-toggle="tab">{% trans 'Product category' %}</a></li>
177
                         </div>
177
                         </div>
178
                     {% endblock product_details %}
178
                     {% endblock product_details %}
179
 
179
 
180
-                    {% block product_variants %}
181
-                        {% with variants=product.children.all %}
182
-                            {% if variants %}
183
-                                <div class="tab-pane" id="product_variants">
184
-                                    {% block product_variants_content %}
180
+                    {% block child_products %}
181
+                        {% with children=product.children.all %}
182
+                            {% if children %}
183
+                                <div class="tab-pane" id="child_products">
184
+                                    {% block child_products_content %}
185
                                         <table class='table table-striped table-bordered'>
185
                                         <table class='table table-striped table-bordered'>
186
                                             <caption>{% trans "Variants" %}</caption>
186
                                             <caption>{% trans "Variants" %}</caption>
187
                                             {% with parent=product.parent %}
187
                                             {% with parent=product.parent %}
200
                                                 <th colspan="3">{% trans "Children" %}</th>
200
                                                 <th colspan="3">{% trans "Children" %}</th>
201
                                             </tr>
201
                                             </tr>
202
 
202
 
203
-                                            {% for variant in variants %}
203
+                                            {% for child in children %}
204
                                                 <tr>
204
                                                 <tr>
205
-                                                    <td>{{ variant.get_title }}</td>
206
-                                                    <td>{{ variant.attribute_summary }}</td>
207
-                                                    <td><a href="{% url 'dashboard:catalogue-product' pk=variant.id %}" class="btn btn-primary">{% trans "Edit" %}</a></td>
205
+                                                    <td>{{ child.get_title }}</td>
206
+                                                    <td>{{ child.attribute_summary }}</td>
207
+                                                    <td><a href="{% url 'dashboard:catalogue-product' pk=child.id %}" class="btn btn-primary">{% trans "Edit" %}</a></td>
208
                                                 </tr>
208
                                                 </tr>
209
                                             {% endfor %}
209
                                             {% endfor %}
210
                                         </table>
210
                                         </table>
211
-                                    {% endblock product_variants_content %}
211
+                                    {% endblock child_products_content %}
212
                                 </div>
212
                                 </div>
213
                             {% endif %}
213
                             {% endif %}
214
                         {% endwith %}
214
                         {% endwith %}
215
-                    {% endblock product_variants %}
215
+                    {% endblock child_products %}
216
 
216
 
217
                     {% block product_attributes %}
217
                     {% block product_attributes %}
218
                         <div class="tab-pane" id="product_attributes">
218
                         <div class="tab-pane" id="product_attributes">

+ 12
- 12
sites/demo/static/demo/css/styles.css View File

5226
   color: #97a5a3;
5226
   color: #97a5a3;
5227
   font-size: 1.1428571428571428em;
5227
   font-size: 1.1428571428571428em;
5228
 }
5228
 }
5229
-.variant-product {
5229
+.child-product {
5230
   *zoom: 1;
5230
   *zoom: 1;
5231
 }
5231
 }
5232
-.variant-product:before,
5233
-.variant-product:after {
5232
+.child-product:before,
5233
+.child-product:after {
5234
   display: table;
5234
   display: table;
5235
   content: "";
5235
   content: "";
5236
   line-height: 0;
5236
   line-height: 0;
5237
 }
5237
 }
5238
-.variant-product:after {
5238
+.child-product:after {
5239
   clear: both;
5239
   clear: both;
5240
 }
5240
 }
5241
-.variant-product h4 {
5241
+.child-product h4 {
5242
   color: #024872;
5242
   color: #024872;
5243
 }
5243
 }
5244
-.variant-product p,
5245
-.variant-product h4 {
5244
+.child-product p,
5245
+.child-product h4 {
5246
   margin-bottom: 15px;
5246
   margin-bottom: 15px;
5247
 }
5247
 }
5248
-.variant-product .price_color {
5248
+.child-product .price_color {
5249
   font-size: 1.7142857142857142em;
5249
   font-size: 1.7142857142857142em;
5250
 }
5250
 }
5251
-.variant-product .image_container {
5251
+.child-product .image_container {
5252
   background: #ffffff;
5252
   background: #ffffff;
5253
   line-height: 80px;
5253
   line-height: 80px;
5254
   min-height: 80px;
5254
   min-height: 80px;
5256
   border: 1px solid #ddd;
5256
   border: 1px solid #ddd;
5257
   float: left;
5257
   float: left;
5258
 }
5258
 }
5259
-.variant-product .image_container img {
5259
+.child-product .image_container img {
5260
   max-height: 70px;
5260
   max-height: 70px;
5261
   max-width: 98%;
5261
   max-width: 98%;
5262
 }
5262
 }
5263
-.variant-product > div:first-child + div {
5263
+.child-product > div:first-child + div {
5264
   margin-left: 100px;
5264
   margin-left: 100px;
5265
 }
5265
 }
5266
-.variant-form label {
5266
+.child-form label {
5267
   display: block;
5267
   display: block;
5268
 }
5268
 }
5269
 .form-notify .btn {
5269
 .form-notify .btn {

+ 1
- 1
sites/demo/static/demo/less/page/product_lists.less View File

1
 // Price Color
1
 // Price Color
2
-//Price (i = variant)
2
+//Price (i = child product)
3
 .price_color {
3
 .price_color {
4
   display:block;
4
   display:block;
5
   color:@green;
5
   color:@green;

+ 3
- 3
sites/demo/static/demo/less/page/product_page.less View File

91
     font-size: @headingFourSize;
91
     font-size: @headingFourSize;
92
   }
92
   }
93
 }
93
 }
94
-//Variant lists
95
-.variant-product {
94
+//Child product lists
95
+.child-product {
96
   .clearfix();
96
   .clearfix();
97
   h4 {
97
   h4 {
98
     color:@blueDark;
98
     color:@blueDark;
119
     margin-left:100px;
119
     margin-left:100px;
120
   }
120
   }
121
 }
121
 }
122
-.variant-form {
122
+.child-form {
123
   label {
123
   label {
124
     display:block;
124
     display:block;
125
   }
125
   }

+ 13
- 13
sites/demo/templates/catalogue/detail.html View File

68
             {% if product.is_group %}
68
             {% if product.is_group %}
69
                 <h3>{% trans "Please select your varieties" %}</h3>
69
                 <h3>{% trans "Please select your varieties" %}</h3>
70
                 
70
                 
71
-                {% with variants=product.children.all %}
72
-                    {% if variants|length > 0 %}
71
+                {% with children=product.children.all %}
72
+                    {% if children|length > 0 %}
73
                           
73
                           
74
-                            {% for variant in variants %}
75
-                            <div class="variant-product well">
74
+                            {% for child in children %}
75
+                            <div class="child-product well">
76
 
76
 
77
-                                {% with image=variant.primary_image %}
77
+                                {% with image=child.primary_image %}
78
                                 {% thumbnail image.original "70x70" upscale=False as thumb %}
78
                                 {% thumbnail image.original "70x70" upscale=False as thumb %}
79
                                 <div class="image_container">
79
                                 <div class="image_container">
80
-                                    <img src="{{ thumb.url }}" alt="{{ variant.get_title }}" data-description="{% if image.caption %}{{ image.caption }}{% endif %}">
80
+                                    <img src="{{ thumb.url }}" alt="{{ child.get_title }}" data-description="{% if image.caption %}{{ image.caption }}{% endif %}">
81
                                 </div>
81
                                 </div>
82
                                 {% endthumbnail %}
82
                                 {% endthumbnail %}
83
                                 {% endwith %}
83
                                 {% endwith %}
84
 
84
 
85
                                 <div>
85
                                 <div>
86
-                                    <h4>{{ variant.title }}</h4>
86
+                                    <h4>{{ child.title }}</h4>
87
 
87
 
88
-                                    {% include "catalogue/partials/variant_stock_record.html" with class="span5" product=variant %}
88
+                                    {% include "catalogue/partials/child_stock_record.html" with class="span5" product=child %}
89
                                     
89
                                     
90
-                                    <div class="variant-form">
91
-                                        {% if variant.is_available_to_buy %}
92
-                                        {% basket_form request variant as basket_form %}
90
+                                    <div class="child-form">
91
+                                        {% if child.is_available_to_buy %}
92
+                                        {% basket_form request child as basket_form %}
93
                                         <form action="{% url 'basket:add' %}" method="post" class="form-inline">
93
                                         <form action="{% url 'basket:add' %}" method="post" class="form-inline">
94
                                             {% csrf_token %}
94
                                             {% csrf_token %}
95
                                             {% include "partials/form_fields_inline.html" with form=basket_form %}
95
                                             {% include "partials/form_fields_inline.html" with form=basket_form %}
97
                                         </form>
97
                                         </form>
98
                                         <span itemprop="availability" content="in_stock"></span>
98
                                         <span itemprop="availability" content="in_stock"></span>
99
                                         {% else %}
99
                                         {% else %}
100
-                                        <p class="variant-notice">{% trans "You can get an email alert when this product is back in stock." %}</p>
101
-                                        {% include "catalogue/partials/alerts_form.html" with product=variant %}
100
+                                        <p>{% trans "You can get an email alert when this product is back in stock." %}</p>
101
+                                        {% include "catalogue/partials/alerts_form.html" with product=child %}
102
                                         {% endif %}
102
                                         {% endif %}
103
                                     </div>
103
                                     </div>
104
                                 </div>
104
                                 </div>

+ 1
- 1
sites/demo/templates/catalogue/partials/stock_record.html View File

5
 {% purchase_info_for_product request product as session %}
5
 {% purchase_info_for_product request product as session %}
6
 
6
 
7
 {% if product.is_group %}
7
 {% if product.is_group %}
8
-    <span>{% blocktrans with product.min_variant_price_incl_tax|currency as price %} <i>From</i> {{ price }}{% endblocktrans %}</span>
8
+    <span>{% blocktrans with product.min_child_price_incl_tax|currency as price %} <i>From</i> {{ price }}{% endblocktrans %}</span>
9
 {% else %}
9
 {% else %}
10
     <span>{% if session.price.retail > session.price.incl_tax %}<del>{{ session.price.retail|currency }}</del>{% endif %} {{ session.price.incl_tax|currency }}</span>
10
     <span>{% if session.price.retail > session.price.incl_tax %}<del>{{ session.price.retail|currency }}</del>{% endif %} {{ session.price.incl_tax|currency }}</span>
11
 {% endif %}
11
 {% endif %}

sites/sandbox/fixtures/variants.json → sites/sandbox/fixtures/child_products.json View File


+ 1
- 1
tests/integration/catalogue/product_tests.py View File

87
         Product.objects.create(
87
         Product.objects.create(
88
             parent=self.parent, structure=Product.CHILD)
88
             parent=self.parent, structure=Product.CHILD)
89
 
89
 
90
-    def test_variant_products_inherit_parent_titles(self):
90
+    def test_child_products_inherit_parent_titles(self):
91
         p = Product.objects.create(
91
         p = Product.objects.create(
92
             parent=self.parent, product_class=self.product_class,
92
             parent=self.parent, product_class=self.product_class,
93
             structure=Product.CHILD)
93
             structure=Product.CHILD)

Loading…
Cancel
Save