Working on home view'

master
Nick Sergeant 2011-10-11 00:13:18 -04:00
parent 88776e0d97
commit 9ac53c88f6
4 changed files with 31 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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,
}

View File

@ -1,4 +1,11 @@
{% extends "base.html" %}
{% block content %}
<section class="snipts">
{% for snipt in snipts %}
<article class="snipt">
{{ snipt.data.title }}
</article>
{% endfor %}
</section>
{% endblock %}