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; bottom: 0px;
padding: 5px; padding: 5px;
} }
.breadcrumb > li.pull-right::before {
content: "";
}

View file

@ -3,23 +3,52 @@
{% block shop_content %} {% 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 }} {{ product.description }}
</p> </p>
</div>
{% if user.is_authenticated %} </div>
<form method="POST">
<div class="col-md-4">
<h3>Add to order</h3>
{% if user.is_authenticated %}
{% if product.is_available %}
<form method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
{% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %} {% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %}
</form> </form>
{% else %}
{% 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 %}"> <a href="{% url 'account_signup' %}?next={% url 'shop:product_detail' slug=product.slug %}">
Signup</a> or Signup</a> or
<a href="{% url 'account_login' %}?next={% url 'shop:product_detail' slug=product.slug %}"> <a href="{% url 'account_login' %}?next={% url 'shop:product_detail' slug=product.slug %}">
login</a> login</a>
to order this product to order this product
{% endif %} {% endif %}
{% endblock %} {% endblock %}
</div>

View file

@ -4,15 +4,23 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="pull-right"> <ol class="breadcrumb">
{% if user.is_authenticated and user.orders.exists %} <li><a href="{% url 'shop:index' %}">Shop</a></li>
<a href="{% url 'shop:order_list' %}" class="btn btn-grey">Previous orders</a> {% 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 %} {% 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>
</div> </div>
{% block shop_content %} {% block shop_content %}
{% endblock %} {% endblock %}
{% endblock %} {% endblock %}

View file

@ -3,13 +3,14 @@
{% load shop_tags %} {% load shop_tags %}
{% block shop_content %} {% block shop_content %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<p> <p>
Categories:<br /> Categories:<br />
{% for category in categories %} {% for category in categories %}
<a href="{% url 'shop:index' %}?category={{category.slug}}" <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}} {{category}}
</a>&nbsp; </a>&nbsp;
{% endfor %} {% endfor %}

View file

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