2012-04-06 02:48:54 +04:00
|
|
|
import jingo
|
|
|
|
|
2012-08-11 03:29:54 +04:00
|
|
|
import mkt
|
2012-08-14 05:24:22 +04:00
|
|
|
from constants.applications import DEVICE_MOBILE
|
2012-04-08 04:27:18 +04:00
|
|
|
from mkt.webapps.models import Webapp
|
2012-04-06 02:48:54 +04:00
|
|
|
|
2012-04-11 12:29:56 +04:00
|
|
|
|
2012-08-14 05:24:22 +04:00
|
|
|
def _add_mobile_filter(request, qs):
|
|
|
|
if request.MOBILE:
|
2012-08-16 00:45:51 +04:00
|
|
|
qs = qs.filter(device=DEVICE_MOBILE.id,
|
|
|
|
uses_flash=False)
|
2012-08-14 05:24:22 +04:00
|
|
|
return qs
|
|
|
|
|
|
|
|
|
2012-05-28 06:46:54 +04:00
|
|
|
# TODO: Cache this soooo hard.
|
2012-04-06 02:48:54 +04:00
|
|
|
def home(request):
|
|
|
|
"""The home page."""
|
2012-04-25 06:22:59 +04:00
|
|
|
if not getattr(request, 'can_view_consumer', True):
|
2012-04-26 23:04:57 +04:00
|
|
|
return jingo.render(request, 'home/home_walled.html')
|
2012-08-08 23:46:06 +04:00
|
|
|
region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
|
2012-07-19 03:54:23 +04:00
|
|
|
featured = Webapp.featured(region=region, cat=None)[:9]
|
2012-08-15 01:43:23 +04:00
|
|
|
popular = _add_mobile_filter(request, Webapp.popular(region=region))[:10]
|
|
|
|
latest = _add_mobile_filter(request, Webapp.latest(region=region))[:10]
|
2012-04-13 00:55:12 +04:00
|
|
|
return jingo.render(request, 'home/home.html', {
|
|
|
|
'featured': featured,
|
|
|
|
})
|