Initial Import.

This commit is contained in:
2013-03-31 23:15:07 +01:00
commit c19f2f5562
66 changed files with 1780 additions and 0 deletions

32
app/stores/views/misc.py Normal file
View File

@@ -0,0 +1,32 @@
from django.core.cache import cache
from django.views.generic import ListView
from ..models import Chain, Store
class MapView(ListView):
model = Store
template_name_suffix = '_map'
def get_context_data(self, **kwargs):
ctx = super(MapView, self).get_context_data(**kwargs)
stores = cache.get('store_count')
chains = cache.get('chain_count')
if not stores:
stores = Store.objects.filter(active=True).count()
cache.set('store_count', stores, 600)
if not chains:
chains = Chain.objects.filter(active=True).count()
cache.set('chain_count', chains, 600)
ctx.update({
'store_count': stores,
'chain_count': chains,
})
return ctx
def get_queryset(self):
qs = super(MapView, self).get_queryset()
return qs.filter(active=True).select_related('address')