Liste articles
This commit is contained in:
parent
925f233e3f
commit
8a14643ad4
2 changed files with 60 additions and 11 deletions
|
@ -6,17 +6,62 @@
|
|||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="btn-group btn-group-lg">
|
||||
<a class="btn btn-primary" href="{% url 'kfet.article.create' %}">Créer un article</a>
|
||||
<div class="col-sm-4 col-md-3 col-content-left">
|
||||
<div class="content-left">
|
||||
<div class="content-left-top">
|
||||
<div class="line line-big">{{ articles|length }}</div>
|
||||
<div class="line line-bigsub">article{{ articles|length|pluralize }}</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a class="btn btn-primary btn-lg" href="{% url 'kfet.article.create' %}">
|
||||
Nouvel article
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-9 col-content-right">
|
||||
{% include 'kfet/base_messages.html' %}
|
||||
<div class="content-right">
|
||||
<div class="content-right-block">
|
||||
<h2>Liste des articles</h2>
|
||||
<div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>Nom</td>
|
||||
<td>Prix</td>
|
||||
<td>Stock</td>
|
||||
<td>En vente</td>
|
||||
<td>Dernier inventaire</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for article in articles %}
|
||||
{% ifchanged article.category %}
|
||||
<tr>
|
||||
<td colspan="6">{{ article.category.name }}</td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'kfet.article.read' article.pk %}">
|
||||
<span class="glyphicon glyphicon-cog"></span>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ article.name }}</td>
|
||||
<td>{{ article.price }}</td>
|
||||
<td>{{ article.stock }}</td>
|
||||
<td>{{ article.is_sold }}</td>
|
||||
<td>{{ article.inventory.0.at }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
{% for article in articles %}
|
||||
<li><a href="{% url 'kfet.article.read' article.pk %}">{{ article }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -542,8 +542,12 @@ class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
|||
# Article - General
|
||||
|
||||
class ArticleList(ListView):
|
||||
model = Article
|
||||
queryset = Article.objects.order_by('category', '-is_sold', 'name')
|
||||
queryset = (Article.objects
|
||||
.select_related('category')
|
||||
.prefetch_related(Prefetch('inventories',
|
||||
queryset = Inventory.objects.order_by('-at'),
|
||||
to_attr = 'inventory'))
|
||||
.order_by('category', '-is_sold', 'name'))
|
||||
template_name = 'kfet/article.html'
|
||||
context_object_name = 'articles'
|
||||
|
||||
|
|
Loading…
Reference in a new issue