Skip to content

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

Highlight create order action

Anna Siwike962edc6274a
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index 1adea14cc2..4acf70ce91 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -32,14 +32,13 @@ from .utils import (
update_order_with_user_addresses)
-class ConfirmDraftOrderForm(forms.ModelForm):
+class CreateOrderFromDraftForm(forms.ModelForm):
"""Save draft order as a ready to fulfill."""
notify_customer = forms.BooleanField(
label=pgettext_lazy(
'Send email to customer about order created by staff users',
'Notify customer'),
required=False, initial=True)
- reapply_voucher = forms.BooleanField(required=False, initial=True)
class Meta:
model = Order
@@ -55,8 +54,8 @@ class ConfirmDraftOrderForm(forms.ModelForm):
errors = []
if self.instance.get_total_quantity() == 0:
errors.append(forms.ValidationError(pgettext_lazy(
- 'Confirm draft order form error',
- 'Could not confirm order without any products')))
+ 'Create draft order form error',
+ 'Could not create order without any products')))
if self.instance.is_shipping_required():
method = self.instance.shipping_method
shipping_address = self.instance.shipping_address
@@ -66,7 +65,7 @@ class ConfirmDraftOrderForm(forms.ModelForm):
shipping_address.country.code != method.country_code
):
errors.append(forms.ValidationError(pgettext_lazy(
- 'Confirm draft order form error',
+ 'Create draft order form error',
'Shipping method is not valid for chosen shipping '
'address')))
if errors:
diff --git a/saleor/dashboard/order/urls.py b/saleor/dashboard/order/urls.py
index a6494681d7..ee75454c4a 100644
--- a/saleor/dashboard/order/urls.py
+++ b/saleor/dashboard/order/urls.py
@@ -5,8 +5,8 @@ from . import views
urlpatterns = [
url(r'^$', views.order_list, name='orders'),
url(r'^add/$', views.order_create, name='order-create'),
- url(r'^(?P<order_pk>\d+)/confirm-draft/$',
- views.confirm_draft_order, name='draft-order-confirm'),
+ url(r'^(?P<order_pk>\d+)/create/$',
+ views.create_order_from_draft, name='create-order-from-draft'),
url(r'^(?P<order_pk>\d+)/$',
views.order_details, name='order-details'),
url(r'^(?P<order_pk>\d+)/add-note/$',
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
index 2179d64291..3223d7b36c 100644
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -30,7 +30,7 @@ from .forms import (
AddressForm, AddVariantToOrderForm, BaseFulfillmentLineFormSet,
CancelFulfillmentForm, CancelOrderForm, CancelOrderLineForm,
CapturePaymentForm, ChangeQuantityForm, ChangeStockForm,
- ConfirmDraftOrderForm, FulfillmentForm, FulfillmentLineForm,
+ CreateOrderFromDraftForm, FulfillmentForm, FulfillmentLineForm,
FulfillmentTrackingNumberForm, OrderCustomerForm, OrderEditDiscountForm,
OrderEditVoucherForm, OrderNoteForm, OrderRemoveCustomerForm,
OrderRemoveShippingForm, OrderRemoveVoucherForm, OrderShippingForm,
@@ -68,10 +68,10 @@ def order_create(request):
@staff_member_required
@permission_required('order.edit_order')
-def confirm_draft_order(request, order_pk):
+def create_order_from_draft(request, order_pk):
order = get_object_or_404(Order, pk=order_pk, status=OrderStatus.DRAFT)
status = 200
- form = ConfirmDraftOrderForm(request.POST or None, instance=order)
+ form = CreateOrderFromDraftForm(request.POST or None, instance=order)
if form.is_valid():
form.save()
msg = pgettext_lazy(
@@ -89,7 +89,7 @@ def confirm_draft_order(request, order_pk):
return redirect('dashboard:order-details', order_pk=order.pk)
elif form.errors:
status = 400
- template = 'dashboard/order/modal/confirm_order.html'
+ template = 'dashboard/order/modal/create_order.html'
ctx = {'form': form, 'order': order}
return TemplateResponse(request, template, ctx, status=status)
diff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.html
index 6b2f097b2e..b82ec1bd4f 100644
--- a/templates/dashboard/order/detail.html
+++ b/templates/dashboard/order/detail.html
@@ -471,10 +471,14 @@
<a href="#base-modal" data-href="{% url 'dashboard:add-variant-to-order' order_pk=order.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans "Add product to order" context "Order summary card action title" %}">
{% trans "Add product" context "Order summary card action" %}
</a>
- <a href="#base-modal" data-href="{% url 'dashboard:draft-order-confirm' order_pk=order.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans "Confirm order" context "Order summary card action title" %}">
- {% trans "Confirm" context "Order summary card action" %}
- </a>
{% endif %}
+ <span class="right">
+ {% if order.is_draft %}
+ <a href="#base-modal" data-href="{% url 'dashboard:create-order-from-draft' order_pk=order.pk %}" class="btn waves-effect modal-trigger-custom" title="{% trans "Create order" context "Order summary card action title" %}">
+ {% trans "Create order" context "Order summary card action" %}
+ </a>
+ {% endif %}
+ </span>
</div>
{% endif %}
{% endif %}
diff --git a/templates/dashboard/order/modal/confirm_order.html b/templates/dashboard/order/modal/confirm_order.html
deleted file mode 100644
index 3b4fa6447f..0000000000
--- a/templates/dashboard/order/modal/confirm_order.html
+++ /dev/null
@@ -1,27 +0,0 @@
-{% extends "dashboard/base_modal.html" %}
-
-{% load i18n %}
-{% load materializecss %}
-
-{% block action_url %}
-{% url 'dashboard:draft-order-confirm' order_pk=order.pk %}
-{% endblock %}
-
-{% block title %}
-{% trans "Confirm order" context "Modal confirm order title" %}
-{% endblock %}
-
-{% block content %}
- <div class="col s12">
- {% blocktrans trimmed with order=order context "Modal confirm order text" %}
- Are you sure you want confirm order {{ order }}? Once the order has been confirmed, you will not be able to make changes.
- {% endblocktrans %}
- {% if form.notify_customer %}
- {{ form.notify_customer|materializecss }}
- {% endif %}
- </div>
-{% endblock %}
-
-{% block primary_action %}
-{% trans "Confirm" context "Modal confirm order primary action" %}
-{% endblock %}
diff --git a/templates/dashboard/order/modal/create_order.html b/templates/dashboard/order/modal/create_order.html
new file mode 100644
index 0000000000..1238db632d
--- /dev/null
+++ b/templates/dashboard/order/modal/create_order.html
@@ -0,0 +1,27 @@
+{% extends "dashboard/base_modal.html" %}
+
+{% load i18n %}
+{% load materializecss %}
+
+{% block action_url %}
+{% url 'dashboard:create-order-from-draft' order_pk=order.pk %}
+{% endblock %}
+
+{% block title %}
+{% trans "Create order" context "Modal create order title" %}
+{% endblock %}
+
+{% block content %}
+ <div class="col s12">
+ {% blocktrans trimmed with order=order context "Modal create order text" %}
+ Are you sure you want create order {{ order }}? Once the order has been created, you will not be able to make changes.
+ {% endblocktrans %}
+ {% if form.notify_customer %}
+ {{ form.notify_customer|materializecss }}
+ {% endif %}
+ </div>
+{% endblock %}
+
+{% block primary_action %}
+{% trans "Create" context "Modal create order primary action" %}
+{% endblock %}
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
index fd31ab808a..fd1cbfa9c7 100644
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -841,7 +841,7 @@ def test_view_order_create(admin_client):
def test_view_confirm_draft_order_valid(admin_client, draft_order):
order = draft_order
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': order.pk})
+ 'dashboard:create-order-from-draft', kwargs={'order_pk': order.pk})
data = {'csrfmiddlewaretoken': 'hello'}
response = admin_client.post(url, data)
@@ -861,7 +861,7 @@ def test_view_confirm_draft_order_assigns_customer_email(
order.user_email = ''
order.save()
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': order.pk})
+ 'dashboard:create-order-from-draft', kwargs={'order_pk': order.pk})
data = {'csrfmiddlewaretoken': 'hello'}
admin_client.post(url, data)
@@ -875,7 +875,7 @@ def test_view_confirm_draft_order_empty_order(admin_client, draft_order):
order = draft_order
order.lines.all().delete()
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': order.pk})
+ 'dashboard:create-order-from-draft', kwargs={'order_pk': order.pk})
data = {'csrfmiddlewaretoken': 'hello'}
response = admin_client.post(url, data)
@@ -891,7 +891,7 @@ def test_view_confirm_draft_order_empty_order(admin_client, draft_order):
def test_view_confirm_draft_order_not_draft_order(
admin_client, order_with_lines):
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': order_with_lines.pk})
+ 'dashboard:create-order-from-draft', kwargs={'order_pk': order_with_lines.pk})
data = {'csrfmiddlewaretoken': 'hello'}
response = admin_client.post(url, data)
@@ -907,7 +907,8 @@ def test_view_confirm_draft_order_shipping_method_not_valid(
draft_order.shipping_method = method
draft_order.save()
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': draft_order.pk})
+ 'dashboard:create-order-from-draft',
+ kwargs={'order_pk': draft_order.pk})
data = {'csrfmiddlewaretoken': 'hello'}
response = admin_client.post(url, data)
@@ -934,7 +935,7 @@ def test_view_confirm_draft_order_no_shipping_address_shipping_not_required(
unit_price_net=Decimal('10.00'),
unit_price_gross=Decimal('10.00'))
url = reverse(
- 'dashboard:draft-order-confirm', kwargs={'order_pk': order.pk})
+ 'dashboard:create-order-from-draft', kwargs={'order_pk': order.pk})
data = {'csrfmiddlewaretoken': 'hello'}
response = admin_client.post(url, data)