--- /dev/null
+from mezzanine import template
+from cartridge.shop.models import Product, Category
+
+register = template.Library()
+
+
+@register.as_tag
+def shop_recent_products(limit=5, category=None):
+ """
+ Put a list of recently published products into the template
+ context. A tag title or slug, category title or slug or author's
+ username can also be specified to filter the recent posts returned.
+ Usage::
+ {% blog_recent_posts 5 as recent_posts %}
+ {% blog_recent_posts limit=5 tag="django" as recent_posts %}
+ {% blog_recent_posts limit=5 category="python" as recent_posts %}
+ """
+ products = Product.objects.published()
+ title_or_slug = lambda s: Q(title=s) | Q(slug=s)
+
+ if category is not None:
+ try:
+ category = Category.objects.get(title_or_slug(category))
+ products = products.filter(categories=category)
+ except Category.DoesNotExist:
+ return []
+
+ return list(products[:limit])
<li><a href="http://mezzanine.jupo.org/docs/deployment.html">Deploying to a production server</a></li>
</ul>
{% endblocktrans %}
-<div><!-- Showcase-->
+{% load blog_tags records_tags keyword_tags i18n mezzanine_tags %}
+<div class="col-xs-12 col-md-8"><!-- Showcase-->
+<h2>{% trans "Showcase" %}</h2>
</div><!-- /Showcase -->
-<div><!-- Latest Releases -->
+<div class="col-xs-6 col-md-4"><!-- Latest Releases -->
+{% shop_recent_products 9 as recent_products %}
+{% if recent_products %}
+<h2>{% trans "Latest Releases" %}</h2>
+{% for product in recent_products %}
+ <div class="col-xs-2 col-md-4 product-thumb">
+ <a href="{{ product.get_absolute_url }}" class="thumbnail">
+ {% if product.image %}
+ <img src="{{ MEDIA_URL }}{% thumbnail product.image 148 148 %}">
+ {% else %}
+ <div class="placeholder"></div>
+ {% endif %}
+ <div class="caption">
+ <h6>{{ product }}</h6>
+ </div>
+ </a>
+ </div>
+{% endfor %}
+{% endif %}
</div><!-- /Latest Releases -->
<div><!-- Recent Posts -->
-{% load blog_tags keyword_tags i18n mezzanine_tags %}
{% blog_recent_posts 5 as recent_posts %}
{% if recent_posts %}
<h2>{% trans "Recent Posts" %}</h2>
{% if recent_post.categories %}
{{ recent_post.categories. }}
{% endif %}
-
+
</div><!-- /recent-summary -->
{% endfor %}
{% endif %}