Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change sort_by params where they are referring to other models
michald059fb0ccff1
diff --git a/saleor/dashboard/customer/filters.py b/saleor/dashboard/customer/filters.pyindex f6d8df0eff..eb5d403d7a 100644--- a/saleor/dashboard/customer/filters.py+++ b/saleor/dashboard/customer/filters.py@@ -6,7 +6,16 @@ from django.utils.translation import pgettext_lazyfrom ...userprofile.models import User-SORT_BY_FIELDS = {+SORT_BY_FIELDS = (+ ('email', 'email'),+ ('default_billing_address__first_name', 'name'),+ ('default_billing_address__city', 'location'),+ ('num_orders', 'num_orders'),+ ('last_order', 'last_order')+)+++SORT_BY_FIELDS_LABELS = {'email': pgettext_lazy('Customer list sorting option', 'email'),'default_billing_address__first_name': pgettext_lazy(@@ -22,8 +31,8 @@ SORT_BY_FIELDS = {class CustomerFilter(FilterSet):sort_by = OrderingFilter(label=pgettext_lazy('Customer list sorting form', 'Sort by'),- fields=SORT_BY_FIELDS.keys(),- field_labels=SORT_BY_FIELDS)+ fields=SORT_BY_FIELDS,+ field_labels=SORT_BY_FIELDS_LABELS)name = CharFilter(label=pgettext_lazy('Customer list sorting filter', 'Name'),name='default_billing_address__first_name')diff --git a/saleor/dashboard/discount/filters.py b/saleor/dashboard/discount/filters.pyindex c7b4bb5cf8..f7a50a2537 100644--- a/saleor/dashboard/discount/filters.py+++ b/saleor/dashboard/discount/filters.py@@ -10,7 +10,7 @@ SORT_BY_FIELDS_SALE = {'name': pgettext_lazy('Sale list sorting option', 'name'),'value': pgettext_lazy('Sale list sorting option', 'value')}-SORT_BY_FIELDS_VOUCHER = {+SORT_BY_FIELDS_LABELS_VOUCHER = {'name': pgettext_lazy('Voucher list sorting option', 'name'),'discount_value': pgettext_lazy('Voucher list sorting option', 'discount_value'),@@ -35,8 +35,8 @@ class SaleFilter(FilterSet):class VoucherFilter(FilterSet):sort_by = OrderingFilter(label=pgettext_lazy('Voucher list sorting filter', 'Sort by'),- fields=SORT_BY_FIELDS_VOUCHER.keys(),- field_labels=SORT_BY_FIELDS_VOUCHER)+ fields=SORT_BY_FIELDS_LABELS_VOUCHER.keys(),+ field_labels=SORT_BY_FIELDS_LABELS_VOUCHER)limit = RangeFilter(label=pgettext_lazy('Voucher list sorting filter', 'Limit'),name='limit')diff --git a/saleor/dashboard/order/filters.py b/saleor/dashboard/order/filters.pyindex e3bac3e2c2..fc7d566263 100644--- a/saleor/dashboard/order/filters.py+++ b/saleor/dashboard/order/filters.py@@ -9,7 +9,16 @@ from payments import PaymentStatusfrom ...order.models import Order-SORT_BY_FIELDS = {+SORT_BY_FIELDS = (+ ('pk', 'pk'),+ ('status', 'status'),+ ('payments__status', 'payment_status'),+ ('user__email', 'email'),+ ('created', 'created'),+ ('total_net', 'total')+)++SORT_BY_FIELDS_LABELS = {'pk': pgettext_lazy('Order list sorting option', '#'),'status': pgettext_lazy('Order list sorting option', 'status'),'payments__status': pgettext_lazy('Order list sorting option', 'payment'),@@ -21,8 +30,8 @@ SORT_BY_FIELDS = {class OrderFilter(FilterSet):sort_by = OrderingFilter(label=pgettext_lazy('Order list sorting filter', 'Sort by'),- fields=SORT_BY_FIELDS.keys(),- field_labels=SORT_BY_FIELDS)+ fields=SORT_BY_FIELDS,+ field_labels=SORT_BY_FIELDS_LABELS)payment_status = ChoiceFilter(label=pgettext_lazy('Order list sorting filter', 'Payment status'),name='payments__status', choices=PaymentStatus.CHOICES)diff --git a/saleor/dashboard/staff/filters.py b/saleor/dashboard/staff/filters.pyindex 95b8a674fd..e0fff2e402 100644--- a/saleor/dashboard/staff/filters.py+++ b/saleor/dashboard/staff/filters.py@@ -7,7 +7,14 @@ from django_prices.models import PriceFieldfrom ...userprofile.models import User-SORT_BY_FIELDS = {+SORT_BY_FIELDS = (+ ('email', 'email'),+ ('default_billing_address__first_name', 'name'),+ ('default_billing_address__city', 'location')+)+++SORT_BY_FIELDS_LABELS = {'email': pgettext_lazy('Customer list sorting option', 'email'),'default_billing_address__first_name': pgettext_lazy(@@ -19,8 +26,8 @@ SORT_BY_FIELDS = {class StaffFilter(FilterSet):sort_by = OrderingFilter(label=pgettext_lazy('Staff list sorting filter', 'Sort by'),- fields=SORT_BY_FIELDS.keys(),- field_labels=SORT_BY_FIELDS)+ fields=SORT_BY_FIELDS,+ field_labels=SORT_BY_FIELDS_LABELS)name = CharFilter(label=pgettext_lazy('Staff list sorting filter', 'Name'),name='default_billing_address__first_name')diff --git a/templates/dashboard/customer/list.html b/templates/dashboard/customer/list.htmlindex c03be064df..0163b8ae23 100644--- a/templates/dashboard/customer/list.html+++ b/templates/dashboard/customer/list.html@@ -35,12 +35,12 @@</a></th><th class="wide">- <a href="{% get_sort_by_url_toggle 'default_billing_address__first_name' %}">+ <a href="{% get_sort_by_url_toggle 'name' %}">{% trans "Name" context "Customers table header" %}</a></th><th>- <a href="{% get_sort_by_url_toggle 'default_billing_address__city' %}">+ <a href="{% get_sort_by_url_toggle 'location' %}">{% trans "Location" context "Customers table header" %}</a></th>diff --git a/templates/dashboard/includes/_orders_table.html b/templates/dashboard/includes/_orders_table.htmlindex c260f28637..29679e91c1 100644--- a/templates/dashboard/includes/_orders_table.html+++ b/templates/dashboard/includes/_orders_table.html@@ -18,12 +18,12 @@</a></th><th>- <a href="{% get_sort_by_url_toggle 'payments__status' %}">+ <a href="{% get_sort_by_url_toggle 'payment_status' %}">{% trans "Payment status" context "Orders table header" %}</a></th><th>- <a href="{% get_sort_by_url_toggle 'user__email' %}">+ <a href="{% get_sort_by_url_toggle 'email' %}">{% trans "Customer" context "Orders table header" %}</a></th>@@ -33,7 +33,7 @@</a></th><th class="right-align">- <a href="{% get_sort_by_url_toggle 'total_net' %}">+ <a href="{% get_sort_by_url_toggle 'total' %}">{% trans "Total" context "Orders table header" %}</a></th>diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.htmlindex b67bc0acd4..f39693d709 100644--- a/templates/dashboard/staff/list.html+++ b/templates/dashboard/staff/list.html@@ -48,12 +48,12 @@</a></th><th class="wide">- <a href="{% get_sort_by_url_toggle 'default_billing_address__first_name' %}">+ <a href="{% get_sort_by_url_toggle 'name' %}">{% trans "Name" context "Staff members table header" %}</a></th><th>- <a href="{% get_sort_by_url_toggle 'default_billing_address__city' %}">+ <a href="{% get_sort_by_url_toggle 'location' %}">{% trans "Location" context "Staff members table header" %}</a></th>