remotes/origin/mitri4
spacenergy 10 years ago
parent 70080f9f0a
commit 8a7e7c1614
  1. 37
      batiskaf/templates/jinja2/category.jinja
  2. 23
      batiskaf/templates/jinja2/includes/category_category_thumb.jinja
  3. 2
      batiskaf/templates/jinja2/includes/category_filter.jinja
  4. 30
      store/migrations/0036_auto_20150925_1215.py
  5. 19
      store/migrations/0037_category_hide_products.py
  6. 12
      store/models.py
  7. 5
      store/views.py

@ -71,8 +71,16 @@
</div>
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9 index-goods category-items">
{% if category.hide_products %}
{% for child in category.childs.all() %}
{% include 'includes/category_category_thumb.jinja' with context %}
{# <li>#}
{# <a href="{{ child.get_absolute_url() }}">{{ child.title }}</a>#}
{# </li>#}
{% endfor %}
{% if products %}
{% elif products %}
<div class="category-paginator">
<div class="category-paginator-top">
<div class="row">
@ -118,6 +126,20 @@
</div>
</div>
</div>
{% else %}
<div class="alert alert-warning alert-dismissable">
<h4>Список товаров пуст</h4>
<p>Товары в данной категории или с выбранными параметрами отсутствуют. Выберите другую
категорию, либо сбросьте фильтр параметров.</p>
<p><a class="btn btn-warning" href="/">Перейти на главную страницу</a>
{% if category %}
<a class="btn btn-link"
href="{{ category.get_absolute_url() }}">или
отменить фильтрацию</a>
{% endif %} </p>
</div>
{% endif %}
<div class="row">
{% if products %}
@ -134,20 +156,7 @@
{% endif %}
{% endfor %}
{% else %}
<div class="alert alert-warning alert-dismissable">
<h4>Список товаров пуст</h4>
<p>Товары в данной категории или с выбранными параметрами отсутствуют. Выберите другую
категорию, либо сбросьте фильтр параметров.</p>
<p><a class="btn btn-warning" href="/">Перейти на главную страницу</a>
{% if category %}
<a class="btn btn-link"
href="{{ category.get_absolute_url() }}">или
отменить фильтрацию</a>
{% endif %} </p>
</div>
{% endif %}
</div>

@ -0,0 +1,23 @@
<div class="col-md-4 col-xs-4 col-sm-4 col-lg-4">
<div class="thumbnail">
{% set im = child.image|thumbnail("420x420") %}
<a href="{{ child.get_absolute_url() }}">
<img src="/static/{{ im.url }}"
class="img-responsive" alt="Купить {{ child.title }}"
title="Купить {{ child.title }}" width="210" height="210"></a>
<div class="caption"><br>
<div class="title text-center">
<a href="{{ child.get_absolute_url() }}">
{{ child.title }}
</a>
</div>
</div>
</div>
</div>

@ -1,7 +1,7 @@
{% if category %}
{% if category.childs.all() %}
{% if not category.hide_products and category.childs.all() %}
<div class="category-filter-title">&rarr;&nbsp;&nbsp;&nbsp;Категории</div>
<ul class="attr-filter">
{% for child in category.childs.all() %}

File diff suppressed because one or more lines are too long

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('store', '0036_auto_20150925_1215'),
]
operations = [
migrations.AddField(
model_name='category',
name='hide_products',
field=models.BooleanField(verbose_name='Показывать дочерние категории вместо товаров', default=False),
),
]

@ -18,6 +18,10 @@ FIELD_TYPE_CHOICES = (
(FIELD_TYPE_SELECT, 'Список'),
)
def photo_filename(instance, filename):
from slugify import slugify_filename
return 'photo_uploads/' + slugify_filename(filename)
class Category(models.Model):
title = models.CharField('Наименование', max_length=256, default='')
@ -31,6 +35,8 @@ class Category(models.Model):
parent = models.ForeignKey(
'self', default=None, null=True, blank=True, related_name='childs',
verbose_name='Родительская категория')
hide_products = models.BooleanField('Показывать дочерние категории вместо товаров', default=False)
image = models.ImageField('Картинка', upload_to=photo_filename, default=None, null=True, blank=True)
attributes = models.ManyToManyField(
'Attribute', through='AttributeForCategory')
priority = models.IntegerField('Приоритет', default=0)
@ -271,12 +277,6 @@ class AttributesInProduct(models.Model):
verbose_name_plural = 'атрибуты в товарах'
def photo_filename(instance, filename):
from slugify import slugify_filename
return 'photo_uploads/' + slugify_filename(filename)
class SlugImageField(models.ImageField):
pass

@ -34,7 +34,7 @@ class CategoryBaseView(object):
class CategoryView(CategoryBaseView, TemplateView):
template_name = 'category.jinja'
brand_pks = []
products_qs = None
products_qs = Product.objects.none()
sort = None
is_search = False
is_sale = False
@ -110,7 +110,8 @@ class CategoryView(CategoryBaseView, TemplateView):
retval['brands'] = list(set(map(lambda item: item.brand, self.products_qs)))
else:
self.category = self._get_full_category(kwargs['categories'])
self.products_qs = self.category.get_all_products().order_by('-pk')
if not self.category.hide_products:
self.products_qs = self.category.get_all_products().order_by('-pk')
self.brand_pks = self._get_brand_pks()
self.sort = self._get_sort()

Loading…
Cancel
Save