Better scale management for order creation

+ Extends labels formatting of scale.
This commit is contained in:
Aurélien Delobelle 2017-05-19 17:40:06 +02:00
parent c11c3f84ed
commit c0b8430a12
5 changed files with 14 additions and 8 deletions

View file

@ -86,7 +86,10 @@ class Scale(object):
def get_labels(self, label_fmt=None): def get_labels(self, label_fmt=None):
if label_fmt is None: if label_fmt is None:
label_fmt = self.label_fmt label_fmt = self.label_fmt
return [begin.strftime(label_fmt) for begin, end in self] return [
begin.strftime(label_fmt.format(i=i, rev_i=len(self)-i))
for i, (begin, end) in enumerate(self)
]
def chunkify_qs(self, qs, field=None): def chunkify_qs(self, qs, field=None):
if field is None: if field is None:

View file

@ -1,3 +1,5 @@
{% load kfet_tags %}
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-8 col-md-offset-2 nopadding"> <div class="col-sm-12 col-md-8 col-md-offset-2 nopadding">
{% include "kfet/base_messages.html" %} {% include "kfet/base_messages.html" %}

View file

@ -17,7 +17,7 @@
{% include 'kfet/base_messages.html' %} {% include 'kfet/base_messages.html' %}
<div class="content-center"> <div class="content-center">
<form id='inventoryform' action="" method="post"> <form id='inventoryform' action="" method="post">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-condensed text-center"> <table class="table table-condensed text-center">
<thead> <thead>
<tr> <tr>
@ -77,7 +77,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
{{ formset.management_form }} {{ formset.management_form }}
{% if not perms.kfet.add_inventory %} {% if not perms.kfet.add_inventory %}
<div class='auth-form form-horizontal'> <div class='auth-form form-horizontal'>

View file

@ -36,11 +36,9 @@
<td rowspan="2">Commande</td> <td rowspan="2">Commande</td>
</tr> </tr>
<tr> <tr>
<td>S1</td> {% for label in scale.get_labels %}
<td>S2</td> <td>{{ label }}</td>
<td>S3</td> {% endfor %}
<td>S4</td>
<td>S5</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -1910,9 +1910,12 @@ def order_create(request, pk):
else: else:
formset = cls_formset(initial=initial) formset = cls_formset(initial=initial)
scale.label_fmt = "S-{rev_i}"
return render(request, 'kfet/order_create.html', { return render(request, 'kfet/order_create.html', {
'supplier': supplier, 'supplier': supplier,
'formset': formset, 'formset': formset,
'scale': scale,
}) })