34 lines
870 B
Python
34 lines
870 B
Python
# -*- mode: python; coding: utf-8 -*-
|
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from django import forms
|
|
from django.forms import ModelForm
|
|
|
|
from .models import Jeu, Emprunt
|
|
|
|
|
|
class JeuForm(ModelForm):
|
|
class Meta:
|
|
model = Jeu
|
|
fields = '__all__'
|
|
|
|
def clean_nombre_joueurs_max(self):
|
|
max_player = self.cleaned_data['nombre_joueurs_max']
|
|
if max_player < self.cleaned_data['nombre_joueurs_min']:
|
|
raise forms.ValidationError("Max ne peut être inférieur à min")
|
|
return max_player
|
|
|
|
|
|
class EmpruntForm(ModelForm):
|
|
class Meta:
|
|
model = Emprunt
|
|
fields = ['media']
|
|
|
|
|
|
class EditEmpruntForm(ModelForm):
|
|
class Meta:
|
|
model = Emprunt
|
|
fields = ['media', 'permanencier_emprunt', 'permanencier_rendu',
|
|
'date_rendu']
|