diff --git a/shelfzilla/apps/homepage/views.py b/shelfzilla/apps/homepage/views.py index 0bca071..564a0c0 100644 --- a/shelfzilla/apps/homepage/views.py +++ b/shelfzilla/apps/homepage/views.py @@ -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) diff --git a/shelfzilla/themes/bootflat/static/less/layout.less b/shelfzilla/themes/bootflat/static/less/layout.less index 14220b9..a376914 100644 --- a/shelfzilla/themes/bootflat/static/less/layout.less +++ b/shelfzilla/themes/bootflat/static/less/layout.less @@ -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; } + } +} diff --git a/shelfzilla/themes/bootflat/templates/homepage/home.html b/shelfzilla/themes/bootflat/templates/homepage/home.html index b22ae2c..c11f7d6 100644 --- a/shelfzilla/themes/bootflat/templates/homepage/home.html +++ b/shelfzilla/themes/bootflat/templates/homepage/home.html @@ -1,3 +1,50 @@ {% extends '_layout.html'|pjax:request %} +{% load i18n thumbnail %} -{% block content %}asd{% endblock %} +{% block main_content %} +
+
+
+
+ {% for volume in LATEST_MANGA_ADDED %} +
+
+
+

{{ volume }}

+

+ {{ volume.publisher }}
+ {{ volume.release_date }} +

+
+
+
+
+ {% if forloop.counter|divisibleby:2 %} +
+ {% endif %} + {% endfor %} +
+
+
+
+
+
+

{% trans "Biggest collections" %}

+
+
    + {% for user in TOP_5_COLLECTORS %} +
  • + #{{ forloop.counter }} + + {{ user.username }} + + {% blocktrans with count=user.have_volumes.count %}{{ count }} volumes{% endblocktrans %} + +
  • + {% endfor %} +
+
+
+
+
+{% endblock %} diff --git a/shelfzilla/urls.py b/shelfzilla/urls.py index 0c0e981..6efc1a6 100644 --- a/shelfzilla/urls.py +++ b/shelfzilla/urls.py @@ -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)), )