snipt/snipts/views.py

23 lines
790 B
Python
Raw Normal View History

2011-10-10 20:30:56 -07:00
from annoying.decorators import render_to
2011-10-10 21:13:18 -07:00
from snipts.api import PublicSniptResource, PublicTagResource
2011-10-10 20:30:56 -07:00
@render_to('home.html')
def home(request):
2011-10-10 21:13:18 -07:00
2011-10-10 20:30:56 -07:00
tr = PublicTagResource()
2011-10-10 21:13:18 -07:00
#tags_queryset = tr.cached_obj_get_list()[:20]
tags_queryset = tr.obj_get_list()[:20]
2011-10-10 20:30:56 -07:00
tags_bundles = (tr.build_bundle(request=request, obj=tag) for tag in tags_queryset)
tags = [tr.full_dehydrate(bundle) for bundle in tags_bundles]
2011-10-10 21:13:18 -07:00
sr = PublicSniptResource()
#snipts_queryset = sr.cached_obj_get_list()[:20]
snipts_queryset = sr.obj_get_list()[:20]
snipts_bundles = (sr.build_bundle(request=request, obj=snipt) for snipt in snipts_queryset)
snipts = [sr.full_dehydrate(bundle) for bundle in snipts_bundles]
2011-10-10 20:30:56 -07:00
return {
2011-10-10 21:13:18 -07:00
'snipts': snipts,
'tags': tags,
2011-10-10 20:30:56 -07:00
}