Replace CsvUnicodeWriter with Python 3 compatible UnicodeCSVWriter
This required extending the UnicodeCSVWriter to be able to deal with
file-like objects as well. This is used to create downloadable CSV files
in memory.
Factory Boy for test fixtures & port address model tests
As previously discussed here
https://groups.google.com/d/topic/django-oscar/Owmi3J1rwlk/discussion
I have started working on the introduction of Factoryboy library into
django-oscar, to make the generation of data for unit tests easier. At
the moment I have only refactored test/unit/address/models_tests.py, but
the plan is to refactor all the existing tests. All the tests, of
course, pass.
Squashed commit of the work done in #1192
Fixes #1192
Update tests for new fields and correct timezone handling
Using timezone.now() will return naive datetimes if USE_TZ is not
enabled, which is what we want.
Resolves errors of comparing naive datetimes with aware datetimes.
Fix to allow users to specify which cards they accept.
By default, this works exactly as it did- i.e., any number
can be entered and only a luhn check is run on it.
Users can now overide this behaviour by passing a list of
accepted cards as a 'types'kwarg to BankcardNumberField,
e.g.
BankcardNumberField(types=[bankcards.VISA, bankcards.VISA_ELECTRON,])
If this is specified, we check that the type of card is one we're
aware of and then that the card number matches the pattern for that
type of card
Fixes #949@maikhoepfel rewrote the ImproperlyConfigured check using Python's sets.
Conflicts:
oscar/apps/payment/forms.py
Previously, the test suite ran with a custom user model for Django >=
1.5, but it didn't subclass Oscar's AbstractUser. This commit adjusts
the custom user model to subclass Oscar's so we can test functionality
within the custom user class.
This does require a change to the way tests authenticate as we don't
actually use the username field.
Call signal receivers from models.py (not __init__.py)
This reverts fa1f8403 which moved them from models.py to __init__.py.
As reported by @mvantellingen, importing receivers from __init__.py
breaks the way models are normally overridden as it causes the core
models.py to get imported before the custom one.
We need to move back to the old system and will need to advise that the
debug toolbar needs to be set-up explicitly to avoid circular import
issues with models.
Fixes #1159
Original issue #1125
Rather than forcing text, it's better to raise an error when a uggettext
proxy is used for the range name as this won't save correctly in the
database.
Related to #1053
Stop using home-rolled encryption for basket cookies
For anon users, the basket ID is stored in a cookie. Previously, this
was stored with a simple crc32 hash to prevent users enumerating baskets
by changing their cookies. However, home-rolled encryption is always a
bad idea. In this case, it may have probably exposed too much
information allowing the SECRET_KEY to be determined.
This change switches away from the home-rolled encryption to use
Django's built-in crypto signing functionality to store the basket ID.
Thanks to Raphael Kimmig for reporting this issue and providing this
patch.
I've had an issue with orders that contain only items that don't require
shipping. In this case, the shipping address could be ``None`` which
breaks the ``create_shipping_address`` method.
I've added a test case for it and provided a simple fix. I wasn't quit
sure if the check should be in ``create_shipping_address`` or in
``place_order`` and only call it for an address that is not ``None``.
I've decided to go with the first because it is also simpler to test
this in isolation but am not fussed about moving it up.
Fixes #956
Fixes #910
This involves some quite involved changes to the internals of how offers
and organised. A new boolean field has been added to the offer model to
indicate whether to apply to prices exclusive of tax. This is used
within the offer methods to determine whether a basket meets a
condition, and how to apply the benefit if it does.
Fixes #925
Fixes #924
Prior to this change, it was possible to select child products in the
product dashboard. A new function get_parent_products_queryset was
introduced, analogues to the existing get_related_products_queryset. It
is not based on the BrowsableManager as I can envision scenarios where
that is extended to respect status fields or such like, which we should
ignore when selecting a parent field. Otherwise it wouldn't be possible
to e.g. add a few hidden products with child products.
Two issues in tests with the G library were fixed as well, were
unintentionally child products were created. If the product field is
left unspecified, it seems to pick a product instead of leaving it as
None.
To support multi-currency sites. This commit also made the order totals
a mandatory input for creating an order, which meant quite a few tests
had to change to support the new API.