From 9ac53c88f6fb6b4125de8f6e7de59a899b1475a9 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Tue, 11 Oct 2011 00:13:18 -0400 Subject: [PATCH] Working on home view' --- media/css/style.less | 12 +++++++++++- snipts/api.py | 2 +- snipts/views.py | 15 ++++++++++++--- templates/home.html | 7 +++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/media/css/style.less b/media/css/style.less index ac16967..4a87086 100644 --- a/media/css/style.less +++ b/media/css/style.less @@ -271,10 +271,15 @@ section.main { padding-left: 22px; a { - border-bottom: 1px solid #C5C5C6; + border-bottom: 1px solid #999; color: #999; font: bold 12px @Helvetica; text-decoration: none; + + &:hover { + border-bottom: 1px solid #333; + color: #333; + } } &.twitter { background: transparent url('/media/images/twitter-icon.png') 4px center no-repeat; @@ -289,6 +294,11 @@ section.main { } } } + section.snipts { + article.snipt { + margin: 20px; + } + } } // Utils diff --git a/snipts/api.py b/snipts/api.py index 3fd7130..08da498 100644 --- a/snipts/api.py +++ b/snipts/api.py @@ -33,7 +33,7 @@ class PublicTagResource(ModelResource): def dehydrate(self, bundle): bundle.data['absolute_url'] = '/public/tag/%s/' % bundle.obj.slug - #bundle.data['snipts'] = '/api/public/snipt/?tag=%d' % bundle.obj.id + bundle.data['snipts'] = '/api/public/snipt/?tag=%d' % bundle.obj.id bundle.data['count'] = bundle.obj.taggit_taggeditem_items.filter( snipt__public=True).count() return bundle diff --git a/snipts/views.py b/snipts/views.py index 678fb0d..d2c0898 100644 --- a/snipts/views.py +++ b/snipts/views.py @@ -1,13 +1,22 @@ from annoying.decorators import render_to -from snipts.api import PublicTagResource +from snipts.api import PublicSniptResource, PublicTagResource @render_to('home.html') def home(request): + tr = PublicTagResource() - tags_queryset = tr.cached_obj_get_list()[:20] + #tags_queryset = tr.cached_obj_get_list()[:20] + tags_queryset = tr.obj_get_list()[:20] tags_bundles = (tr.build_bundle(request=request, obj=tag) for tag in tags_queryset) tags = [tr.full_dehydrate(bundle) for bundle in tags_bundles] + 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] + return { - 'tags': tags + 'snipts': snipts, + 'tags': tags, } diff --git a/templates/home.html b/templates/home.html index e48212a..3537a5c 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,4 +1,11 @@ {% extends "base.html" %} {% block content %} +
+ {% for snipt in snipts %} +
+ {{ snipt.data.title }} +
+ {% endfor %} +
{% endblock %}