Добавлены кнопки создания вариативных товаров и групп вариантов на страницы /products/all/ и /products/catalog/. Улучшен табличный режим каталога с фиксированной сеткой колонок, двухстрочными названиями и выравниванием по всей ширине
This commit is contained in:
@@ -6,6 +6,7 @@ from django.views.generic import ListView
|
||||
from django.db.models import Prefetch, Sum, Value, DecimalField, Q
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.core.paginator import Paginator
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from ..models import Product, ProductKit, ProductCategory, ProductPhoto, ProductKitPhoto, KitItem
|
||||
|
||||
@@ -108,4 +109,41 @@ class CatalogView(LoginRequiredMixin, ListView):
|
||||
category_tree = self.build_category_tree(categories, parent=None)
|
||||
context['category_tree'] = category_tree
|
||||
|
||||
# Кнопки действий
|
||||
action_buttons = []
|
||||
|
||||
if self.request.user.has_perm('products.add_product'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:product-create'),
|
||||
'text': 'Создать товар',
|
||||
'class': 'btn-primary',
|
||||
'icon': 'plus-circle'
|
||||
})
|
||||
|
||||
if self.request.user.has_perm('products.add_productkit'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:productkit-create'),
|
||||
'text': 'Создать комплект',
|
||||
'class': 'btn-outline-primary',
|
||||
'icon': 'box-seam'
|
||||
})
|
||||
|
||||
if self.request.user.has_perm('products.add_configurableproduct'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:configurableproduct-create'),
|
||||
'text': 'Создать вариативный товар',
|
||||
'class': 'btn-outline-success',
|
||||
'icon': 'grid-3x3-gap'
|
||||
})
|
||||
|
||||
if self.request.user.has_perm('products.add_productvariantgroup'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:variantgroup-create'),
|
||||
'text': 'Создать группу вариантов',
|
||||
'class': 'btn-outline-info',
|
||||
'icon': 'collection'
|
||||
})
|
||||
|
||||
context['action_buttons'] = action_buttons
|
||||
|
||||
return context
|
||||
|
||||
@@ -402,6 +402,22 @@ class CombinedProductListView(LoginRequiredMixin, ManagerOwnerRequiredMixin, Lis
|
||||
'icon': 'box-seam'
|
||||
})
|
||||
|
||||
if self.request.user.has_perm('products.add_configurableproduct'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:configurableproduct-create'),
|
||||
'text': 'Создать вариативный товар',
|
||||
'class': 'btn-outline-success',
|
||||
'icon': 'grid-3x3-gap'
|
||||
})
|
||||
|
||||
if self.request.user.has_perm('products.add_productvariantgroup'):
|
||||
action_buttons.append({
|
||||
'url': reverse_lazy('products:variantgroup-create'),
|
||||
'text': 'Создать группу вариантов',
|
||||
'class': 'btn-outline-info',
|
||||
'icon': 'collection'
|
||||
})
|
||||
|
||||
context['action_buttons'] = action_buttons
|
||||
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user