Add setting to allow SlugField and AutoSlugField accept unicode and automatically generate unicode-containing slugs.
Since there is no way to override SlugField and AutoSlugField in existing Oscar models, it was decided to pass `allow_unicode` parameter if this setting enable. This allows to achieve backwards compatibility with Django versions under 1.9, when this parameter was not supported yet. If parameter specified in the field expliticly - we do not override it, which allow to control slug fields individually in a normal way. For the reasons, explained above, standard SlugField was replaced with a custom one with the single slight change - control over `allow_unicode` parameter by the mentioned setting.
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.
Fix errors with shipping discounts on free weightbased shipping.
The Repository.apply_shipping_offer() method returns the shipping method
object when there is no additional discount for an order. This however
broke with the WeightBased, because it's implementation does not work.
self.offer is never assigned, nor useful (a copy-paste error?).
Instead, it should work like the non-model `methods.Base` that also
states the method does not have a default shipping discount.
Weigh the basket using decimals, avoid float rounding issues
While the backend stores the information as floats, the calculations
don't have to do be affected by this. For example:
0.3 + 0.3 + 0.3 == 0.8999999999
Using decimals improves the calculation, and avoid falling into the
wrong weight band.
- Set Meta.app_label on models created in the tests
- Use logging.NullHandler instead of django.utils.log.NullHandler
- Use oscar.core.loading.get_model() instead of django's get_model
- Remove template tags '{% load url from future %}'
Trigger product unavailable warning message using availability policy rather than reproducing the stockrecord check, to allow for greater extensibility.
Replace assert statements with appropriate assert* method.
Replace 'assert' with 'assert*' method.
Convert tests.unit.forms.widget_tests to use TestCase class.
Convert bankcard tests to use TestCase.
Convert tests.unit.logging_tests to use TestCase.
The offer tests contained a stray test case that I suppose was once
intended as a base class for all the other tests. But it's only used
twice, and for very little gain, so let's delete it.
Fix ValueError in tests when assigning unsaved instance
Django now throws a ValueError when an unsaved instance is assigned:
https://docs.djangoproject.com/en/1.8/releases/1.8/#assigning-unsaved-objects-to-relations-raises-an-error
This commit changes the offending lines to create objects in the
database instead. But I don't understand why I don't need to make
the same changes for e.g. the country factory.
But I don't really care, as long as the tests pass. I'm guessing it has
something to do with factory-boy and the get_or_create statement.
Unfortunately, this will make our test suite slower. But to make up for
it, Django 1.8 introduces the setUpTestCase method, which we can use
once Django 1.7 is removed.
Refactor the shipping_status method to return a consistent last
complete status. Since dictionaries have no guaranteed order, and also
since the shipping status queryset isn’t ordered the method didn’t
always return the actual last complete status.
Conflicts:
oscar/test/newfactories.py
tests/integration/order/model_tests.py
Backported by @maikhoepfel from #1672.
Refactor the shipping_status method to return a consistent last
complete status. Since dictionaries have no guaranteed order, and also
since the shipping status queryset isn’t ordered the method didn’t
always return the actual last complete status.