Fix durée d'un jeu
This commit is contained in:
parent
dee26e3eda
commit
3c9021f8f4
|
@ -39,6 +39,11 @@ class JeuForm(ModelForm):
|
||||||
model = Jeu
|
model = Jeu
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def clean_nombre_joueurs_max(self):
|
||||||
|
if self.cleaned_data['nombre_joueurs_max'] < self.cleaned_data['nombre_joueurs_min']:
|
||||||
|
raise forms.ValidationError("Max ne peut être inférieur à min")
|
||||||
|
return self.cleaned_data['nombre_joueurs_max']
|
||||||
|
|
||||||
class EmpruntForm(ModelForm):
|
class EmpruntForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Emprunt
|
model = Emprunt
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.2 on 2017-07-03 23:38
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('media', '0006_jeu'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='jeu',
|
||||||
|
name='duree',
|
||||||
|
field=models.CharField(choices=[('1h-', '1h-'), ('1-2h', '1-2h'), ('2-3h', '2-3h'), ('4h+', '4h+')], max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='jeu',
|
||||||
|
name='nombre_joueurs_max',
|
||||||
|
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='jeu',
|
||||||
|
name='nombre_joueurs_min',
|
||||||
|
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,4 +1,5 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.core.validators import MinValueValidator
|
||||||
|
|
||||||
class Auteur(models.Model):
|
class Auteur(models.Model):
|
||||||
nom = models.CharField(max_length=255)
|
nom = models.CharField(max_length=255)
|
||||||
|
@ -26,17 +27,18 @@ class Emprunt(models.Model):
|
||||||
|
|
||||||
class Jeu(models.Model):
|
class Jeu(models.Model):
|
||||||
DUREE = (
|
DUREE = (
|
||||||
('LONG', 'LONG'),
|
('-1h', '-1h'),
|
||||||
('MOYEN', 'MOYEN'),
|
('1-2h', '1-2h'),
|
||||||
('COURT', 'COURT'),
|
('2-3h', '2-3h'),
|
||||||
|
('4h+', '4h+'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
nom = models.CharField(max_length=255)
|
nom = models.CharField(max_length=255)
|
||||||
proprietaire = models.ForeignKey('users.User', on_delete=models.PROTECT)
|
proprietaire = models.ForeignKey('users.User', on_delete=models.PROTECT)
|
||||||
duree = models.CharField(choices=DUREE, max_length=255)
|
duree = models.CharField(choices=DUREE, max_length=255)
|
||||||
nombre_joueurs_min = models.IntegerField()
|
nombre_joueurs_min = models.IntegerField(validators=[MinValueValidator(1)])
|
||||||
nombre_joueurs_max = models.IntegerField()
|
nombre_joueurs_max = models.IntegerField(validators=[MinValueValidator(1)])
|
||||||
comment = models.CharField(help_text="Commentaire", max_length=255, blank=True, null=True)
|
comment = models.CharField(help_text="Commentaire", max_length=255, blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue