8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 00:43:46 +00:00

Unique together remplace unique

This commit is contained in:
Gabriel Detraz 2017-10-29 11:57:18 +01:00 committed by root
parent 225164273f
commit 05c5a3a0c0
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-29 10:56
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0026_auto_20171028_0126'),
]
operations = [
migrations.AlterField(
model_name='article',
name='name',
field=models.CharField(max_length=255),
),
]

View file

@ -246,7 +246,7 @@ class Article(models.Model):
('All', 'All'), ('All', 'All'),
) )
name = models.CharField(max_length=255, unique=True) name = models.CharField(max_length=255)
prix = models.DecimalField(max_digits=5, decimal_places=2) prix = models.DecimalField(max_digits=5, decimal_places=2)
duration = models.PositiveIntegerField( duration = models.PositiveIntegerField(
help_text="Durée exprimée en mois entiers", help_text="Durée exprimée en mois entiers",
@ -266,6 +266,8 @@ class Article(models.Model):
max_length=255 max_length=255
) )
unique_together = ('name', 'type_user')
def clean(self): def clean(self):
if self.name.lower() == "solde": if self.name.lower() == "solde":
raise ValidationError("Solde est un nom d'article invalide") raise ValidationError("Solde est un nom d'article invalide")