Added content to homepage:
+ Last 12 volumes based on release date + Biggest 5 collectors based on volumes owned
This commit is contained in:
parent
2e105d07a9
commit
a4537ae0e1
|
@ -1,11 +1,26 @@
|
|||
from django.views.generic import View
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response
|
||||
from django.db.models import Count
|
||||
from shelfzilla.apps.users.models import User
|
||||
from shelfzilla.apps.manga.models import Volume
|
||||
|
||||
|
||||
class HomepageView(View):
|
||||
template = 'homepage/home.html'
|
||||
|
||||
def get(self, request):
|
||||
ctx = RequestContext(request, {})
|
||||
data = {}
|
||||
from datetime import datetime
|
||||
# TOP 5
|
||||
data['TOP_5_COLLECTORS'] = User.objects.all()\
|
||||
.annotate(num_volumes=Count('have_volumes'))\
|
||||
.order_by('-num_volumes')[:5]
|
||||
|
||||
# Latest manga added
|
||||
data['LATEST_MANGA_ADDED'] = Volume.objects\
|
||||
.filter(release_date__lte=datetime.now())\
|
||||
.order_by('-release_date')[:12]
|
||||
|
||||
ctx = RequestContext(request, data)
|
||||
return render_to_response(self.template, context_instance=ctx)
|
||||
|
|
|
@ -46,3 +46,18 @@ body {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list-group-item.list-group-users {
|
||||
.avatar {
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.latest-manga {
|
||||
.item {
|
||||
min-height: 100px;
|
||||
|
||||
.content { padding-left: 86px; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,50 @@
|
|||
{% extends '_layout.html'|pjax:request %}
|
||||
{% load i18n thumbnail %}
|
||||
|
||||
{% block content %}asd{% endblock %}
|
||||
{% block main_content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<div class="row">
|
||||
{% for volume in LATEST_MANGA_ADDED %}
|
||||
<div class="col-sm-6 latest-manga">
|
||||
<div class="well text-right item" style="background: white url({% thumbnail volume.cover 80x120 crop %}) top left no-repeat;">
|
||||
<div class="content">
|
||||
<h4 class="media-heading">{{ volume }}</h4>
|
||||
<p>
|
||||
{{ volume.publisher }}<br />
|
||||
{{ volume.release_date }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% if forloop.counter|divisibleby:2 %}
|
||||
</div><div class="row">
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-4">
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans "Biggest collections" %}</h3>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{% for user in TOP_5_COLLECTORS %}
|
||||
<li class="list-group-item list-group-users">
|
||||
<strong>#{{ forloop.counter }}</strong>
|
||||
<img src="{{ user.avatar }}" class="avatar img-rounded"/>
|
||||
{{ user.username }}
|
||||
<span class="pull-right">
|
||||
<i>{% blocktrans with count=user.have_volumes.count %}{{ count }} volumes{% endblocktrans %}</i>
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,13 +10,13 @@ admin.autodiscover()
|
|||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^messages/$', MessagesView.as_view(), name="contrib.messages"),
|
||||
url(r'^$', include('shelfzilla.apps.homepage.urls')),
|
||||
url(r'^', include('shelfzilla.apps.landing.urls')),
|
||||
url(r'^', include('shelfzilla.apps.users.urls')),
|
||||
url(r'^series/', include('shelfzilla.apps.manga.urls.series')),
|
||||
url(r'^volumes/', include('shelfzilla.apps.manga.urls.volumes')),
|
||||
url(r'^publishers/', include('shelfzilla.apps.manga.urls.publishers')),
|
||||
url(r'^search/', include('shelfzilla.apps.manga.urls.search')),
|
||||
url(r'^$', include('shelfzilla.apps.homepage.urls')),
|
||||
url(r'^_admin/', include('shelfzilla.apps._admin.urls')),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
|
Reference in New Issue