Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Unify customers and staff tables

Marcin Gębala4c4d943ac71a
diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.py
index 81460af7af..d4d5093289 100644
--- a/saleor/dashboard/customer/views.py
+++ b/saleor/dashboard/customer/views.py
@@ -21,9 +21,6 @@ def customer_list(request):
User.objects
.prefetch_related('orders', 'addresses')
.select_related('default_billing_address', 'default_shipping_address')
- .annotate(
- num_orders=Count('orders', distinct=True),
- last_order=Max('orders', distinct=True))
.order_by('email'))
customer_filter = UserFilter(request.GET, queryset=customers)
customers = get_paginator_items(
diff --git a/templates/dashboard/customer/list.html b/templates/dashboard/customer/list.html
index 602b7a1c7d..a0fc3df0c3 100644
--- a/templates/dashboard/customer/list.html
+++ b/templates/dashboard/customer/list.html
@@ -31,21 +31,21 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Customers table header" %}
</a>
</th>
{% get_sort_by_toggle 'email' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Email" context "Customers table header" %}
</a>
</th>
{% get_sort_by_toggle 'location' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Location" context "Customers table header" %}
diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.html
index 0ea3c94cfb..ded1c7c5b6 100644
--- a/templates/dashboard/staff/list.html
+++ b/templates/dashboard/staff/list.html
@@ -43,22 +43,22 @@
<table class="bordered highlight responsive data-table">
<thead>
<tr>
- {% get_sort_by_toggle 'email' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ {% get_sort_by_toggle 'name' as toggle %}
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
- {% trans "Email" context "Staff members table header" %}
+ {% trans "Name" context "Staff members table header" %}
</a>
</th>
- {% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ {% get_sort_by_toggle 'email' as toggle %}
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
- {% trans "Name" context "Staff members table header" %}
+ {% trans "Email" context "Staff members table header" %}
</a>
</th>
{% get_sort_by_toggle 'location' as toggle %}
- <th class="wide {% if toggle.is_active %}active{% endif %}">
+ <th class="{% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
<svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Location" context "Staff members table header" %}
@@ -70,19 +70,23 @@
{% for user in staff %}
<tr data-action-go="{% url "dashboard:staff-details" pk=user.pk %}">
{% with user.default_billing_address as default_address %}
+ <td>
+ {% if default_address %}
+ {{ default_address.first_name }} {{ default_address.last_name }}
+ {% else %}
+ -
+ {% endif %}
+ </td>
<td>
{{ user.email }}
</td>
- {% if default_address %}
- <td>
- {{ default_address.first_name }} {{ default_address.last_name }}
- </td>
- <td>
+ <td>
+ {% if default_address %}
{{ default_address.city }}, {{ default_address.get_country_display }}
- </td>
- {% else %}
- <td colspan="2"></td>
- {% endif %}
+ {% else %}
+ -
+ {% endif %}
+ </td>
{% endwith %}
</tr>
{% endfor %}