Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Extract 'category' dahsboard module
Marcin Gębalaac5f127c8cb2
diff --git a/saleor/dashboard/category/__init__.py b/saleor/dashboard/category/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/dashboard/category/urls.py b/saleor/dashboard/category/urls.pynew file mode 100644index 0000000000..0e6594a21c--- /dev/null+++ b/saleor/dashboard/category/urls.py@@ -0,0 +1,13 @@+from django.conf.urls import patterns, url++from . import views+++urlpatterns = patterns(+ '',+ url(r'^$',+ views.category_list, name='categories'),+ url(r'^(?P<pk>[0-9]+)/update/$',+ views.category_details, name='category-update'),+ url(r'^add/$',+ views.category_details, name='category-add'))diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.pynew file mode 100644index 0000000000..e6d4793c68--- /dev/null+++ b/saleor/dashboard/category/views.py@@ -0,0 +1,22 @@+from django.shortcuts import get_object_or_404+from django.template.response import TemplateResponse+from django.utils.translation import ugettext_lazy as _++from ...product.models import Category+++def category_list(request):+ categories = Category.objects.all()+ ctx = {'categories': categories}+ return TemplateResponse(request, 'dashboard/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/category/detail.html', ctx)diff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.pyindex db599f98d1..9643e501e9 100644--- a/saleor/dashboard/product/urls.py+++ b/saleor/dashboard/product/urls.py@@ -12,11 +12,4 @@ 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'),-- 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'))+ views.ProductDeleteView.as_view(), name='product-delete'),)diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex f93607c8d1..d07f43d53f 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, Category+from ...product.models import Productfrom ..utils import paginatefrom ..views import StaffMemberOnlyMixin, staff_member_requiredfrom .forms import (ProductImageFormSet, ProductClassForm, get_product_form,@@ -73,20 +73,3 @@ 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/category/detail.htmlsimilarity index 100%rename from saleor/dashboard/templates/dashboard/product/category/detail.htmlrename to saleor/dashboard/templates/dashboard/category/detail.htmldiff --git a/saleor/dashboard/templates/dashboard/product/category/list.html b/saleor/dashboard/templates/dashboard/category/list.htmlsimilarity index 100%rename from saleor/dashboard/templates/dashboard/product/category/list.htmlrename to saleor/dashboard/templates/dashboard/category/list.htmldiff --git a/saleor/dashboard/templates/dashboard/includes/sidebar.html b/saleor/dashboard/templates/dashboard/includes/sidebar.htmlindex 962ce6f536..94cf96bc18 100644--- a/saleor/dashboard/templates/dashboard/includes/sidebar.html+++ b/saleor/dashboard/templates/dashboard/includes/sidebar.html@@ -4,6 +4,7 @@<li><a href="{% url 'dashboard:index' %}">Home</a></li><li><a href="{% url 'dashboard:orders' %}">Orders</a></li><li><a href="{% url 'dashboard:products' %}">Products</a></li>+ <li><a href="{% url 'dashboard:categories' %}">Categories</a></li><li><a href="{% url 'dashboard:customers' %}">Customers</a></li><li><a href="{% url 'dashboard:payments' %}">Payments</a></li></ul>diff --git a/saleor/dashboard/urls.py b/saleor/dashboard/urls.pyindex 7f6842f847..aef39e34f0 100644--- a/saleor/dashboard/urls.py+++ b/saleor/dashboard/urls.py@@ -1,6 +1,7 @@from django.conf.urls import patterns, url, includefrom . import views as core_views+from .category.urls import urlpatterns as category_urlsfrom .customer.urls import urlpatterns as customer_urlsfrom .order.urls import urlpatterns as order_urlsfrom .payments.urls import urlpatterns as payments_urls@@ -10,6 +11,7 @@ from .product.urls import urlpatterns as product_urlsurlpatterns = patterns('',url(r'^$', core_views.index, name='index'),+ url(r'^categories/', include(category_urls)),url(r'^orders/', include(order_urls)),url(r'^products/', include(product_urls)),url(r'^payments/', include(payments_urls)),