Skip to content

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

Improve order details

Paweł Kowalewskif5487403d1f6
diff --git a/saleor/core/templates/materializecssform/field.html b/saleor/core/templates/materializecssform/field.html
index aab25945dd..2b9a3ade12 100644
--- a/saleor/core/templates/materializecssform/field.html
+++ b/saleor/core/templates/materializecssform/field.html
@@ -106,7 +106,7 @@
{% elif field|is_textarea %}
<div class="input-field col {{ classes.label }}">
- <textarea id="{{ field.auto_id }}" class="materialize-textarea" name="{{field.name}}">{% if field.value %}{{ field.value }}{% endif %}</textarea>
+ {{ field }}
{% if field.auto_id %}
<label class="active {{ classes.label }}{% if not field.field.required %} optional{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
{% endif %}
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index 17e1f894c1..5358396812 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -14,7 +14,7 @@ class OrderNoteForm(forms.ModelForm):
model = OrderNote
fields = ['content']
widgets = {'content': forms.Textarea({
- 'rows': 5, 'placeholder': _('Note')})}
+ 'rows': 5, 'placeholder': _('Note'), 'class': 'materialize-textarea'})}
def __init__(self, *args, **kwargs):
super(OrderNoteForm, self).__init__(*args, **kwargs)
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
index c9a0c8b619..ab53cd187a 100644
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -33,6 +33,7 @@ def order_details(request, order_pk):
order = get_object_or_404(Order.objects.prefetch_related(
'notes', 'payments', 'history', 'groups'), pk=order_pk)
notes = order.notes.all()
+ all_payments = order.payments.all()
payment = order.payments.last()
groups = list(order)
captured = preauthorized = Price(0, currency=order.get_total().currency)
@@ -47,10 +48,10 @@ def order_details(request, order_pk):
else:
can_capture = can_release = can_refund = False
- ctx = {'order': order, 'payment': payment, 'notes': notes, 'groups': groups,
- 'captured': captured, 'preauthorized': preauthorized,
- 'can_capture': can_capture, 'can_release': can_release,
- 'can_refund': can_refund}
+ ctx = {'order': order, 'all_payments': all_payments, 'payment': payment,
+ 'notes': notes, 'groups': groups, 'captured': captured,
+ 'preauthorized': preauthorized, 'can_capture': can_capture,
+ 'can_release': can_release, 'can_refund': can_refund}
return TemplateResponse(request, 'dashboard/order/detail.html', ctx)
@@ -67,7 +68,7 @@ def order_add_note(request, order_pk):
return redirect('dashboard:order-details', order_pk=order_pk)
elif form.errors:
status = 400
- ctx = {'object': order, 'form': form}
+ ctx = {'order': order, 'form': form}
ctx.update(csrf(request))
template = 'dashboard/order/modal_add_note.html'
return TemplateResponse(request, template, ctx, status=status)
diff --git a/saleor/dashboard/templates/dashboard/order/detail.html b/saleor/dashboard/templates/dashboard/order/detail.html
index d86c9cad09..f2b78feb26 100644
--- a/saleor/dashboard/templates/dashboard/order/detail.html
+++ b/saleor/dashboard/templates/dashboard/order/detail.html
@@ -253,26 +253,32 @@
</div>
</div>
- <div class="card tab-content" id="payment-history">
- <table class="bordered hoverable responsive data-table">
- <thead>
- <tr>
- <th></th>
- <th>{% trans "Date" %}</th>
- <th class="wide">{% trans "Payment status" %}</th>
- </tr>
- </thead>
-
- <tbody>
- {% for payment in order.payments.all %}
- <tr>
- <td><a href="{% url "dashboard:payment-details" pk=payment.pk %}">#{{ payment.id }}</a></td>
- <td>{{ payment.created }}</td>
- <td>{% render_status payment.status payment.get_status_display %}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ <div class="tab-content" id="payment-history">
+ {% if all_payments %}
+ <div class="card">
+ <table class="bordered hoverable responsive data-table">
+ <thead>
+ <tr>
+ <th></th>
+ <th>{% trans "Date" %}</th>
+ <th class="wide">{% trans "Payment status" %}</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {% for payment in all_payments %}
+ <tr>
+ <td><a href="{% url "dashboard:payment-details" pk=payment.pk %}">#{{ payment.id }}</a></td>
+ <td>{{ payment.created }}</td>
+ <td>{% render_status payment.status payment.get_status_display %}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ {% else %}
+ <p>{% trans "No payments made for this order." %}</p>
+ {% endif %}
</div>
<div class="card tab-content" id="order-history">