Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Order list in profile
Marek Brzóskaf59382a62ffc
diff --git a/order/models.py b/order/models.pyindex ea61c78fa4..1e5e7b6169 100644--- a/order/models.py+++ b/order/models.py@@ -21,7 +21,7 @@ class Order(models.Model, ItemSet):('cancelled', pgettext_lazy(u'Order status field value',u'cancelled')),('payment', pgettext_lazy(u'Order status field value',- u'payment')),+ u'payment')),('completed', pgettext_lazy(u'Order status field value',u'completed')))status = models.CharField(@@ -34,7 +34,7 @@ class Order(models.Model, ItemSet):pgettext_lazy(u'Order field', u'last status change'),default=datetime.datetime.now, editable=False)user = models.ForeignKey(- settings.AUTH_USER_MODEL, blank=True, null=True, related_name='+',+ settings.AUTH_USER_MODEL, blank=True, null=True, related_name='orders',verbose_name=pgettext_lazy(u'Order field', u'user'))billing_address = models.ForeignKey(Address, related_name='+')anonymous_user_email = models.EmailField(blank=True, default='')diff --git a/saleor/templates/base.html b/saleor/templates/base.htmlindex fd14f51996..21ddda73b6 100644--- a/saleor/templates/base.html+++ b/saleor/templates/base.html@@ -54,8 +54,9 @@<li class="dropdown pull-right"> {# TODO pull-right not working #}<a data-toggle="dropdown" class="dropdown-toggle" href=".">{{ user }}</a><ul class="dropdown-menu">- <li><a href="{% url "profile:details" %}">Profile edit</a></li>- <li><a href="{% url "registration:logout" %}">Log out</a></li>+ <li><a href="{% url "profile:details" %}">{% trans "Profile edit" %}</a></li>+ <li><a href="{% url "registration:logout" %}">{% trans "Log out" %}</a></li>+ <li><a href="{% url "profile:orders" %}">{% trans "Orders" %}</a></li></ul></li>{% else %}diff --git a/userprofile/templates/userprofile/orders.html b/userprofile/templates/userprofile/orders.htmlnew file mode 100644index 0000000000..c6b3df4acc--- /dev/null+++ b/userprofile/templates/userprofile/orders.html@@ -0,0 +1,32 @@+{% extends "base.html" %}+{% load i18n %}+++{% block content %}+ <table class="table">+ <thead>+ <tr>+ <th>+ {% trans "Order token" %}+ </th>+ <th>+ {% trans "Status" %}+ </th>+ </tr>+ </thead>+ <tbody>+ {% for order in orders %}+ <tr>+ <td>+ <a href="{{ order.get_absolute_url }}">{{ order.token }}</a>+ </td>+ <td>+ {{ order.get_status_display }}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ </table>++{% endblock content %}+diff --git a/userprofile/urls.py b/userprofile/urls.pyindex 5d479bd0da..36905fe891 100644--- a/userprofile/urls.py+++ b/userprofile/urls.py@@ -4,6 +4,7 @@ from django.conf.urls import patterns, urlurlpatterns = patterns('',url(r'^$', 'userprofile.views.details', name='details'),+ url(r'^orders/$', 'userprofile.views.orders', name='orders'),url(r'^address/create/$','userprofile.views.address_create',name='address-create'),diff --git a/userprofile/views.py b/userprofile/views.pyindex 822756b076..4bc7f183e2 100755--- a/userprofile/views.py+++ b/userprofile/views.py@@ -17,6 +17,13 @@ def details(request):return TemplateResponse(request, "userprofile/details.html", ctx)+@login_required+def orders(request):++ ctx = {'orders': request.user.orders.all()}+ return TemplateResponse(request, "userprofile/orders.html", ctx)++def validate_address_and_render(request, address_form, address_book_form,success_message):if address_form.is_valid() and address_book_form.is_valid():