Adding breadcrumbs

This commit is contained in:
Víðir Valberg Guðmundsson 2016-05-30 20:56:03 +02:00
parent 55fccf54fe
commit 8737c2f8ad
5 changed files with 58 additions and 16 deletions

View file

@ -105,3 +105,7 @@ footer {
bottom: 0px;
padding: 5px;
}
.breadcrumb > li.pull-right::before {
content: "";
}

View file

@ -3,23 +3,52 @@
{% block shop_content %}
<h2>{{ product.name }}</h2>
<div class="col-md-8">
<p>
<div class="row">
<h2>{{ product.name }}</h2>
</div>
<div class="row">
<p>
{{ product.description }}
</p>
</p>
</div>
{% if user.is_authenticated %}
<form method="POST">
</div>
<div class="col-md-4">
<h3>Add to order</h3>
{% if user.is_authenticated %}
{% if product.is_available %}
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %}
</form>
{% else %}
</form>
{% else %}
<p>
This product is available from
{{ product.available_in.lower|date:"Y-m-d H:i" }}
</p>
{% endif %}
{% else %}
<a href="{% url 'account_signup' %}?next={% url 'shop:product_detail' slug=product.slug %}">
Signup</a> or
<a href="{% url 'account_login' %}?next={% url 'shop:product_detail' slug=product.slug %}">
login</a>
to order this product
{% endif %}
{% endblock %}
to order this product
{% endif %}
{% endblock %}
</div>

View file

@ -4,15 +4,23 @@
<div class="row">
<div class="col-md-12">
<div class="pull-right">
{% if user.is_authenticated and user.orders.exists %}
<a href="{% url 'shop:order_list' %}" class="btn btn-grey">Previous orders</a>
<ol class="breadcrumb">
<li><a href="{% url 'shop:index' %}">Shop</a></li>
{% if product %}
<li><a href="{% url 'shop:index' %}?category={{product.category.slug}}">{{ product.category }}</a></li>
<li class="active">{{ product.name }}</li>
{% elif current_category %}
<li class="active">{{ current_category }}</li>
{% endif %}
</div>
{% if user.is_authenticated and user.orders.exists %}
<li class="pull-right"><a href="{% url 'shop:order_list' %}">Previous orders</a></li>
{% endif %}
</ol>
</div>
</div>
{% block shop_content %}
{% endblock %}
{% endblock %}

View file

@ -3,13 +3,14 @@
{% load shop_tags %}
{% block shop_content %}
<div class="row">
<div class="col-md-12">
<p>
Categories:<br />
{% for category in categories %}
<a href="{% url 'shop:index' %}?category={{category.slug}}"
class="label label-{% if category.slug == current_category %}primary{% else %}default{% endif %}">
class="label label-{% if category.slug == current_category.slug %}primary{% else %}default{% endif %}">
{{category}}
</a>&nbsp;
{% endfor %}

View file

@ -110,7 +110,7 @@ class ShopIndexView(ListView):
context['products'] = context['products'].filter(
category__slug=category
)
context['current_category'] = category
context['current_category'] = categoryobj
context['categories'] = ProductCategory.objects.annotate(
num_products=Count('products')
).filter(