mirror of
https://github.com/nanoy42/coope
synced 2024-11-24 12:23:11 +00:00
Improve search and fix keg edition
This commit is contained in:
parent
2167e61c99
commit
4060a22c50
3 changed files with 48 additions and 3 deletions
|
@ -626,7 +626,7 @@ def editKeg(request, pk):
|
|||
keg.demi.name = "Demi " + name
|
||||
keg.demi.save()
|
||||
if(keg.galopin):
|
||||
keg.galopin.deg = deg
|
||||
keg.galopin.deg = keg.deg
|
||||
keg.galopin.amount = ceil(2.5 * pinte_price)/10
|
||||
keg.galopin.name = "Galopin " + name
|
||||
keg.galopin.save()
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
{% if perms.gestion.view_product %}
|
||||
<li><a href="#second">Produits ({{products.count}})</a></li>
|
||||
{% endif %}
|
||||
{% if perms.gestion.view_consumptionhistory %}
|
||||
<li><a href="#secondbis">Dernières transactions ({{last_consumptions.count}})</a></li>
|
||||
{% endif %}
|
||||
{% if perms.gestion.view_keg %}
|
||||
<li><a href="#third">Fûts ({{kegs.count}})</a></li>
|
||||
{% endif %}
|
||||
|
@ -104,6 +107,46 @@
|
|||
</section>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if perms.auth.view_consumptionhistory %}
|
||||
<section id="secondbis" class="main">
|
||||
<header class="major">
|
||||
<h2>Résultats dans les dernières transactions ({{last_consumptions.count}} résultat{% if last_consumptions.count != 1 %}s{% endif %})</h2>
|
||||
</header>
|
||||
<section>
|
||||
{% if last_consumptions.count %}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Produit</th>
|
||||
<th>Quantité</th>
|
||||
<th>Utilisateur</th>
|
||||
<th>Date</th>
|
||||
<th>Type de paiement</th>
|
||||
<th>Administration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for consumption in last_consumptions %}
|
||||
<tr>
|
||||
<td>{{consumption.product}}</td>
|
||||
<td>{{consumption.quantity}}</td>
|
||||
<td>{{consumption.customer}}</td>
|
||||
<td>{{consumption.date}}</td>
|
||||
<td>{{consumption.payment_method}}</td>
|
||||
<td>{% if perms.gestion.delete_consumptionhistory %}<a href="{% url 'gestion:cancelConsumption' consumption.pk %}" class="button small"><i class="fa fa-times"></i> Annuler</a>{% endif %}</td>
|
||||
</tr>
|
||||
{%endfor%}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
Aucun résultat n'a pu être trouvé.
|
||||
{% endif %}
|
||||
</section>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.gestion.view_keg %}
|
||||
<section id="third" class="main">
|
||||
<header class="major">
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.contrib.auth.models import User, Group
|
|||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from coopeV3.acl import active_required
|
||||
from gestion.models import Product, Menu, Keg
|
||||
from gestion.models import Product, Menu, Keg, ConsumptionHistory
|
||||
|
||||
@active_required
|
||||
@login_required
|
||||
|
@ -13,13 +13,15 @@ def search(request):
|
|||
if q:
|
||||
users = User.objects.filter(Q(username__icontains=q) | Q(first_name__icontains=q) | Q(last_name__icontains=q))
|
||||
products = Product.objects.filter(name__icontains=q)
|
||||
last_consumptions = ConsumptionHistory.objects.select_related('product').filter(product__name__icontains=q).order_by('-date')[:10]
|
||||
kegs = Keg.objects.filter(name__icontains=q)
|
||||
menus = Menu.objects.filter(name__icontains=q)
|
||||
groups = Group.objects.filter(name__icontains=q)
|
||||
else:
|
||||
users = User.objects.none()
|
||||
products = Product.objects.none()
|
||||
lats_consumptions = ConsumptionHistory.objects.none()
|
||||
kegs = Keg.objects.none()
|
||||
menus = Menu.objects.none()
|
||||
groups = Group.objects.none()
|
||||
return render(request, "search/search.html", {"q": q, "users": users, "products": products, "kegs": kegs, "menus": menus, "groups": groups})
|
||||
return render(request, "search/search.html", {"q": q, "users": users, "products": products, "last_consumptions": last_consumptions, "kegs": kegs, "menus": menus, "groups": groups})
|
||||
|
|
Loading…
Reference in a new issue