Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add shipping zones on the dashboard
Pacu2cd2809c93541
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex 8e8bd8a842..b222ead548 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -516,17 +516,17 @@ def create_shipping_methods():#FIXME we should make sure that no country will be placed in two ShippingZonesfor i in range(4):- shipping_zone.shipping_methods.add(- ShippingRate.objects.create(- name=fake.company(),- price=fake.money()))+ ShippingRate.objects.create(+ shipping_zone=shipping_zone,+ name=fake.company(),+ price=fake.money())shipping_zone = ShippingZone.objects.create(name='European countries', countries=django_countries[1::2])for i in range(4):- shipping_zone.shipping_methods.add(- ShippingRate.objects.create(- name=fake.company(),- price=fake.money()))+ ShippingRate.objects.create(+ shipping_zone=shipping_zone,+ name=fake.company(),+ price=fake.money())shipping_method = ShippingMethod.objects.create(name='UPC')shipping_method.price_per_country.create(price=fake.money())yield 'Shipping method #%d' % shipping_method.iddiff --git a/saleor/dashboard/shipping/filters.py b/saleor/dashboard/shipping/filters.pyindex 04c26d7dfc..c5ec577449 100644--- a/saleor/dashboard/shipping/filters.py+++ b/saleor/dashboard/shipping/filters.py@@ -4,24 +4,24 @@ from django_filters import (from ...core.filters import SortedFilterSetfrom ...core.i18n import COUNTRY_CODE_CHOICES-from ...shipping.models import ShippingMethod+from ...shipping.models import ShippingZoneSORT_BY_FIELDS = {'name': pgettext_lazy('Group list sorting option', 'name')}-class ShippingMethodFilter(SortedFilterSet):+class ShippingZoneFilter(SortedFilterSet):name = CharFilter(label=pgettext_lazy(- 'Shipping method list filter label', 'Name'),+ 'Shipping zones list filter label', 'Zone name'),lookup_expr="icontains")price = RangeFilter(label=pgettext_lazy(- 'Shipping method list filter label', 'Price range'),- name='price_per_country__price')+ 'Shipping zones list filter label', 'Price range'),+ name='shipping_methods__price')country = ChoiceFilter(- label=pgettext_lazy('Shipping method filter label', 'Country'),- name='price_per_country__country_code',+ label=pgettext_lazy('Shipping zones filter label', 'Country'),+ name='countries', lookup_expr='contains',choices=COUNTRY_CODE_CHOICES)sort_by = OrderingFilter(label=pgettext_lazy('Product list sorting filter label', 'Sort by'),@@ -29,7 +29,7 @@ class ShippingMethodFilter(SortedFilterSet):field_labels=SORT_BY_FIELDS)class Meta:- model = ShippingMethod+ model = ShippingZonefields = []def get_summary_message(self):diff --git a/saleor/dashboard/shipping/forms.py b/saleor/dashboard/shipping/forms.pyindex efd0848b67..31df137c28 100644--- a/saleor/dashboard/shipping/forms.py+++ b/saleor/dashboard/shipping/forms.py@@ -1,29 +1,69 @@from django import formsfrom django.utils.translation import pgettext_lazy-from ...shipping.models import ShippingMethod, ShippingMethodCountry+from ...shipping.models import ShippingMethod, ShippingZone, ShippingRate, ShippingMethodCountry+from django_countries.widgets import LazySelectMultiple+from saleor.account.i18n import COUNTRY_CHOICES-class ShippingMethodForm(forms.ModelForm):+def currently_used_countries(shipping_zone_pk=None):+ shipping_zones = ShippingZone.objects.exclude(pk=shipping_zone_pk)+ used_countries = {+ (country.code, country.name)+ for shipping_zone in shipping_zones+ for country in shipping_zone.countries}+ return used_countries+++class ShippingZoneForm(forms.ModelForm):class Meta:- model = ShippingMethod- exclude = []+ model = ShippingZone+ exclude = ['shipping_methods']labels = {'name': pgettext_lazy(- 'Item name', 'Name'),- 'description': pgettext_lazy(- 'Description', 'Description')}+ 'Shippment Zone field name', 'Zone Name'),+ 'countries': pgettext_lazy(+ 'List of countries to pick from', 'Countries')}+ help_texts = {+ 'countries': pgettext_lazy(+ 'Countries field help text',+ 'Each country might be included in only one shipping zone.'),+ 'name': pgettext_lazy(+ 'Help text for ShippingZone name',+ 'Name is for internal use only, it won\'t '+ 'be displayed to your customers')}+ def __init__(self, *args, **kwargs):+ super().__init__(*args, **kwargs)+ self.fields['countries'].choices = (+ set(self.fields['countries'].choices) - currently_used_countries(+ self.instance.pk if self.instance else None))-class ShippingMethodCountryForm(forms.ModelForm):+ def clean_countries(self):+ countries = self.cleaned_data.get('countries')+ if not countries:+ return+ duplicated_countries = set(countries).intersection(+ currently_used_countries())+ if duplicated_countries:+ self.add_error(+ 'countries',+ 'Countries already exists in another '+ 'shipping zone: %(list_of_countries)s' % {+ 'list_of_countries': ''.join(duplicated_countries)})+ return countries+++class ShippingRateForm(forms.ModelForm):class Meta:- model = ShippingMethodCountry- exclude = []- widgets = {'shipping_method': forms.widgets.HiddenInput()}+ model = ShippingRate+ exclude = ['shipping_zone']labels = {- 'country_code': pgettext_lazy(- 'List of countries', 'Country'),+ 'name': pgettext_lazy(+ 'Shipping Rate name', 'Name'),+ 'type': pgettext_lazy(+ 'Shipping Rate type', 'Type'),'price': pgettext_lazy('Currency amount', 'Price')}diff --git a/saleor/dashboard/shipping/urls.py b/saleor/dashboard/shipping/urls.pyindex eaf898bdad..c69ff1f245 100644--- a/saleor/dashboard/shipping/urls.py+++ b/saleor/dashboard/shipping/urls.py@@ -12,13 +12,9 @@ urlpatterns = [url(r'^(?P<pk>\d+)/delete/$',views.shipping_method_delete, name='shipping-method-delete'),- url(r'^(?P<shipping_method_pk>\d+)/country/add/$',- views.shipping_method_country_add,- name='shipping-method-country-add'),- url(r'^(?P<shipping_method_pk>\d+)/country/(?P<country_pk>\d+)/update/$',- views.shipping_method_country_edit,- name='shipping-method-country-edit'),- url(r'^(?P<shipping_method_pk>\d+)/country/(?P<country_pk>\d+)/delete/$',- views.shipping_method_country_delete,- name='shipping-method-country-delete'),-]+ url(r'^(?P<shipping_method_pk>\d+)/rate/add/$',+ views.shipping_rate_add, name='shipping-rate-add'),+ url(r'^(?P<shipping_method_pk>\d+)/rate/(?P<rate_pk>\d+)/update/$',+ views.shipping_rate_edit, name='shipping-rate-edit'),+ url(r'^(?P<shipping_method_pk>\d+)/rate/(?P<rate_pk>\d+)/delete/$',+ views.shipping_rate_delete, name='shipping-rate-delete')]diff --git a/saleor/dashboard/shipping/views.py b/saleor/dashboard/shipping/views.pyindex 8d61f1b46e..412252ca3d 100644--- a/saleor/dashboard/shipping/views.py+++ b/saleor/dashboard/shipping/views.py@@ -6,24 +6,24 @@ from django.template.response import TemplateResponsefrom django.utils.translation import pgettext_lazyfrom ...core.utils import get_paginator_items-from ...shipping.models import ShippingMethod, ShippingMethodCountry+from ...shipping.models import ShippingRate, ShippingZonefrom ..views import staff_member_required-from .filters import ShippingMethodFilter-from .forms import ShippingMethodCountryForm, ShippingMethodForm+from .filters import ShippingZoneFilter+from .forms import ShippingRateForm, ShippingZoneForm@staff_member_required@permission_required('shipping.manage_shipping')def shipping_method_list(request):- methods = ShippingMethod.objects.prefetch_related(- 'price_per_country').order_by('name')- shipping_method_filter = ShippingMethodFilter(- request.GET, queryset=methods)- methods = get_paginator_items(- shipping_method_filter.qs, settings.DASHBOARD_PAGINATE_BY,+ zones = ShippingZone.objects.prefetch_related(+ 'shipping_methods').order_by('name')+ shipping_method_filter = ShippingZoneFilter(+ request.GET, queryset=zones)+ zones = get_paginator_items(+ shipping_method_filter.qs.distinct(), settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))ctx = {- 'shipping_methods': methods, 'filter_set': shipping_method_filter,+ 'shipping_zones': zones, 'filter_set': shipping_method_filter,'is_empty': not shipping_method_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/shipping/list.html', ctx)@@ -31,13 +31,13 @@ def shipping_method_list(request):@staff_member_required@permission_required('shipping.manage_shipping')def shipping_method_add(request):- method = ShippingMethod()- form = ShippingMethodForm(request.POST or None, instance=method)+ zone = ShippingZone()+ form = ShippingZoneForm(request.POST or None, instance=zone)if form.is_valid():- method = form.save()- msg = pgettext_lazy('Dashboard message', 'Added shipping method')+ zone = form.save()+ msg = pgettext_lazy('Dashboard message', 'Added shipping zone')messages.success(request, msg)- return redirect('dashboard:shipping-method-details', pk=method.pk)+ return redirect('dashboard:shipping-method-details', pk=zone.pk)ctx = {'form': form, 'shipping_method': form.instance}return TemplateResponse(request, 'dashboard/shipping/form.html', ctx)@@ -45,25 +45,23 @@ def shipping_method_add(request):@staff_member_required@permission_required('shipping.manage_shipping')def shipping_method_edit(request, pk):- method = get_object_or_404(ShippingMethod, pk=pk)- form = ShippingMethodForm(request.POST or None, instance=method)+ zone = get_object_or_404(ShippingZone, pk=pk)+ form = ShippingZoneForm(request.POST or None, instance=zone)if form.is_valid():- method = form.save()- msg = pgettext_lazy('Dashboard message', 'Updated shipping method')+ zone = form.save()+ msg = pgettext_lazy('Dashboard message', 'Updated shipping zone')messages.success(request, msg)- return redirect('dashboard:shipping-method-details', pk=method.pk)- ctx = {'form': form, 'shipping_method': method}+ return redirect('dashboard:shipping-method-details', pk=zone.pk)+ ctx = {'form': form, 'shipping_method': zone}return TemplateResponse(request, 'dashboard/shipping/form.html', ctx)@staff_member_required@permission_required('shipping.manage_shipping')def shipping_method_details(request, pk):- shipping_methods = ShippingMethod.objects.prefetch_related(- 'price_per_country').all()- method = get_object_or_404(shipping_methods, pk=pk)- method_countries = method.price_per_country.all()- ctx = {'shipping_method': method, 'method_countries': method_countries}+ zone = get_object_or_404(ShippingZone, pk=pk)+ shipping_rates = zone.shipping_methods.all()+ ctx = {'shipping_method': zone, 'shipping_rates': shipping_rates}return TemplateResponse(request, 'dashboard/shipping/detail.html', ctx)@@ -71,45 +69,48 @@ def shipping_method_details(request, pk):@staff_member_required@permission_required('shipping.manage_shipping')def shipping_method_delete(request, pk):- shipping_method = get_object_or_404(ShippingMethod, pk=pk)+ shipping_zone = get_object_or_404(ShippingZone, pk=pk)if request.method == 'POST':- shipping_method.delete()+ shipping_zone.delete()msg = pgettext_lazy('Dashboard message',- '%(shipping_method_name)s successfully removed') % {- 'shipping_method_name': shipping_method}+ '%(shipping_zone_name)s successfully removed') % {+ 'shipping_zone_name': shipping_zone}messages.success(request, msg)return redirect('dashboard:shipping-methods')- ctx = {'shipping_method': shipping_method}+ ctx = {'shipping_zone': shipping_zone}return TemplateResponse(request, 'dashboard/shipping/modal/confirm_delete.html', ctx)@staff_member_required@permission_required('shipping.manage_shipping')-def shipping_method_country_add(request, shipping_method_pk):- shipping_method = get_object_or_404(ShippingMethod, pk=shipping_method_pk)- country = ShippingMethodCountry(shipping_method_id=shipping_method_pk)- form = ShippingMethodCountryForm(request.POST or None, instance=country)+def shipping_rate_add(request, shipping_method_pk):+ shipping_zone = get_object_or_404(ShippingZone, pk=shipping_method_pk)+ shipping_rate = ShippingRate(shipping_zone_id=shipping_method_pk)+ form = ShippingRateForm(request.POST or None, instance=shipping_rate)if form.is_valid():- country = form.save()+ shipping_rate = form.save()msg = pgettext_lazy(- 'Dashboard message', 'Added shipping price for %s') % (country,)+ 'Dashboard message', 'Added shipping price for %s'+ ) % (shipping_rate,)messages.success(request, msg)return redirect('dashboard:shipping-method-details', pk=shipping_method_pk)ctx = {- 'form': form, 'shipping_method': shipping_method, 'country': country}+ 'form': form, 'shipping_method': shipping_zone,+ 'shipping_rate': shipping_rate}return TemplateResponse(- request, 'dashboard/shipping/country/form.html', ctx)+ request, 'dashboard/shipping/rate/form.html', ctx)@staff_member_required@permission_required('shipping.manage_shipping')-def shipping_method_country_edit(request, shipping_method_pk, country_pk):- shipping_method = get_object_or_404(ShippingMethod, pk=shipping_method_pk)- country = get_object_or_404(ShippingMethodCountry, pk=country_pk)- form = ShippingMethodCountryForm(request.POST or None, instance=country)+def shipping_rate_edit(request, shipping_method_pk, rate_pk):+ shipping_zone = get_object_or_404(ShippingZone, pk=shipping_method_pk)+ shipping_rate = get_object_or_404(ShippingRate, pk=rate_pk)++ form = ShippingRateForm(request.POST or None, instance=shipping_rate)if form.is_valid():country = form.save()msg = pgettext_lazy(@@ -119,23 +120,27 @@ def shipping_method_country_edit(request, shipping_method_pk, country_pk):return redirect('dashboard:shipping-method-details', pk=shipping_method_pk)ctx = {- 'form': form, 'shipping_method': shipping_method, 'country': country}+ 'form': form, 'shipping_method': shipping_zone,+ 'shipping_rate': shipping_rate}return TemplateResponse(- request, 'dashboard/shipping/country/form.html', ctx)+ request, 'dashboard/shipping/rate/form.html', ctx)@staff_member_required@permission_required('shipping.manage_shipping')-def shipping_method_country_delete(- request, shipping_method_pk, country_pk=None):- country = get_object_or_404(ShippingMethodCountry, pk=country_pk)+def shipping_rate_delete(+ request, shipping_method_pk, rate_pk=None):+ shipping_rate = get_object_or_404(ShippingRate, pk=rate_pk)if request.method == 'POST':- country.delete()+ shipping_rate.delete()msg = pgettext_lazy(- 'Dashboard message', 'Removed shipping method %s') % (country,)+ 'Dashboard message', 'Removed shipping method %s') % (+ shipping_rate,)messages.success(request, msg)return redirect('dashboard:shipping-method-details', pk=shipping_method_pk)- ctx = {'country': country, 'shipping_method_pk': shipping_method_pk}+ ctx = {+ 'shipping_rate': shipping_rate,+ 'shipping_method_pk': shipping_method_pk}return TemplateResponse(- request, 'dashboard/shipping/modal/country_confirm_delete.html', ctx)+ request, 'dashboard/shipping/modal/rate_confirm_delete.html', ctx)diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex c2259d1d95..688228875d 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -16,6 +16,36 @@ from ..core.utils import format_moneyfrom ..shipping.utils import get_taxed_shipping_price+class ShippingZone(models.Model):+ name = models.CharField(max_length=100)+ countries = CountryField(multiple=True)++ def __str__(self):+ return self.name++ def get_countries_display(self):+ if len(self.countries) <= 3:+ return ','.join((name for code, name in self.countries))+ return pgettext_lazy(+ 'Number of countries shipping zone apply to',+ '%(num_of_countries)d countries' % {+ 'num_of_countries': len(self.countries)})++ @property+ def price_range(self):+ prices = [+ shipping_method.get_total_price()+ for shipping_method in self.shipping_methods.all()]+ if prices:+ return MoneyRange(min(prices).net, max(prices).net)+ return None++ class Meta:+ permissions = ((+ 'manage_shipping', pgettext_lazy(+ 'Permission description', 'Manage shipping.')),)++class ShippingRate(models.Model):name = models.CharField(max_length=100)type = models.CharField(@@ -24,6 +54,9 @@ class ShippingRate(models.Model):price = MoneyField(currency=settings.DEFAULT_CURRENCY, max_digits=12,decimal_places=settings.DEFAULT_DECIMAL_PLACES, default=0)+ shipping_zone = models.ForeignKey(+ ShippingZone, related_name='shipping_methods',+ on_delete=models.CASCADE)def __str__(self):return self.name@@ -32,20 +65,6 @@ class ShippingRate(models.Model):return get_taxed_shipping_price(self.price, taxes)-class ShippingZone(models.Model):- name = models.CharField(max_length=100)- countries = CountryField(multiple=True)- shipping_methods = models.ManyToManyField(- ShippingRate, blank=True, related_name='shipping_zone')-- def __str__(self):- return self.name-- class Meta:- permissions = ((- 'manage_shipping', pgettext_lazy(- 'Permission description', 'Manage shipping.')),)-class ShippingMethod(models.Model):diff --git a/templates/dashboard/shipping/detail.html b/templates/dashboard/shipping/detail.htmlindex 473d7789c8..e0d88cb06d 100644--- a/templates/dashboard/shipping/detail.html+++ b/templates/dashboard/shipping/detail.html@@ -38,20 +38,10 @@<div class="card"><div class="card-content"><span class="card-title">- {{ shipping_method.name }}+ {% blocktrans with shipping_name=shipping_method.name list_of_countries=shipping_method.get_countries_display %}+ {{ shipping_name }} <small>(ships to {{ list_of_countries }})</small>+ {% endblocktrans %}</span>- <div class="row">- {% if shipping_method.description %}- <div class="col s12 m4 l12">- <h4>- {% trans "Description" context "Shipping method field" %}- </h4>- <p>- {{ shipping_method.description }}- </p>- </div>- {% endif %}- </div></div><div class="card-action"><a class="btn-flat waves-effect" href="{% url 'dashboard:shipping-method-update' shipping_method.pk %}">@@ -68,11 +58,11 @@<div class="card"><div class="card-content"><span class="card-title">- {% trans "Price per country" context "Title of the per-country shipping price list" %}+ {% trans "Shipping rates" context "Title of the per-country shipping price list" %}</span></div><div class="data-table-header-action">- <a href="{% url 'dashboard:shipping-method-country-add' shipping_method_pk=shipping_method.pk %}" class="btn-data-table btn-flat waves-effect">+ <a href="{% url 'dashboard:shipping-rate-add' shipping_method_pk=shipping_method.pk %}" class="btn-data-table btn-flat waves-effect">{% trans "Add" %}</a></div>@@ -81,7 +71,7 @@<thead><tr><th>- {% trans "Country" context "Header of the per-country shipping price list" %}+ {% trans "Name" context "Header of the per-country shipping price list" %}</th><th>{% trans "Price" context "Header of the per-country shipping price list" %}@@ -89,15 +79,15 @@</tr></thead><tbody>- {% for country in method_countries %}+ {% for country in shipping_rates %}<tr>- <td>{{ country.get_country_code_display }}</td>+ <td>{{ country.name }}</td><td>{% price country.price %}</td><td class="right-align">- <a href="{% url 'dashboard:shipping-method-country-edit' shipping_method_pk=shipping_method.pk country_pk=country.pk %}" class="btn-flat waves-effect">+ <a href="{% url 'dashboard:shipping-rate-edit' shipping_method_pk=shipping_method.pk rate_pk=country.pk %}" class="btn-flat waves-effect">{% trans 'Edit' context 'Attribute choice value edit action' %}</a>- <a class="btn-flat waves-effect modal-trigger-custom" href="#base-modal" data-href="{% url 'dashboard:shipping-method-country-delete' shipping_method_pk=shipping_method.pk country_pk=country.pk %}">+ <a class="btn-flat waves-effect modal-trigger-custom" href="#base-modal" data-href="{% url 'dashboard:shipping-rate-delete' shipping_method_pk=shipping_method.pk rate_pk=country.pk %}">{% trans 'Remove' context 'Attribute choice value remove action' %}</a></td>diff --git a/templates/dashboard/shipping/list.html b/templates/dashboard/shipping/list.htmlindex 6eb84e0168..5a739f1180 100644--- a/templates/dashboard/shipping/list.html+++ b/templates/dashboard/shipping/list.html@@ -32,13 +32,13 @@{% block content %}<div class="row"><div class="col s12 l9">- {% if shipping_methods %}+ {% if shipping_zones %}<div class="card"><div class="data-table-container"><table class="bordered highlight responsive data-table"><thead><tr>- {% trans "Name" context "Shipping methods table header" as label %}+ {% trans "Zone name" context "Shipping methods table header" as label %}{% sorting_header 'name' label is_wide=True %}<th>@@ -50,7 +50,7 @@</tr></thead><tbody>- {% for method in shipping_methods %}+ {% for method in shipping_zones %}<tr data-action-go="{% url 'dashboard:shipping-method-details' pk=method.pk %}"><td>{{ method }}@@ -63,7 +63,7 @@{% endif %}</td><td>- {{ method.countries|join:", " }}+ {{ method.get_countries_display }}</td></tr>{% endfor %}@@ -71,7 +71,7 @@</table></div></div>- {% paginate shipping_methods %}+ {% paginate shipping_zones %}{% else %}{% if is_empty %}{% include 'dashboard/shipping/zero_page.html' %}diff --git a/templates/dashboard/shipping/modal/confirm_delete.html b/templates/dashboard/shipping/modal/confirm_delete.htmlindex e73c8e1d4e..ab9bb859ee 100644--- a/templates/dashboard/shipping/modal/confirm_delete.html+++ b/templates/dashboard/shipping/modal/confirm_delete.html@@ -6,19 +6,19 @@{% block form_class %}{% endblock %}{% block action_url %}-{% url "dashboard:shipping-method-delete" shipping_method.pk %}+{% url "dashboard:shipping-method-delete" shipping_zone.pk %}{% endblock %}{% block title %}{% blocktrans context "Dashboard confirmation modal" %}-Remove shipping method {{ shipping_method }}+Remove shipping zone {{ shipping_zone }}{% endblocktrans %}{% endblock %}{% block content %}<div class="col s12">{% blocktrans context "Dashboard confirmation modal" %}- Are you sure you want to remove shipping method <strong>{{ shipping_method}}</strong>?+ Are you sure you want to remove shipping method <strong>{{ shipping_zone}}</strong>?{% endblocktrans %}</div>{% endblock %}diff --git a/templates/dashboard/shipping/modal/country_confirm_delete.html b/templates/dashboard/shipping/modal/rate_confirm_delete.htmlsimilarity index 57%rename from templates/dashboard/shipping/modal/country_confirm_delete.htmlrename to templates/dashboard/shipping/modal/rate_confirm_delete.htmlindex 46032e5ef7..08f57a57ae 100644--- a/templates/dashboard/shipping/modal/country_confirm_delete.html+++ b/templates/dashboard/shipping/modal/rate_confirm_delete.html@@ -5,19 +5,19 @@{% block form_class %}{% endblock %}{% block action_url %}-{% url "dashboard:shipping-method-country-delete" shipping_method_pk=shipping_method_pk country_pk=country.pk %}+{% url "dashboard:shipping-rate-delete" shipping_method_pk=shipping_method_pk rate_pk=shipping_rate.pk %}{% endblock %}{% block title %}-{% blocktrans trimmed context "Modal remove shipping method country title" %}- Remove shipping {{ country }}+{% blocktrans trimmed context "Modal remove shipping method shippingrate title" %}+ Remove shipping {{ shipping_rate }}{% endblocktrans %}{% endblock title %}{% block content %}<div class="col s12">- {% blocktrans trimmed context "Modal remove shipping method country text" %}- Are you sure you want to remove shipping <strong>{{ country }}</strong>?+ {% blocktrans trimmed context "Modal remove shipping method shipping rate text" %}+ Are you sure you want to remove shipping rate <strong>{{ shipping_rate }}</strong>?{% endblocktrans %}</div>{% endblock content %}diff --git a/templates/dashboard/shipping/country/form.html b/templates/dashboard/shipping/rate/form.htmlsimilarity index 97%rename from templates/dashboard/shipping/country/form.htmlrename to templates/dashboard/shipping/rate/form.htmlindex 96f43ac02e..60e6e88ab0 100644--- a/templates/dashboard/shipping/country/form.html+++ b/templates/dashboard/shipping/rate/form.html@@ -43,7 +43,7 @@</a></li>{% endif %}- {% if country.pk %}+ {% if shipping_zone.pk %}<li><span class="breadcrumbs--ellipsed-item">{% trans "Edit" context "Attribute detail breadcrumbs" %}@@ -79,7 +79,7 @@<a href="{% url 'dashboard:shipping-method-details' pk=shipping_method.pk %}" class="btn-flat waves-effect">{% trans "Cancel" context "Dashboard cancel action" %}</a>- {% if country.pk %}+ {% if shipping_rate.pk %}<button type="submit" class="btn waves-effect">{% trans "Save" context "Dashboard update action" %}</button>diff --git a/tests/dashboard/test_shipping.py b/tests/dashboard/test_shipping.pyindex e0db33a0a2..faf2d2eb8f 100644--- a/tests/dashboard/test_shipping.py+++ b/tests/dashboard/test_shipping.py@@ -56,9 +56,9 @@ def test_shipping_method_delete(admin_client, shipping_method):assert ShippingMethod.objects.count() == 0-def test_shipping_method_country_add(admin_client, shipping_method):+def test_shipping_rate_add(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 1- url = reverse('dashboard:shipping-method-country-add',+ url = reverse('dashboard:shipping-rate-add',kwargs={'shipping_method_pk': shipping_method.pk})data = {'country_code': 'FR', 'price': '50','shipping_method': shipping_method.pk}@@ -67,9 +67,9 @@ def test_shipping_method_country_add(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 2-def test_shipping_method_country_add_not_valid(admin_client, shipping_method):+def test_shipping_rate_add_not_valid(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 1- url = reverse('dashboard:shipping-method-country-add',+ url = reverse('dashboard:shipping-rate-add',kwargs={'shipping_method_pk': shipping_method.pk})data = {}response = admin_client.post(url, data, follow=True)@@ -77,13 +77,13 @@ def test_shipping_method_country_add_not_valid(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 1-def test_shipping_method_country_edit(admin_client, shipping_method):+def test_shipping_rate_edit(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 1country = shipping_method.price_per_country.all()[0]assert country.price == Money(10, 'USD')- url = reverse('dashboard:shipping-method-country-edit',+ url = reverse('dashboard:shipping-rate-edit',kwargs={'shipping_method_pk': shipping_method.pk,- 'country_pk': country.pk})+ 'rate_pk': country.pk})data = {'country_code': '', 'price': '50','shipping_method': shipping_method.pk}response = admin_client.post(url, data, follow=True)@@ -94,12 +94,12 @@ def test_shipping_method_country_edit(admin_client, shipping_method):assert shipping_price == Money(50, 'USD')-def test_shipping_method_country_delete(admin_client, shipping_method):+def test_shipping_rate_delete(admin_client, shipping_method):assert ShippingMethodCountry.objects.count() == 1country = shipping_method.price_per_country.all()[0]- url = reverse('dashboard:shipping-method-country-delete',+ url = reverse('dashboard:shipping-rate-delete',kwargs={'shipping_method_pk': shipping_method.pk,- 'country_pk': country.pk})+ 'rate_pk': country.pk})response = admin_client.post(url, follow=True)assert response.status_code == 200assert ShippingMethodCountry.objects.count() == 0