Add top 100 to counters

This commit is contained in:
Skia
2016-09-15 11:07:03 +02:00
parent 6aaeb7cdc9
commit 35d811317c
7 changed files with 100 additions and 3 deletions

View File

@ -152,7 +152,6 @@ td {
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
max-width: 0;
}
td>ul {
margin-top: 0px;
@ -165,7 +164,9 @@ tbody>tr:nth-child(even) {
}
tbody>tr:hover {
background: yellow;
width: 100%;
}
tbody>tr.highlight {
background: orange;
}
.tool-bar {
overflow: auto;

View File

@ -14,6 +14,12 @@
<p>La Gommette: {{ total_gommette_time }}</p>
</div>
{% endif %}
<div>
<h3>{% trans %}Buyings{% endtrans %}</h3>
<p>Foyer: {{ total_foyer_buyings }} €</p>
<p>MDE: {{ total_mde_buyings }} €</p>
<p>La Gommette: {{ total_gommette_buyings }} €</p>
</div>
{% endblock %}

View File

@ -20,6 +20,7 @@ import logging
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm
from core.models import User, SithFile
from subscription.models import Subscription
def login(request):
"""
@ -189,10 +190,17 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
foyer = Counter.objects.filter(name="Foyer").first()
mde = Counter.objects.filter(name="MDE").first()
gommette = Counter.objects.filter(name="La Gommette").first()
semester_start=Subscription.compute_start(d=date.today(), duration=3)
kwargs['total_perm_time'] = sum([p.end-p.start for p in self.object.permanencies.all()], timedelta())
kwargs['total_foyer_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=foyer)], timedelta())
kwargs['total_mde_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=mde)], timedelta())
kwargs['total_gommette_time'] = sum([p.end-p.start for p in self.object.permanencies.filter(counter=gommette)], timedelta())
kwargs['total_foyer_buyings'] = sum([b.unit_price*b.quantity for b in
self.object.customer.buyings.filter(counter=foyer, date__gte=semester_start)])
kwargs['total_mde_buyings'] = sum([b.unit_price*b.quantity for b in self.object.customer.buyings.filter(counter=mde,
date__gte=semester_start)])
kwargs['total_gommette_buyings'] = sum([b.unit_price*b.quantity for b in
self.object.customer.buyings.filter(counter=gommette, date__gte=semester_start)])
return kwargs
class UserMiniView(CanViewMixin, DetailView):