|
|
@@ -7,6 +7,7 @@ from django.utils.translation import ugettext as _
|
|
7
|
7
|
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
|
8
|
8
|
|
|
9
|
9
|
from oscar.apps.basket.managers import OpenBasketManager, SavedBasketManager
|
|
|
10
|
+from oscar.templatetags.currency_filters import currency
|
|
10
|
11
|
|
|
11
|
12
|
# Basket statuses
|
|
12
|
13
|
# - Frozen is for when a basket is in the process of being submitted
|
|
|
@@ -84,7 +85,7 @@ class AbstractBasket(models.Model):
|
|
84
|
85
|
if not self.id:
|
|
85
|
86
|
self.save()
|
|
86
|
87
|
|
|
87
|
|
- # Line refernene is used to distinguish between variations of the same
|
|
|
88
|
+ # Line reference is used to distinguish between variations of the same
|
|
88
|
89
|
# product (eg T-shirts with different personalisations)
|
|
89
|
90
|
line_ref = self._create_line_reference(product, options)
|
|
90
|
91
|
|
|
|
@@ -513,6 +514,28 @@ class AbstractLine(models.Model):
|
|
513
|
514
|
d = "%s (%s)" % (d.decode('utf-8'), ", ".join(ops))
|
|
514
|
515
|
return d
|
|
515
|
516
|
|
|
|
517
|
+ def get_warning(self):
|
|
|
518
|
+ """
|
|
|
519
|
+ Return a warning message about this basket line if one is applicable
|
|
|
520
|
+
|
|
|
521
|
+ This could be things like the price has changed
|
|
|
522
|
+ """
|
|
|
523
|
+ if not self.price_incl_tax:
|
|
|
524
|
+ return
|
|
|
525
|
+ current_price_incl_tax = self.product.stockrecord.price_incl_tax
|
|
|
526
|
+ if current_price_incl_tax > self.price_incl_tax:
|
|
|
527
|
+ msg = u"The price of '%(product)s' has increased from %(old_price)s " \
|
|
|
528
|
+ u"to %(new_price)s since you added it to your basket"
|
|
|
529
|
+ return _(msg % {'product': self.product.get_title(),
|
|
|
530
|
+ 'old_price': currency(self.price_incl_tax),
|
|
|
531
|
+ 'new_price': currency(current_price_incl_tax)})
|
|
|
532
|
+ if current_price_incl_tax < self.price_incl_tax:
|
|
|
533
|
+ msg = u"The price of '%(product)s' has decreased from %(old_price)s " \
|
|
|
534
|
+ u"to %(new_price)s since you added it to your basket"
|
|
|
535
|
+ return _(msg % {'product': self.product.get_title(),
|
|
|
536
|
+ 'old_price': currency(self.price_incl_tax),
|
|
|
537
|
+ 'new_price': currency(current_price_incl_tax)})
|
|
|
538
|
+
|
|
516
|
539
|
|
|
517
|
540
|
class AbstractLineAttribute(models.Model):
|
|
518
|
541
|
"""An attribute of a basket line"""
|