Don't show non-active products. Also don't show categories which doesn't have any active products.
This commit is contained in:
parent
77422417ec
commit
029ec74389
|
@ -49,7 +49,7 @@ Shop | {{ block.super }}
|
|||
</tr>
|
||||
{% endifchanged %}
|
||||
|
||||
<tr {% if not product.is_available %}class="text-muted"{% endif %}>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'shop:product_detail' slug=product.slug %}">
|
||||
{{ product.name }}
|
||||
|
@ -61,6 +61,12 @@ Shop | {{ block.super }}
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
Sorry no products found.
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -171,7 +171,7 @@ class ShopIndexView(ListView):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super(ShopIndexView, self).get_queryset()
|
||||
return queryset.order_by('category__name', 'price', 'name')
|
||||
return queryset.available().order_by('category__name', 'price', 'name')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ShopIndexView, self).get_context_data(**kwargs)
|
||||
|
@ -197,6 +197,7 @@ class ShopIndexView(ListView):
|
|||
).filter(
|
||||
num_products__gt=0,
|
||||
public=True,
|
||||
products__available_in__contains=timezone.now()
|
||||
)
|
||||
return context
|
||||
|
||||
|
|
Loading…
Reference in a new issue