Use verbose names and form snippets for article_create
This commit is contained in:
parent
f32f83db75
commit
079666c0db
4 changed files with 31 additions and 12 deletions
|
@ -235,16 +235,20 @@ class CheckoutStatementUpdateForm(forms.ModelForm):
|
|||
|
||||
class ArticleForm(forms.ModelForm):
|
||||
category_new = forms.CharField(
|
||||
label="Créer une catégorie",
|
||||
max_length=45,
|
||||
required = False)
|
||||
category = forms.ModelChoiceField(
|
||||
label="Catégorie",
|
||||
queryset = ArticleCategory.objects.all(),
|
||||
required = False)
|
||||
|
||||
suppliers = forms.ModelMultipleChoiceField(
|
||||
label="Fournisseurs",
|
||||
queryset = Supplier.objects.all(),
|
||||
required = False)
|
||||
supplier_new = forms.CharField(
|
||||
label="Créer un fournisseur",
|
||||
max_length = 45,
|
||||
required = False)
|
||||
|
||||
|
|
|
@ -336,19 +336,21 @@ class ArticleCategory(models.Model):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class Article(models.Model):
|
||||
name = models.CharField(max_length = 45)
|
||||
is_sold = models.BooleanField(default = True)
|
||||
hidden = models.BooleanField(default=False,
|
||||
name = models.CharField("nom", max_length = 45)
|
||||
is_sold = models.BooleanField("en vente", default = True)
|
||||
hidden = models.BooleanField("caché",
|
||||
default=False,
|
||||
help_text="Si oui, ne sera pas affiché "
|
||||
"au public ; par exemple "
|
||||
"sur la carte.")
|
||||
price = models.DecimalField(
|
||||
"prix",
|
||||
max_digits = 6, decimal_places = 2,
|
||||
default = 0)
|
||||
stock = models.IntegerField(default = 0)
|
||||
category = models.ForeignKey(
|
||||
ArticleCategory, on_delete = models.PROTECT,
|
||||
related_name = "articles")
|
||||
related_name = "articles", verbose_name='catégorie')
|
||||
BOX_TYPE_CHOICES = (
|
||||
("caisse", "caisse"),
|
||||
("carton", "carton"),
|
||||
|
@ -356,10 +358,12 @@ class Article(models.Model):
|
|||
("fût", "fût"),
|
||||
)
|
||||
box_type = models.CharField(
|
||||
"type de contenant",
|
||||
choices = BOX_TYPE_CHOICES,
|
||||
max_length = choices_length(BOX_TYPE_CHOICES),
|
||||
blank = True, null = True, default = None)
|
||||
box_capacity = models.PositiveSmallIntegerField(
|
||||
"capacité du contenant",
|
||||
blank = True, null = True, default = None)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -1,17 +1,27 @@
|
|||
{% extends 'kfet/base.html' %}
|
||||
{% load widget_tweaks %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block title %}Nouvel article{% endblock %}
|
||||
{% block content-header-title %}Création d'un article{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form submit="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% if not perms.kfet.add_article %}
|
||||
<input type="password" name="KFETPASSWORD">
|
||||
{% endif %}
|
||||
<input type="submit" value="Enregistrer">
|
||||
</form>
|
||||
{% include "kfet/base_messages.html" %}
|
||||
|
||||
<div class="row form-only">
|
||||
<div class="col-sm-12 col-md-8 col-md-offset-2">
|
||||
<div class="content-form">
|
||||
<form submit="" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
{% 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 %}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
|
||||
<div class="col-sm-10">
|
||||
{{ field|add_class:'form-control' }}
|
||||
<span class="help-block">{{field.help_text}}</span>
|
||||
<span class="help-block">{{ field.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue