Skip to content

Commit

Permalink
Properly serialise phone number when storing in session
Browse files Browse the repository at this point in the history
Previously, we just used force_text() to serialise it.
That is the wrong approach, as we allow changing the standard
display to a regional format. But in the session we should always
include the country code. Luckily the easy fix is to just store things
as an international phone number.
  • Loading branch information
maiksprenger committed Jan 30, 2015
1 parent a0ce8f2 commit 1b1b82b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/oscar/apps/checkout/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def ship_to_new_address(self, address_fields):
self._unset('shipping', 'new_address_fields')
phone_number = address_fields.get('phone_number')
if phone_number:
# Phone number is stored as a PhoneNumber instance. As we store
# strings in the session, we need to serialize it.
address_fields = address_fields.copy()
address_fields['phone_number'] = force_text(
address_fields['phone_number'])
address_fields['phone_number'] = phone_number.as_international
self._set('shipping', 'new_address_fields', address_fields)

def new_shipping_address_fields(self):
Expand Down

0 comments on commit 1b1b82b

Please sign in to comment.