Working on dash
parent
9ac53c88f6
commit
4d1e272577
|
@ -7,6 +7,7 @@
|
||||||
-e hg+http://bitbucket.org/dwaiter/django-bcrypt#egg=django-bcrypt
|
-e hg+http://bitbucket.org/dwaiter/django-bcrypt#egg=django-bcrypt
|
||||||
-e hg+ssh://hg@bitbucket.org/nicksergeant/django-registration#egg=django-registration
|
-e hg+ssh://hg@bitbucket.org/nicksergeant/django-registration#egg=django-registration
|
||||||
-e svn+http://django-grappelli.googlecode.com/svn/trunk#egg=django-grappelli
|
-e svn+http://django-grappelli.googlecode.com/svn/trunk#egg=django-grappelli
|
||||||
|
-e svn+http://django-pagination.googlecode.com/svn/trunk#egg=django-pagination
|
||||||
-e hg+https://bitbucket.org/birkenfeld/pygments-main#egg=Pygments
|
-e hg+https://bitbucket.org/birkenfeld/pygments-main#egg=Pygments
|
||||||
|
|
||||||
# Deployment
|
# Deployment
|
||||||
|
|
|
@ -43,6 +43,7 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
|
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
|
||||||
|
'pagination.middleware.PaginationMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
ROOT_URLCONF = 'urls'
|
ROOT_URLCONF = 'urls'
|
||||||
|
@ -62,6 +63,7 @@ INSTALLED_APPS = (
|
||||||
'compressor',
|
'compressor',
|
||||||
'django_bcrypt',
|
'django_bcrypt',
|
||||||
'south',
|
'south',
|
||||||
|
'pagination',
|
||||||
'taggit',
|
'taggit',
|
||||||
'tastypie',
|
'tastypie',
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,34 @@
|
||||||
from annoying.decorators import render_to
|
|
||||||
from snipts.api import PublicSniptResource, PublicTagResource
|
from snipts.api import PublicSniptResource, PublicTagResource
|
||||||
|
from annoying.decorators import render_to
|
||||||
|
from django.db.models import Count
|
||||||
|
from snipts.models import Snipt
|
||||||
|
from taggit.models import Tag
|
||||||
|
|
||||||
@render_to('home.html')
|
@render_to('home.html')
|
||||||
def home(request):
|
def home(request):
|
||||||
|
|
||||||
tr = PublicTagResource()
|
if request.user.is_authenticated():
|
||||||
#tags_queryset = tr.cached_obj_get_list()[:20]
|
return home_user(request)
|
||||||
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()
|
tags = Tag.objects.filter(snipt__public=True)
|
||||||
#snipts_queryset = sr.cached_obj_get_list()[:20]
|
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||||
snipts_queryset = sr.obj_get_list()[:20]
|
tags = tags.order_by('-count')[: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]
|
snipts = Snipt.objects.filter(public=True).order_by('-created')
|
||||||
|
|
||||||
|
return {
|
||||||
|
'snipts': snipts,
|
||||||
|
'tags': tags,
|
||||||
|
}
|
||||||
|
|
||||||
|
@render_to('home.html')
|
||||||
|
def home_user(request):
|
||||||
|
|
||||||
|
tags = Tag.objects.filter(snipt__user=request.user)
|
||||||
|
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||||
|
tags = tags.order_by('-count')[:20]
|
||||||
|
|
||||||
|
snipts = Snipt.objects.filter(public=True).order_by('-created')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'snipts': snipts,
|
'snipts': snipts,
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ tag.data.absolute_url }}">{{ tag.data.name }} ({{ tag.data.count }})</a>
|
<a href="/public/tag/{{ tag.slug }}/">{{ tag.name }} ({{ tag.count }})</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% load pagination_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section class="snipts">
|
<section class="snipts">
|
||||||
|
{% autopaginate snipts 20 %}
|
||||||
{% for snipt in snipts %}
|
{% for snipt in snipts %}
|
||||||
<article class="snipt">
|
<article class="snipt">
|
||||||
{{ snipt.data.title }}
|
{{ snipt.title }}
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% paginate %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue