diff --git a/kfet/forms.py b/kfet/forms.py index 67103de6..7acd0880 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -233,6 +233,16 @@ class CheckoutStatementUpdateForm(forms.ModelForm): model = CheckoutStatement exclude = ['by', 'at', 'checkout', 'amount_error', 'amount_taken'] + +# ----- +# Category +# ----- + +class CategoryForm(forms.ModelForm): + class Meta: + model = ArticleCategory + fields = ['name', 'has_addcost'] + # ----- # Article forms # ----- diff --git a/kfet/migrations/0052_category_addcost.py b/kfet/migrations/0052_category_addcost.py new file mode 100644 index 00000000..83346a1a --- /dev/null +++ b/kfet/migrations/0052_category_addcost.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0051_verbose_names'), + ] + + operations = [ + migrations.AddField( + model_name='articlecategory', + name='has_addcost', + field=models.BooleanField(default=True, help_text="Si oui et qu'une majoration est active, celle-ci sera appliquée aux articles de cette catégorie.", verbose_name='majorée'), + ), + migrations.AlterField( + model_name='articlecategory', + name='name', + field=models.CharField(max_length=45, verbose_name='nom'), + ), + ] diff --git a/kfet/models.py b/kfet/models.py index 6ddac84d..cb8c324b 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -338,13 +338,20 @@ class CheckoutStatement(models.Model): balance=F('balance') - last_statement.balance_new + self.balance_new) super(CheckoutStatement, self).save(*args, **kwargs) + @python_2_unicode_compatible class ArticleCategory(models.Model): - name = models.CharField(max_length = 45) + name = models.CharField("nom", max_length=45) + has_addcost = models.BooleanField("majorée", default=True, + help_text="Si oui et qu'une majoration " + "est active, celle-ci sera " + "appliquée aux articles de " + "cette catégorie.") def __str__(self): return self.name + @python_2_unicode_compatible class Article(models.Model): name = models.CharField("nom", max_length = 45) diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index 17c831df..123f4cfa 100644 --- a/kfet/templates/kfet/article.html +++ b/kfet/templates/kfet/article.html @@ -16,6 +16,9 @@ Nouvel article + + Catégories + diff --git a/kfet/templates/kfet/article_update.html b/kfet/templates/kfet/article_update.html index 85a29f6b..a3bfbcc6 100644 --- a/kfet/templates/kfet/article_update.html +++ b/kfet/templates/kfet/article_update.html @@ -12,7 +12,7 @@