Merge branch 'Aufinal/kfet_forms' into 'master'

K-Fêt
- Affichage des formulaires amélioré

See merge request !203
This commit is contained in:
Aurélien Delobelle 2017-04-03 13:40:41 +02:00
commit b157ffac4c
10 changed files with 132 additions and 80 deletions

View file

@ -74,8 +74,11 @@ class AccountRestrictForm(AccountForm):
class AccountPwdForm(forms.Form): class AccountPwdForm(forms.Form):
pwd1 = forms.CharField( pwd1 = forms.CharField(
label="Mot de passe K-Fêt",
help_text="Le mot de passe doit contenir au moins huit caractères",
widget=forms.PasswordInput) widget=forms.PasswordInput)
pwd2 = forms.CharField( pwd2 = forms.CharField(
label="Confirmer le mot de passe",
widget=forms.PasswordInput) widget=forms.PasswordInput)
def clean(self): def clean(self):
@ -128,6 +131,7 @@ class UserRestrictTeamForm(UserForm):
class UserGroupForm(forms.ModelForm): class UserGroupForm(forms.ModelForm):
groups = forms.ModelMultipleChoiceField( groups = forms.ModelMultipleChoiceField(
Group.objects.filter(name__icontains='K-Fêt'), Group.objects.filter(name__icontains='K-Fêt'),
label='Statut équipe',
required=False) required=False)
def clean_groups(self): def clean_groups(self):
@ -235,16 +239,20 @@ class CheckoutStatementUpdateForm(forms.ModelForm):
class ArticleForm(forms.ModelForm): class ArticleForm(forms.ModelForm):
category_new = forms.CharField( category_new = forms.CharField(
label="Créer une catégorie",
max_length=45, max_length=45,
required = False) required = False)
category = forms.ModelChoiceField( category = forms.ModelChoiceField(
label="Catégorie",
queryset = ArticleCategory.objects.all(), queryset = ArticleCategory.objects.all(),
required = False) required = False)
suppliers = forms.ModelMultipleChoiceField( suppliers = forms.ModelMultipleChoiceField(
label="Fournisseurs",
queryset = Supplier.objects.all(), queryset = Supplier.objects.all(),
required = False) required = False)
supplier_new = forms.CharField( supplier_new = forms.CharField(
label="Créer un fournisseur",
max_length = 45, max_length = 45,
required = False) required = False)
@ -478,9 +486,7 @@ class OrderArticleForm(forms.Form):
queryset=Article.objects.all(), queryset=Article.objects.all(),
widget=forms.HiddenInput(), widget=forms.HiddenInput(),
) )
quantity_ordered = forms.IntegerField( quantity_ordered = forms.IntegerField(required=False)
required=False,
widget=forms.NumberInput(attrs={'class': 'form-control'}))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(OrderArticleForm, self).__init__(*args, **kwargs) super(OrderArticleForm, self).__init__(*args, **kwargs)
@ -507,18 +513,14 @@ class OrderArticleToInventoryForm(forms.Form):
) )
price_HT = forms.DecimalField( price_HT = forms.DecimalField(
max_digits = 7, decimal_places = 4, max_digits = 7, decimal_places = 4,
required = False, required = False)
widget=forms.NumberInput(attrs={'class': 'form-control'}))
TVA = forms.DecimalField( TVA = forms.DecimalField(
max_digits = 7, decimal_places = 2, max_digits = 7, decimal_places = 2,
required = False, required = False)
widget=forms.NumberInput(attrs={'class': 'form-control'}))
rights = forms.DecimalField( rights = forms.DecimalField(
max_digits = 7, decimal_places = 4, max_digits = 7, decimal_places = 4,
required = False, required = False)
widget=forms.NumberInput(attrs={'class': 'form-control'})) quantity_received = forms.IntegerField()
quantity_received = forms.IntegerField(
widget=forms.NumberInput(attrs={'class': 'form-control'}))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(OrderArticleToInventoryForm, self).__init__(*args, **kwargs) super(OrderArticleToInventoryForm, self).__init__(*args, **kwargs)

View file

@ -40,7 +40,7 @@ class Account(models.Model):
balance = models.DecimalField( balance = models.DecimalField(
max_digits = 6, decimal_places = 2, max_digits = 6, decimal_places = 2,
default = 0) default = 0)
is_frozen = models.BooleanField(default = False) is_frozen = models.BooleanField("est gelé", default = False)
created_at = models.DateTimeField(auto_now_add = True, null = True) created_at = models.DateTimeField(auto_now_add = True, null = True)
# Optional # Optional
PROMO_CHOICES = [(r,r) for r in range(1980, date.today().year+1)] PROMO_CHOICES = [(r,r) for r in range(1980, date.today().year+1)]
@ -48,6 +48,7 @@ class Account(models.Model):
choices = PROMO_CHOICES, choices = PROMO_CHOICES,
blank = True, null = True, default = default_promo()) blank = True, null = True, default = default_promo())
nickname = models.CharField( nickname = models.CharField(
"surnom(s)",
max_length = 255, max_length = 255,
blank = True, default = "") blank = True, default = "")
password = models.CharField( password = models.CharField(
@ -224,14 +225,18 @@ class AccountNegative(models.Model):
start = models.DateTimeField( start = models.DateTimeField(
blank = True, null = True, default = None) blank = True, null = True, default = None)
balance_offset = models.DecimalField( balance_offset = models.DecimalField(
"décalage de balance",
help_text="Montant non compris dans l'autorisation de négatif",
max_digits = 6, decimal_places = 2, max_digits = 6, decimal_places = 2,
blank = True, null = True, default = None) blank = True, null = True, default = None)
authz_overdraft_amount = models.DecimalField( authz_overdraft_amount = models.DecimalField(
"négatif autorisé",
max_digits = 6, decimal_places = 2, max_digits = 6, decimal_places = 2,
blank = True, null = True, default = None) blank = True, null = True, default = None)
authz_overdraft_until = models.DateTimeField( authz_overdraft_until = models.DateTimeField(
"expiration du négatif",
blank = True, null = True, default = None) blank = True, null = True, default = None)
comment = models.CharField(max_length = 255, blank = True) comment = models.CharField("commentaire", max_length = 255, blank = True)
@python_2_unicode_compatible @python_2_unicode_compatible
class Checkout(models.Model): class Checkout(models.Model):
@ -273,29 +278,35 @@ class CheckoutStatement(models.Model):
checkout = models.ForeignKey( checkout = models.ForeignKey(
Checkout, on_delete = models.PROTECT, Checkout, on_delete = models.PROTECT,
related_name = "statements") related_name = "statements")
balance_old = models.DecimalField(max_digits = 6, decimal_places = 2) balance_old = models.DecimalField("ancienne balance",
balance_new = models.DecimalField(max_digits = 6, decimal_places = 2) max_digits = 6, decimal_places = 2)
amount_taken = models.DecimalField(max_digits = 6, decimal_places = 2) balance_new = models.DecimalField("nouvelle balance",
amount_error = models.DecimalField(max_digits = 6, decimal_places = 2) max_digits = 6, decimal_places = 2)
amount_taken = models.DecimalField("montant pris",
max_digits = 6, decimal_places = 2)
amount_error = models.DecimalField("montant de l'erreur",
max_digits = 6, decimal_places = 2)
at = models.DateTimeField(auto_now_add = True) at = models.DateTimeField(auto_now_add = True)
not_count = models.BooleanField(default=False) not_count = models.BooleanField("caisse non comptée", default=False)
taken_001 = models.PositiveSmallIntegerField(default=0) taken_001 = models.PositiveSmallIntegerField("pièces de 1¢", default=0)
taken_002 = models.PositiveSmallIntegerField(default=0) taken_002 = models.PositiveSmallIntegerField("pièces de 2¢", default=0)
taken_005 = models.PositiveSmallIntegerField(default=0) taken_005 = models.PositiveSmallIntegerField("pièces de 5¢", default=0)
taken_01 = models.PositiveSmallIntegerField(default=0) taken_01 = models.PositiveSmallIntegerField("pièces de 10¢", default=0)
taken_02 = models.PositiveSmallIntegerField(default=0) taken_02 = models.PositiveSmallIntegerField("pièces de 20¢", default=0)
taken_05 = models.PositiveSmallIntegerField(default=0) taken_05 = models.PositiveSmallIntegerField("pièces de 50¢", default=0)
taken_1 = models.PositiveSmallIntegerField(default=0) taken_1 = models.PositiveSmallIntegerField("pièces de 1€", default=0)
taken_2 = models.PositiveSmallIntegerField(default=0) taken_2 = models.PositiveSmallIntegerField("pièces de 2€", default=0)
taken_5 = models.PositiveSmallIntegerField(default=0) taken_5 = models.PositiveSmallIntegerField("billets de 5€", default=0)
taken_10 = models.PositiveSmallIntegerField(default=0) taken_10 = models.PositiveSmallIntegerField("billets de 10€", default=0)
taken_20 = models.PositiveSmallIntegerField(default=0) taken_20 = models.PositiveSmallIntegerField("billets de 20€", default=0)
taken_50 = models.PositiveSmallIntegerField(default=0) taken_50 = models.PositiveSmallIntegerField("billets de 50€", default=0)
taken_100 = models.PositiveSmallIntegerField(default=0) taken_100 = models.PositiveSmallIntegerField("billets de 100€", default=0)
taken_200 = models.PositiveSmallIntegerField(default=0) taken_200 = models.PositiveSmallIntegerField("billets de 200€", default=0)
taken_500 = models.PositiveSmallIntegerField(default=0) taken_500 = models.PositiveSmallIntegerField("billets de 500€", default=0)
taken_cheque = models.DecimalField(default=0, max_digits=6, decimal_places=2) taken_cheque = models.DecimalField(
"montant des chèques",
default=0, max_digits=6, decimal_places=2)
def __str__(self): def __str__(self):
return '%s %s' % (self.checkout, self.at) return '%s %s' % (self.checkout, self.at)
@ -336,19 +347,21 @@ class ArticleCategory(models.Model):
@python_2_unicode_compatible @python_2_unicode_compatible
class Article(models.Model): class Article(models.Model):
name = models.CharField(max_length = 45) name = models.CharField("nom", max_length = 45)
is_sold = models.BooleanField(default = True) is_sold = models.BooleanField("en vente", default = True)
hidden = models.BooleanField(default=False, hidden = models.BooleanField("caché",
default=False,
help_text="Si oui, ne sera pas affiché " help_text="Si oui, ne sera pas affiché "
"au public ; par exemple " "au public ; par exemple "
"sur la carte.") "sur la carte.")
price = models.DecimalField( price = models.DecimalField(
"prix",
max_digits = 6, decimal_places = 2, max_digits = 6, decimal_places = 2,
default = 0) default = 0)
stock = models.IntegerField(default = 0) stock = models.IntegerField(default = 0)
category = models.ForeignKey( category = models.ForeignKey(
ArticleCategory, on_delete = models.PROTECT, ArticleCategory, on_delete = models.PROTECT,
related_name = "articles") related_name = "articles", verbose_name='catégorie')
BOX_TYPE_CHOICES = ( BOX_TYPE_CHOICES = (
("caisse", "caisse"), ("caisse", "caisse"),
("carton", "carton"), ("carton", "carton"),
@ -356,10 +369,12 @@ class Article(models.Model):
("fût", "fût"), ("fût", "fût"),
) )
box_type = models.CharField( box_type = models.CharField(
"type de contenant",
choices = BOX_TYPE_CHOICES, choices = BOX_TYPE_CHOICES,
max_length = choices_length(BOX_TYPE_CHOICES), max_length = choices_length(BOX_TYPE_CHOICES),
blank = True, null = True, default = None) blank = True, null = True, default = None)
box_capacity = models.PositiveSmallIntegerField( box_capacity = models.PositiveSmallIntegerField(
"capacité du contenant",
blank = True, null = True, default = None) blank = True, null = True, default = None)
def __str__(self): def __str__(self):
@ -417,11 +432,11 @@ class Supplier(models.Model):
Article, Article,
through = 'SupplierArticle', through = 'SupplierArticle',
related_name = "suppliers") related_name = "suppliers")
name = models.CharField(max_length = 45) name = models.CharField("nom", max_length = 45)
address = models.TextField() address = models.TextField("adresse")
email = models.EmailField() email = models.EmailField("adresse mail")
phone = models.CharField(max_length = 10) phone = models.CharField("téléphone", max_length = 10)
comment = models.TextField() comment = models.TextField("commentaire")
def __str__(self): def __str__(self):
return self.name return self.name

View file

@ -1,17 +1,27 @@
{% extends 'kfet/base.html' %} {% extends 'kfet/base.html' %}
{% load widget_tweaks %}
{% load staticfiles %}
{% block title %}Nouvel article{% endblock %} {% block title %}Nouvel article{% endblock %}
{% block content-header-title %}Création d'un article{% endblock %} {% block content-header-title %}Création d'un article{% endblock %}
{% block content %} {% block content %}
<form submit="" method="post"> {% include "kfet/base_messages.html" %}
{% csrf_token %}
{{ form.as_p }} <div class="row form-only">
{% if not perms.kfet.add_article %} <div class="col-sm-12 col-md-8 col-md-offset-2">
<input type="password" name="KFETPASSWORD"> <div class="content-form">
{% endif %} <form submit="" method="post" class="form-horizontal">
<input type="submit" value="Enregistrer"> {% csrf_token %}
</form> {% include 'kfet/form_snippet.html' with form=form %}
{% if not perms.kfet.add_article %}
{% include 'kfet/form_authentication_snippet.html' %}
{% endif %}
{% include 'kfet/form_submit_snippet.html' with value="Enregistrer" %}
</form>
</div>
</div>
</div>
{% endblock %} {% endblock %}

View file

@ -1,17 +1,27 @@
{% extends 'kfet/base.html' %} {% extends 'kfet/base.html' %}
{% load widget_tweaks %}
{% load staticfiles %}
{% block title %}Édition de l'article {{ article.name }}{% endblock %} {% block title %}Édition de l'article {{ article.name }}{% endblock %}
{% block content-header-title %}Article {{ article.name }} - Édition{% endblock %} {% block content-header-title %}Article {{ article.name }} - Édition{% endblock %}
{% block content %} {% block content %}
<form action="" method="post"> {% include "kfet/base_messages.html" %}
{% csrf_token %}
{{ form.as_p }} <div class="row form-only">
{% if not perms.kfet.change_article %} <div class="col-sm-12 col-md-8 col-md-offset-2">
<input type="password" name="KFETPASSWORD"> <div class="content-form">
{% endif %} <form submit="" method="post" class="form-horizontal">
<input type="submit" value="Mettre à jour"> {% csrf_token %}
</form> {% include 'kfet/form_snippet.html' with form=form %}
{% if not perms.kfet.change_article %}
{% include 'kfet/form_authentication_snippet.html' %}
{% endif %}
{% include 'kfet/form_submit_snippet.html' with value="Mettre à jour" %}
</form>
</div>
</div>
</div>
{% endblock %} {% endblock %}

View file

@ -80,7 +80,7 @@
<td><input id="id_taken_001" name="taken_001" data-value="0.01" min="0" value="0" type="number" class="form-control" required></td> <td><input id="id_taken_001" name="taken_001" data-value="0.01" min="0" value="0" type="number" class="form-control" required></td>
</tr> </tr>
</table> </table>
Chèque: <input id="id_taken_cheque" name="taken_cheque" data-value="1" min="0" step="0.01" value="0" type="number" class="form-control" required> <p style="font-weight:bold"> Chèque:</p> <input id="id_taken_cheque" name="taken_cheque" data-value="1" min="0" step="0.01" value="0" type="number" class="form-control" required>
</div> </div>
</div> </div>
<div class="content-right-block"> <div class="content-right-block">

View file

@ -15,15 +15,15 @@ Caisse {{ checkout.name }} - Modification relevé {{ checkoutstatement.at }}
</div> </div>
<div class="col-sm-8 col-md-9 col-content-right"> <div class="col-sm-8 col-md-9 col-content-right">
{% include 'kfet/base_messages.html' %} {% include 'kfet/base_messages.html' %}
<div class="content-right"> <div class="content-right form-only">
<div class="content-right-block"> <div class="content-form">
<form action="" method="post"> <form submit="" method="post" class="form-horizontal">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {% include 'kfet/form_snippet.html' with form=form %}
{% if not perms.kfet.change_checkoutstatement %} {% if not perms.kfet.change_checkoutstatement %}
<input type="password" name="KFETPASSWORD"> {% include 'kfet/form_authentication_snippet.html' %}
{% endif %} {% endif %}
<input type="submit" value="Enregistrer"> {% include 'kfet/form_submit_snippet.html' with value="Enregistrer" %}
</form> </form>
</div> </div>
</div> </div>

View file

@ -4,6 +4,11 @@
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label> <label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
{{ field|add_class:'form-control' }} {{ field|add_class:'form-control' }}
<span class="help-block">{{ field.errors }}</span> {% if field.errors %}
<span class="help-block">{{field.errors}}</span>
{% endif %}
{% if field.help_text %}
<span class="help-block">{{field.help_text}}</span>
{% endif %}
</div> </div>
</div> </div>

View file

@ -1,4 +1,5 @@
{% extends 'kfet/base.html' %} {% extends 'kfet/base.html' %}
{% load widget_tweaks %}
{% block title %}Nouvelle commande{% endblock %} {% block title %}Nouvelle commande{% endblock %}
{% block content-header-title %}Nouvelle commande {{ supplier.name }}{% endblock %} {% block content-header-title %}Nouvelle commande {{ supplier.name }}{% endblock %}
@ -60,7 +61,7 @@
<td>{{ form.v_prev }}</td> <td>{{ form.v_prev }}</td>
<td>{{ form.stock }}</td> <td>{{ form.stock }}</td>
<td>{{ form.c_rec }}</td> <td>{{ form.c_rec }}</td>
<td>{{ form.quantity_ordered }}</td> <td>{{ form.quantity_ordered | add_class:"form-control" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

@ -1,4 +1,5 @@
{% extends 'kfet/base.html' %} {% extends 'kfet/base.html' %}
{% load widget_tweaks %}
{% block title %}{% endblock %} {% block title %}{% endblock %}
{% block content-header-title %}{% endblock %} {% block content-header-title %}{% endblock %}
@ -33,11 +34,11 @@
<tr> <tr>
{{ form.article }} {{ form.article }}
<td>{{ form.name }}</td> <td>{{ form.name }}</td>
<td>{{ form.price_HT }}</td> <td>{{ form.price_HT | add_class:"form-control" }}</td>
<td>{{ form.TVA }}</td> <td>{{ form.TVA | add_class:"form-control" }}</td>
<td>{{ form.rights }}</td> <td>{{ form.rights | add_class:"form-control" }}</td>
<td>{{ form.quantity_ordered }}</td> <td>{{ form.quantity_ordered }}</td>
<td>{{ form.quantity_received }}</td> <td>{{ form.quantity_received | add_class:"form-control" }}</td>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View file

@ -1,4 +1,6 @@
{% extends 'kfet/base.html' %} {% extends 'kfet/base.html' %}
{% load widget_tweaks %}
{% load staticfiles %}
{% block title %}Fournisseur - Modification{% endblock %} {% block title %}Fournisseur - Modification{% endblock %}
{% block content-header-title %}Fournisseur - Modification{% endblock %} {% block content-header-title %}Fournisseur - Modification{% endblock %}
@ -7,13 +9,19 @@
{% include 'kfet/base_messages.html' %} {% include 'kfet/base_messages.html' %}
<form action="" method="post"> <div class="row form-only">
{% csrf_token %} <div class="col-sm-12 col-md-8 col-md-offset-2">
{{ form.as_p }} <div class="content-form">
{% if not perms.kfet.change_supplier %} <form submit="" method="post" class="form-horizontal">
<input type="password" name="KFETPASSWORD"> {% csrf_token %}
{% endif %} {% include 'kfet/form_snippet.html' with form=form %}
<input type="submit" class="btn btn-primary btn-lg"> {% if not perms.kfet.change_supplier %}
</form> {% include 'kfet/form_authentication_snippet.html' %}
{% endif %}
{% include 'kfet/form_submit_snippet.html' with value="Mettre à jour" %}
</form>
</div>
</div>
</div>
{% endblock %} {% endblock %}