forked from DGNum/gestioCOF
Merge branch 'qwann/separate_list'
This commit is contained in:
commit
568a58c52a
2 changed files with 63 additions and 2 deletions
|
@ -7,8 +7,11 @@
|
|||
|
||||
<aside>
|
||||
<div class="heading">
|
||||
{{ articles|length }}
|
||||
<span class="sub">article{{ articles|length|pluralize }}</span>
|
||||
{{ nb_articles }}
|
||||
<span class="sub">article{{ nb_articles|pluralize }}</span>
|
||||
</div>
|
||||
<div class="heading">
|
||||
<span class="sub">dont {{ articles|length }} en vente</span>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
|
@ -25,6 +28,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h2>Article{{ articles|length|pluralize}} en vente</h2>
|
||||
<div class="table-responsive">
|
||||
<table
|
||||
class="table table-hover table-condensed sortable"
|
||||
|
@ -72,4 +76,53 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Article{{ not_sold_articles|length|pluralize }} non vendu{{ nots_sold_article|length|pluralize }}</h2>
|
||||
<div class="table-responsive">
|
||||
<table
|
||||
class="table table-hover table-condensed sortable"
|
||||
{# Initial sort: [(is_sold,desc), (name,asc)] #}
|
||||
data-sortlist="[[3,1], [0,0]]">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Nom</td>
|
||||
<td class="text-right">Prix</td>
|
||||
<td class="text-right">Stock</td>
|
||||
<td class="text-right" data-sorter="article__is_sold">En vente</td>
|
||||
<td class="text-right" data-sorter="article__hidden">Affiché</td>
|
||||
<td class="text-right" data-sorter="shortDate">Dernier inventaire</td>
|
||||
</tr>
|
||||
</thead>
|
||||
{% regroup not_sold_articles by category as not_sold_category_list %}
|
||||
|
||||
{% for category in not_sold_category_list %}
|
||||
<tbody class="tablesorter-no-sort">
|
||||
<tr class="section">
|
||||
<td colspan="6">{{ category.grouper }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
{% for article in category.list %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'kfet.article.read' article.pk %}">
|
||||
{{ article.name }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-right">{{ article.price }}€</td>
|
||||
<td class="text-right">{{ article.stock }}</td>
|
||||
<td class="text-right">{{ article.is_sold | yesno:"En vente,Non vendu"}}</td>
|
||||
<td class="text-right">{{ article.hidden | yesno:"Caché,Affiché" }}</td>
|
||||
{% with last_inventory=article.inventory.0 %}
|
||||
<td class="text-right" title="{{ last_inventory.at }}">
|
||||
{{ last_inventory.at|date:'d/m/Y H:i' }}
|
||||
</td>
|
||||
{% endwith %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -707,6 +707,14 @@ class ArticleList(ListView):
|
|||
template_name = 'kfet/article.html'
|
||||
context_object_name = 'articles'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
articles = context[self.context_object_name]
|
||||
context['nb_articles'] = len(articles)
|
||||
context[self.context_object_name] = articles.filter(is_sold=True)
|
||||
context['not_sold_articles'] = articles.filter(is_sold=False)
|
||||
return context
|
||||
|
||||
|
||||
# Article - Create
|
||||
class ArticleCreate(SuccessMessageMixin, CreateView):
|
||||
|
|
Loading…
Reference in a new issue