From c0370d3a12e6ecfe0b1edfbcd53bf51beb2045fb Mon Sep 17 00:00:00 2001 From: chirac Date: Tue, 18 Jul 2017 23:31:04 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20et=20emp=C3=A8che=20des=20valeurs=20n?= =?UTF-8?q?=C3=A9gatives=20aux=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0017_auto_20170718_2329.py | 26 +++++++++++++++++++ cotisations/models.py | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 cotisations/migrations/0017_auto_20170718_2329.py diff --git a/cotisations/migrations/0017_auto_20170718_2329.py b/cotisations/migrations/0017_auto_20170718_2329.py new file mode 100644 index 00000000..4980bb1e --- /dev/null +++ b/cotisations/migrations/0017_auto_20170718_2329.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-07-18 21:29 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cotisations', '0016_auto_20160715_0110'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='duration', + field=models.IntegerField(blank=True, help_text='Durée exprimée en mois entiers', null=True, validators=[django.core.validators.MinValueValidator(0)]), + ), + migrations.AlterField( + model_name='article', + name='name', + field=models.CharField(max_length=255, unique=True), + ), + ] diff --git a/cotisations/models.py b/cotisations/models.py index 63cf97e2..45e9308d 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -104,10 +104,10 @@ def vente_post_delete(sender, **kwargs): class Article(models.Model): PRETTY_NAME = "Articles en vente" - name = models.CharField(max_length=255) + name = models.CharField(max_length=255, unique=True) prix = models.DecimalField(max_digits=5, decimal_places=2) iscotisation = models.BooleanField() - duration = models.IntegerField(help_text="Durée exprimée en mois entiers", blank=True, null=True) + duration = models.IntegerField(validators=[MinValueValidator(0)], help_text="Durée exprimée en mois entiers", blank=True, null=True) def clean(self):