Skip to content

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

Remove promoting customer to staff action

Anna Siwik18128275a95d
diff --git a/saleor/dashboard/customer/urls.py b/saleor/dashboard/customer/urls.py
index 6dca905893..963b7c98c9 100644
--- a/saleor/dashboard/customer/urls.py
+++ b/saleor/dashboard/customer/urls.py
@@ -8,7 +8,5 @@ urlpatterns = [
url(r'^create/$', views.customer_create, name='customer-create'),
url(r'^(?P<pk>[0-9]+)/$', views.customer_details, name='customer-details'),
url(r'^(?P<pk>[0-9]+)/update/$', views.customer_edit,
- name='customer-update'),
- url(r'^(?P<pk>[0-9]+)/promote/$', views.customer_promote_to_staff,
- name='customer-promote')
+ name='customer-update')
]
diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.py
index 1f10dac156..cd8270bc73 100644
--- a/saleor/dashboard/customer/views.py
+++ b/saleor/dashboard/customer/views.py
@@ -73,20 +73,3 @@ def customer_edit(request, pk=None):
ctx = {'form': form, 'customer': customer}
return TemplateResponse(request, 'dashboard/customer/form.html', ctx)
-
-@staff_member_required
-@permission_required('userprofile.edit_staff')
-@permission_required('userprofile.edit_user')
-def customer_promote_to_staff(request, pk):
- customer = get_object_or_404(User, pk=pk)
- if request.method == 'POST':
- customer.is_staff = True
- customer.save()
- msg = pgettext_lazy(
- 'Dashboard message',
- 'Customer %s promoted to staff member') % customer
- messages.success(request, msg)
- return redirect('dashboard:customer-details', pk=customer.pk)
- return TemplateResponse(
- request, 'dashboard/customer/modal/confirm_promote.html',
- {'customer': customer})
diff --git a/templates/dashboard/customer/detail.html b/templates/dashboard/customer/detail.html
index 341d61513b..9ab300e000 100644
--- a/templates/dashboard/customer/detail.html
+++ b/templates/dashboard/customer/detail.html
@@ -63,11 +63,6 @@
{% trans "Edit customer" context "Customer action" %}
</a>
{% endif %}
- {% if not customer.is_staff and perms.userprofile.edit_user and perms.userprofile.edit_staff %}
- <a href="#base-modal" class="btn-flat waves-effect modal-trigger-custom" data-href="{% url 'dashboard:customer-promote' pk=customer.pk %}">
- {% trans 'Promote to staff' context 'Customer promote to staff member action' %}
- </a>
- {% endif %}
{% if perms.userprofile.impersonate_user %}
<a href="{% url 'impersonate-start' uid=customer.pk %}" class="btn-flat waves-effect">
{% trans 'Impersonate customer' context 'Customer impersonate action' %}
diff --git a/tests/dashboard/test_customer.py b/tests/dashboard/test_customer.py
deleted file mode 100644
index b2b3fe6446..0000000000
--- a/tests/dashboard/test_customer.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from django.urls import reverse
-
-from saleor.userprofile.models import User
-
-
-def test_customer_promote_to_staff_with_POST(admin_client, customer_user):
- assert User.objects.filter(is_staff=True).count() == 1
- url = reverse(
- 'dashboard:customer-promote', kwargs={'pk': customer_user.pk})
- admin_client.get(url)
- assert User.objects.filter(is_staff=True).count() == 1
-
-
-def test_customer_promote_to_staff(admin_client, customer_user):
- assert User.objects.filter(is_staff=True).count() == 1
- url = reverse(
- 'dashboard:customer-promote', kwargs={'pk': customer_user.pk})
- data = {'pk': customer_user.pk}
- response = admin_client.post(url, data)
- assert User.objects.filter(is_staff=True).count() == 2
- assert response['Location'] == reverse('dashboard:customer-details',
- kwargs={'pk': customer_user.pk})
diff --git a/tests/dashboard/test_permissions.py b/tests/dashboard/test_permissions.py
index 7805c1884a..a56938fa13 100644
--- a/tests/dashboard/test_permissions.py
+++ b/tests/dashboard/test_permissions.py
@@ -903,30 +903,6 @@ def test_staff_with_permissions_can_update_add_and_delete_shipping_method(
assert response.status_code == 200
-def test_staff_with_permissions_can_promote_customer(
- staff_client, staff_user, staff_group, customer_user,
- permission_edit_staff, permission_edit_user):
- assert not staff_user.has_perm("userprofile.edit_user")
- assert not staff_user.has_perm("userprofile.edit_staff")
- assert not customer_user.is_staff
- response = staff_client.get(reverse('dashboard:customer-promote',
- args=[customer_user.pk]))
- assert response.status_code == 302
- staff_group.permissions.add(permission_edit_user)
- staff_group.permissions.add(permission_edit_staff)
- staff_user.groups.add(staff_group)
- staff_user = User.objects.get(pk=staff_user.pk)
- assert staff_user.has_perm("userprofile.edit_user")
- assert staff_user.has_perm("userprofile.edit_staff")
- response = staff_client.get(reverse('dashboard:customer-promote',
- args=[customer_user.pk]))
- assert response.status_code == 200
- response = staff_client.post(reverse('dashboard:customer-promote',
- args=[customer_user.pk]))
- customer_user = User.objects.get(pk=customer_user.pk)
- assert customer_user.is_staff
-
-
def test_staff_with_permissions_can_edit_customer(
staff_client, customer_user, staff_user, staff_group,
permission_edit_user, permission_view_user):