{% extends "shop/base.html" %}
{% load thumbnail %}
{% load i18n %}
{% block pagename %}{{ brand.name }}{% endblock %}

{% block extra-head %}
{% if category.meta %}
    <meta name="description" content="{{brand.name}}">
{% endif %}
{% endblock %}

{% block navbar %}
<li><a href="{{shop_base}}">{% trans 'Home' %}</a></li>
{% if brand.brand %}<li><a href="{{ brand.brand.get_absolute_url }}">{{ brand.brand.translation.name }}</a></li>{% endif %}
<li>{{ brand.translation.name }}</li>
{% endblock %}

{% block content %}
{% with brand.translation as translated %}
<div id="product_category" class="brand">
	<div class="brand_description">
		<h3>{{ translated.name }}</h3>
	    {% if translated.picture %}
        {% thumbnail translated.picture 85x85 as image %}
        <a href="{{ brand.get_absolute_url }}"><img src="{{ image }}" width="{{ image.width }}" height="{{ image.height }}" alt="{{ translated.name }}" /></a>
	    {% endif %}
		{% if translated.description %}
		<div class="description">
			{{ translated.description|safe }}
        </div>
		{% endif %}
		{% if user.is_staff or user.is_superuser %}
            <p><a href="/admin/brand/brand/{{ brand.id }}/">Edit this brand</a></p>
        {% endif %}
	</div>

    {% if brand.has_content %}
    	{% if brand.has_products %}
		<div class="brandproducts">
		{% for product in products %} 
			<div class="productImage{% if forloop.first %} first{% endif %}">	
            {% thumbnail product.main_image.picture 85x85 as image %}
            <a href="{{ product.get_absolute_url }}"><img src="{{ image }}" width="{{ image.width }}" height="{{ image.height }}" /></a>
				<br/>
		        <a href="{{ product.get_absolute_url }}">{{ product.translated_name }}</a>
	         </div>
	    {% endfor %}
		</div>
		{% endif %}

		{% if brand.has_categories %}
		<div class="brandcategories">
			<h4>{% trans 'View more products in these categories' %}</h4>
      	    {% for cat in brand.active_categories %}{% with cat.translation as translatedcat %}
			<div class="brandImage">
            {% thumbnail translatedcat.picture 85x85 as image %}
            <a href="{{ cat.get_absolute_url }}"><img src="{{ image }}" width="{{ image.width }}" height="{{ image.height }}" /
				<br/>
            	<a href="{{ cat.get_absolute_url }}">{{ translatedcat.name }}</a>
			</div>
	        {% endwith %}{% endfor %}
		</div>
		{% endif %}
	{% endif %}
	{% if sale %}
	{% include "product/some_discount_eligible.html" %}
	{% endif %}
</div>
{% endwith %}
{% endblock %}
