Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: django-oscar/django-oscar
...
head fork: django-oscar/django-oscar
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 09, 2012
David Winterbottom codeinthehole Fixed bug with saving multiple images for a product.
Needed to pass a custom class for inferring the display order from the
form prefix.
8eb6968
David Winterbottom codeinthehole Added new blocks to thank-you template 0e1b685
1  oscar/apps/catalogue/abstract_models.py
View
@@ -1,4 +1,3 @@
-import re
from itertools import chain
from datetime import datetime, date
22 oscar/apps/dashboard/catalogue/forms.py
View
@@ -135,5 +135,25 @@ class StockAlertSearchForm(forms.Form):
ProductCategoryFormSet = inlineformset_factory(Product, ProductCategory,
fields=('category',), extra=1)
+class ProductImageForm(forms.ModelForm):
+ class Meta:
+ model = ProductImage
+ exclude = ('display_order',)
+
+ def save(self, *args, **kwargs):
+ # We infer the display order of the image based on the order of the image fields
+ # within the formset.
+ kwargs['commit'] = False
+ obj = super(ProductImageForm, self).save(*args, **kwargs)
+ obj.display_order = self.get_display_order()
+ obj.save()
+ return obj
+
+ def get_display_order(self):
+ return self.prefix.split('-').pop()
+
+
+
ProductImageFormSet = inlineformset_factory(Product, ProductImage,
- fields=('original', 'caption'), extra=2)
+ form=ProductImageForm,
+ extra=2)
2  oscar/apps/dashboard/catalogue/views.py
View
@@ -190,7 +190,7 @@ def form_valid(self, form):
self.request.FILES,
instance=self.object)
if stockrecord_form.is_valid() and category_formset.is_valid() and image_formset.is_valid():
- product = form.save()
+ form.save()
stockrecord_form.save()
category_formset.save()
image_formset.save()
6 oscar/templates/checkout/thank_you.html
View
@@ -18,6 +18,7 @@
<div class="row-fluid">
<div class="span6">
+ {% block shipping_info %}
<div class="well well-info">
<h3>Shipping</h3>
<p>Your order will be delivered to:</p>
@@ -25,14 +26,17 @@
{{ line }}<br/>
{% endfor %}
</div>
+ {% endblock %}
</div>
<div class="span6">
+ {% block payment_info %}
<div class="well well-success">
<h3>Payment</h3>
{% for source in order.sources.all %}
{{ source }}
{% endfor %}
</div>
+ {% endblock %}
</div>
</div>
<div class="sub-header">
@@ -66,6 +70,7 @@ <h4 class="span1">Cost</h4>
</div>
</div>
{% endfor %}
+
{% for discount in order.discounts.all %}
<div class="basket-items">
<div class="row-fluid">
@@ -74,6 +79,7 @@ <h4 class="span11">{{ discount.offer }}</h4>
</div>
</div>
{% endfor %}
+
<div class="basket-items">
<div class="row-fluid">
<h4 class="span11">Basket total</h4>

No commit comments for this range

Something went wrong with that request. Please try again.