Skip to content

Commit

Permalink
Prevent user selecting a non-shipping country as default shipping add…
Browse files Browse the repository at this point in the history
…ress

Hides the 'make default shipping address' button if the address country is non-shipping
Shows flash error message if it does come through (belt and braces)
  • Loading branch information
danyilmaz committed Dec 20, 2013
1 parent 2acc1b5 commit edeb9bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions oscar/apps/customer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,7 @@ def get(self, request, pk=None, action=None, *args, **kwargs):
elif action == 'default_for_billing':
setattr(address, 'is_default_for_billing', True)
else:
(args.context['shipping_address_error'] =
'We do not ship to this country')
messages.error(request, 'We do not ship to this country')
address.save()
return super(AddressChangeStatusView, self).get(
request, *args, **kwargs)
5 changes: 2 additions & 3 deletions oscar/templates/oscar/customer/address/address_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
{% if address.is_default_for_billing %}
<span class="label label-info">{% trans 'Default billing address' %}</span>
{% endif %}
{% if shipping_address_error %}
<span class="label label-warning">{{ shipping_address_error }}</span>
{% endif %}
<address>
{% for field in address.active_address_fields %}
{{ field }}</br>
Expand All @@ -43,11 +40,13 @@
</li>

{% if not address.is_default_for_shipping %}
{% if address.country.is_shipping_country %}
<li>
<a href="{% url 'customer:address-change-status' pk=address.id action='default_for_shipping' %}">
{% trans 'Set as default shipping address' %}
</a>
</li>
{% endif %}
{% endif %}
{% if not address.is_default_for_billing %}
<li>
Expand Down

0 comments on commit edeb9bf

Please sign in to comment.