This change adds a uniqueness constraint on user addresses to prevent
duplicates. A few changes follow:
- The user address forms in account and checkout are modified to take a
user as a constructor arg so uniqueness can be checked.
- The assignment of a user when creating a new address has been moved
into the form.
It's possible that a user could select an address to ship to but then
delete it before checkout is complete. This change raises an
UnableToPlaceOrder exception in such circumstances.
Fix variable name mismatch in "Basket total now" message
The message context includes the variable include_buttons, but the
template checks for presence of show_buttons. This led to the buttons
never being displayed.
- Expand width of address block
- Wrap edit user address form in "well"
- Add extra blocks to preview template, splitting out shipping address,
contact number, notes and method.
Prevent checkout as guest/new user if email address exists
Before, it was possible to enter an existing email address and continue
the checkout process as a guest, which is a bug. It was also possible to
select to create a new user, but the then-displayed form would disallow
creating a new user with that email address.
All code handling email addresses has been update to use a new function
normalise_email, to have one consistent way of handling email addresses.
This function lowercases the domain part of an email address if it can
find an @, so it works on partial addresses as well.
The assumption is that most customers will not have an account (unlike
Amazon, eBay etc.), hence the default is to create an account.
The wording has been changed to hopefully be more approachable.
Fix bug when parent field is excluded from ProductForm
A check in ProductForm's __init__ caused an error when the parent field
is not present. It is reasonable to believe that this field would be
omitted for deployments that sell only canonical products. Hence, the
existence of the field is checked before altering it.