mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-12-25 20:22:23 +00:00
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
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 Auteur, Media, Jeu, Emprunt
|
|
|
|
|
|
class AuteurForm(ModelForm):
|
|
class Meta:
|
|
model = Auteur
|
|
fields = '__all__'
|
|
|
|
|
|
class MediaForm(ModelForm):
|
|
auteur = forms.ModelMultipleChoiceField(Auteur.objects.all(), widget=forms.CheckboxSelectMultiple, required=False)
|
|
|
|
class Meta:
|
|
model = Media
|
|
fields = '__all__'
|
|
|
|
|
|
class JeuForm(ModelForm):
|
|
class Meta:
|
|
model = Jeu
|
|
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 Meta:
|
|
model = Emprunt
|
|
fields = ['media']
|
|
|
|
|
|
class EditEmpruntForm(ModelForm):
|
|
class Meta:
|
|
model = Emprunt
|
|
fields = ['media', 'permanencier_emprunt', 'permanencier_rendu', 'date_rendu']
|