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,7 +15,7 @@ sandbox: install
15 15
 	sites/sandbox/manage.py syncdb --noinput
16 16
 	sites/sandbox/manage.py migrate
17 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 19
 	sites/sandbox/manage.py oscar_import_catalogue sites/sandbox/fixtures/*.csv
20 20
 	sites/sandbox/manage.py oscar_import_catalogue_images sites/sandbox/fixtures/images.tar.gz
21 21
 	sites/sandbox/manage.py oscar_populate_countries

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

@@ -214,7 +214,7 @@ Backwards incompatible changes in 0.8
214 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 218
 unavoidable:
219 219
 
220 220
 * You now need to explicitly set product structure when creating a product;
@@ -224,6 +224,7 @@ unavoidable:
224 224
   deprecation warning), but if you used the old related name in a query lookup
225 225
   (e.g. ``products.filter(variants__title='foo')``, you will have to change it
226 226
   to ``children``.
227
+* Template blocks and CSS classes have been renamed.
227 228
 
228 229
 The following methods and properties have been deprecated:
229 230
 
@@ -236,6 +237,13 @@ The following methods and properties have been deprecated:
236 237
 * ``Strategy.select_variant_stockrecords`` - Use
237 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 247
 Shipping
240 248
 ~~~~~~~~
241 249
 

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

@@ -418,33 +418,33 @@ class AbstractProduct(models.Model):
418 418
         return ", ".join(pairs)
419 419
 
420 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 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 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 442
         if not prices:
443 443
             return None
444 444
         prices.sort()
445 445
         return prices[0]
446 446
 
447
-    # Deprecated properties
447
+    # The properties below are based on deprecated naming conventions
448 448
 
449 449
     @property
450 450
     @deprecated
@@ -466,15 +466,32 @@ class AbstractProduct(models.Model):
466 466
     @deprecated
467 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 471
         return self.is_parent
472 472
 
473 473
     @property
474
+    @deprecated
474 475
     def is_variant(self):
475 476
         """Return True if a product is not a top level product"""
476 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 495
     # Wrappers
479 496
 
480 497
     def get_title(self):

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

@@ -184,7 +184,7 @@ class DemoSiteImporter(object):
184 184
 
185 185
         if is_child:
186 186
             product.structure = Product.CHILD
187
-            # Assign parent for variants
187
+            # Assign parent for children
188 188
             product.parent = self.parent
189 189
         elif is_parent:
190 190
             product.structure = Product.PARENT

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

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

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

@@ -47,10 +47,10 @@
47 47
         {% endblocktrans %}
48 48
 
49 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 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 54
                     {% endfor %}
55 55
                 </ul>
56 56
             </p>

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

@@ -46,7 +46,7 @@
46 46
                             <li{% if not product %} class="active"{% endif %}><a href="#product_details" data-toggle="tab">{% trans 'Product details' %}</a></li>
47 47
                             <li><a href="#product_recommended" data-toggle="tab">{% trans 'Recommended Products' %}</a></li>
48 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 50
                             {% endif %}
51 51
                             <li><a href="#product_attributes" data-toggle="tab">{% trans 'Product attributes' %}</a></li>
52 52
                             <li><a href="#product_category" data-toggle="tab">{% trans 'Product category' %}</a></li>
@@ -177,11 +177,11 @@
177 177
                         </div>
178 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 185
                                         <table class='table table-striped table-bordered'>
186 186
                                             <caption>{% trans "Variants" %}</caption>
187 187
                                             {% with parent=product.parent %}
@@ -200,19 +200,19 @@
200 200
                                                 <th colspan="3">{% trans "Children" %}</th>
201 201
                                             </tr>
202 202
 
203
-                                            {% for variant in variants %}
203
+                                            {% for child in children %}
204 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 208
                                                 </tr>
209 209
                                             {% endfor %}
210 210
                                         </table>
211
-                                    {% endblock product_variants_content %}
211
+                                    {% endblock child_products_content %}
212 212
                                 </div>
213 213
                             {% endif %}
214 214
                         {% endwith %}
215
-                    {% endblock product_variants %}
215
+                    {% endblock child_products %}
216 216
 
217 217
                     {% block product_attributes %}
218 218
                         <div class="tab-pane" id="product_attributes">

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

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

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

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

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

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

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

@@ -68,28 +68,28 @@
68 68
             {% if product.is_group %}
69 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 78
                                 {% thumbnail image.original "70x70" upscale=False as thumb %}
79 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 81
                                 </div>
82 82
                                 {% endthumbnail %}
83 83
                                 {% endwith %}
84 84
 
85 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 93
                                         <form action="{% url 'basket:add' %}" method="post" class="form-inline">
94 94
                                             {% csrf_token %}
95 95
                                             {% include "partials/form_fields_inline.html" with form=basket_form %}
@@ -97,8 +97,8 @@
97 97
                                         </form>
98 98
                                         <span itemprop="availability" content="in_stock"></span>
99 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 102
                                         {% endif %}
103 103
                                     </div>
104 104
                                 </div>

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

@@ -5,7 +5,7 @@
5 5
 {% purchase_info_for_product request product as session %}
6 6
 
7 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 9
 {% else %}
10 10
     <span>{% if session.price.retail > session.price.incl_tax %}<del>{{ session.price.retail|currency }}</del>{% endif %} {{ session.price.incl_tax|currency }}</span>
11 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,7 +87,7 @@ class VariantProductTests(ProductTests):
87 87
         Product.objects.create(
88 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 91
         p = Product.objects.create(
92 92
             parent=self.parent, product_class=self.product_class,
93 93
             structure=Product.CHILD)

Loading…
Cancel
Save