Prevent trying to save a negative quantity to a Basket
basket.Line.quantity is a positive integer field, but the quantity sumation in
basket.Basket.add_product made it possible to try and save negative values. This
makes add_product never go below 0-quantity, thereby preventing a db exception
from being thrown. Also adds a test for the described behavior.
Trigger product unavailable warning message using availability policy rather than reproducing the stockrecord check, to allow for greater extensibility.
The word "stock info" was bugging me as it's not quite correct for the
combination of availability and price information. The problem is the
word "stock" which implies physical widgets in a warehouse somewhere.
It sounds weird for ask for stock info for a digital product.
Hence, I came up with PurchaseInfo, which is a bit more vague but
captures the information better.
We no longer need to pass the StockInfo instance as the basket has a
reference to the strategy class and can fetch it for itself. This means
we don't have to break backwards compatibility with Oscar < 0.6.