Merge tag 'vcustomer-detail-styling' into develop

1.3.8 vcustomer-detail-styling
This commit is contained in:
Nathan Chapman 2022-05-19 19:16:49 -06:00
commit 2883b42117
5 changed files with 32 additions and 4 deletions

View File

@ -165,6 +165,11 @@ class OrderManager(models.Manager):
def with_lines(self):
return self.select_related('lines')
def without_drafts(self):
return self.exclude(
status=OrderStatus.DRAFT
)
def with_fulfillment(self):
return self.annotate(
total_quantity_fulfilled=models.Sum('lines__quantity_fulfilled'),

View File

@ -577,13 +577,20 @@ article > header {
display: flex;
justify-content: space-between;
align-items: center;
align-content: center;
}
.article__header--with-action h1 {
margin-bottom: 0;
}
@media screen and (max-width: 600px) {
.article__header--with-action {
flex-direction: column;
align-items: flex-start;
}
}
article + article {
margin-top: 8rem;
}
@ -897,6 +904,13 @@ article + article {
gap: 4rem;
}
@media screen and (max-width: 600px) {
.customer__detail-section {
grid-template-columns: 1fr;
gap: 1rem;
}
}

View File

@ -57,7 +57,6 @@
{% endfor %}
</div>
</section>
{% with order_list=customer.orders.all %}
<section>
<h3>Your orders</h3>
<table>
@ -73,7 +72,7 @@
<tr>
<td>#{{order.pk}}</td>
<td>{{order.created_at|date:"M j, Y"}}</td>
<td>${{order.total_net_amount}}</td>
<td>${{order.get_total_price_after_discount}}</td>
<td><a href="{% url 'storefront:order-detail' customer.pk order.pk %}">See details &rarr;</a></td>
</tr>
{% empty %}
@ -82,6 +81,5 @@
</tbody>
</table>
</section>
{% endwith %}
</article>
{% endblock content %}

View File

@ -56,6 +56,10 @@
<td>{{order.coupon.discount_value}} {{order.coupon.get_discount_value_type_display}}</td>
</tr>
{% endif %}
<tr>
<td>Shipping</td>
<td>${{order.shipping_total}}</td>
</tr>
<tr>
<th>Total</th>
<td><strong>${{order.get_total_price_after_discount}}</strong></td>

View File

@ -337,6 +337,13 @@ class CustomerDetailView(UserPassesTestMixin, LoginRequiredMixin, DetailView):
permission_denied_message = 'Not authorized.'
raise_exception = True
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['order_list'] = Order.objects.without_drafts().filter(
customer=self.object
).prefetch_related('lines')
return context
def test_func(self):
return self.request.user.pk == self.get_object().pk