diff --git a/stroyprombeton/context/catalog.py b/stroyprombeton/context/catalog.py
index 0e59bb58..ec5fa92e 100644
--- a/stroyprombeton/context/catalog.py
+++ b/stroyprombeton/context/catalog.py
@@ -8,6 +8,7 @@
from functools import partial
+from django import http
from django.conf import settings
from django.shortcuts import get_object_or_404
@@ -82,6 +83,9 @@ def context(self) -> typing.ContextDict:
tags = FilteredTags(stb_models.Tag.objects.all(), self.request_data)
options_ = options.Filtered(self.category, tags.qs(), self.request_data)
+ if not options_.qs():
+ raise http.Http404('
В категории нет изделий
BeautifulSoup:
diff --git a/stroyprombeton/views/catalog.py b/stroyprombeton/views/catalog.py
index 9825a39e..e0e7531e 100644
--- a/stroyprombeton/views/catalog.py
+++ b/stroyprombeton/views/catalog.py
@@ -1,7 +1,7 @@
from csv import writer as CSVWriter
+from django import http
from django.conf import settings
-from django.http import HttpResponseBadRequest, StreamingHttpResponse
from django.shortcuts import get_object_or_404, render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
@@ -24,7 +24,7 @@ def fetch_products(request):
# @todo #451:60m Create middleware to for http errors. se2
# Middleware should transform http exceptions to http errors errors.
except exception.Http400 as e:
- return HttpResponseBadRequest(str(e))
+ return http.HttpResponseBadRequest(str(e))
return render(request, 'catalog/options.html', context_.context())
@@ -57,7 +57,7 @@ def serialize_categories(categories):
models.CategoryPage.objects.active()
)
- response = StreamingHttpResponse(
+ response = http.StreamingHttpResponse(
(writer.writerow(c) for c in categories),
content_type="text/csv",
)
@@ -205,12 +205,20 @@ def series_matrix(request, page='series'):
def series(request, series_slug: str):
series = get_object_or_404(models.Series.objects, slug=series_slug)
-
+ options = series.options.active()
+ # @todo #619:60m Prevent code doubling in series views.
+ # Now series and series_matrix have doubled code.
+ # Possible solutions:
+ # - Use only one view for series and series+category. As category page does
+ # - Use view context system. Category view does it too.
+ # Those solutions don't except each other.
+ if not options:
+ raise http.Http404('В секции нет изделий
В секции нет изделий
+ Марка |
{% for group in tag_groups %}
{{ group.name }} |
{% endfor %}
@@ -66,6 +67,7 @@
{% for option in product.options.all %}
+ {{ option.mark }} |
{% for group in tag_groups %}
{% get_tag_name group option %}
diff --git a/templates/search/items_list.html b/templates/search/items_list.html
index fa1e8221..f083d3b5 100644
--- a/templates/search/items_list.html
+++ b/templates/search/items_list.html
@@ -15,7 +15,7 @@
|
- {{ item.catalog_name }}
+ {{ item.name }}
|
{% if item|hasattr_:'price' %}