d1194f0500a46fcc43b1de9f8f081c3dc3412945
[redakcja.git] / src / depot / templatetags / depot.py
1 from django.template import Library
2 from depot.models import Shop
3
4
5 register = Library()
6
7
8 @register.simple_tag(takes_context=True)
9 def depot_shops(context, book):
10     shops = []
11     for shop in Shop.objects.all():
12         d = {
13             'shop_id': shop.id,
14             'name': shop.name,
15         }
16         d.update(shop.can_publish(book))
17         d['last'] = shop.get_last(book)
18         d['id'] = getattr(book, shop.shop + '_id')
19         shops.append(d)
20     return shops