Added Stats to homepage
This commit is contained in:
parent
e879746e94
commit
2262064136
|
@ -3,7 +3,7 @@ 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
|
||||
from shelfzilla.apps.manga.models import Volume, Series
|
||||
|
||||
|
||||
class HomepageView(View):
|
||||
|
@ -27,6 +27,14 @@ class HomepageView(View):
|
|||
.filter(release_date__gt=datetime.now())\
|
||||
.order_by('release_date')[:6]
|
||||
|
||||
# Stats
|
||||
data['STATS'] = {
|
||||
'users': User.objects.count() - 1,
|
||||
'series': Series.objects.count(),
|
||||
'series_review': Series.objects.filter(for_review=True).count(),
|
||||
'volumes': Volume.objects.count(),
|
||||
'volumes_review': Volume.objects.filter(for_review=True).count(),
|
||||
}
|
||||
|
||||
ctx = RequestContext(request, data)
|
||||
return render_to_response(self.template, context_instance=ctx)
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
</div>
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-4">
|
||||
<!-- WIDGETS -->
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans "Biggest collections" %}</h3>
|
||||
|
@ -78,6 +79,27 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans "Stats" %}</h3>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{% if STATS.users > 100 %}
|
||||
<li class="list-group-item ">
|
||||
{% trans "Users" %} <span class="pull-right badge badge-success">{{ STATS.users }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="list-group-item ">
|
||||
{% trans "Series" %} <span class="pull-right badge badge-success">{{ STATS.series }}</span>
|
||||
</li>
|
||||
<li class="list-group-item ">
|
||||
{% trans "Volumes" %} <span class="pull-right badge badge-success">{{ STATS.volumes }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in New Issue