Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Initial work for category management
Marcin Gębala0b55fce3894a
diff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.pyindex 9643e501e9..db599f98d1 100644--- a/saleor/dashboard/product/urls.py+++ b/saleor/dashboard/product/urls.py@@ -12,4 +12,11 @@ urlpatterns = patterns(url(r'^add/(?P<cls_name>[-\w]+)/$',views.product_details, name='product-add'),url(r'^(?P<pk>[0-9]+)/delete/$',- views.ProductDeleteView.as_view(), name='product-delete'),)+ views.ProductDeleteView.as_view(), name='product-delete'),++ url(r'^categories/$',+ views.category_list, name='category-list'),+ url(r'^categories/(?P<pk>[0-9]+)/update/$',+ views.category_details, name='category-update'),+ url(r'^categories/add/$',+ views.category_details, name='category-add'))diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex d07f43d53f..f93607c8d1 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -8,7 +8,7 @@ from django.template.response import TemplateResponsefrom django.utils.translation import ugettext_lazy as _from django.views.generic import DeleteView-from ...product.models import Product+from ...product.models import Product, Categoryfrom ..utils import paginatefrom ..views import StaffMemberOnlyMixin, staff_member_requiredfrom .forms import (ProductImageFormSet, ProductClassForm, get_product_form,@@ -73,3 +73,20 @@ class ProductDeleteView(StaffMemberOnlyMixin, DeleteView):result = self.delete(request, *args, **kwargs)messages.success(request, _('Deleted product %s') % self.object)return result+++def category_list(request):+ categories = Category.objects.all()+ ctx = {'categories': categories}+ return TemplateResponse(request, 'dashboard/product/category/list.html', ctx)+++def category_details(request, pk=None):+ if pk:+ category = get_object_or_404(Category.objects.all(), pk=pk)+ title = category.name+ else:+ category = Category()+ title = _('Add new category')+ ctx = {'category': category, 'title': title}+ return TemplateResponse(request, 'dashboard/product/category/detail.html', ctx)diff --git a/saleor/dashboard/templates/dashboard/product/category/detail.html b/saleor/dashboard/templates/dashboard/product/category/detail.htmlnew file mode 100644index 0000000000..f24eac17f5--- /dev/null+++ b/saleor/dashboard/templates/dashboard/product/category/detail.html@@ -0,0 +1,13 @@+{% extends "dashboard/base.html" %}+{% load i18n %}+{% load mptt_tags %}++{% block title %}{{ title }} - {{ block.super }}{% endblock %}++{% block content %}+ <div class="row">+ <div class="col-lg-12">+ <h1 class="page-header">{% trans "Category" %} {{ category.name }}</h1>+ </div>+ </div>+{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/category/list.html b/saleor/dashboard/templates/dashboard/product/category/list.htmlnew file mode 100644index 0000000000..81a80107ba--- /dev/null+++ b/saleor/dashboard/templates/dashboard/product/category/list.html@@ -0,0 +1,26 @@+{% extends "dashboard/base.html" %}+{% load i18n %}+{% load mptt_tags %}++{% block title %}{% trans "Categories" %} - {{ block.super }}{% endblock %}++{% block content %}+ <div class="row">+ <div class="col-lg-12">+ <h1 class="page-header">{% trans "Categories" %}</h1>+ <a class="btn btn-default" href="{% url 'dashboard:category-add' %}">{% trans 'Add category' %}</a>+ <ul class="list-unstyled">+ {% recursetree categories %}+ <li>+ <a href="{% url 'dashboard:category-update' pk=node.pk %}">{{ node.name }}</a>+ {% if not node.is_leaf_node %}+ <ul class="children">+ {{ children }}+ </ul>+ {% endif %}+ </li>+ {% endrecursetree %}+ </ul>+ </div>+ </div>+{% endblock %}