3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-06-02 13:21:48 +00:00
coope/preferences/forms.py

53 lines
1.9 KiB
Python
Raw Normal View History

2018-10-05 22:03:02 +00:00
from django import forms
2018-11-22 21:52:15 +00:00
from django.core.exceptions import ValidationError
2018-10-05 22:03:02 +00:00
2019-06-23 12:53:18 +00:00
from .models import Cotisation, PaymentMethod, GeneralPreferences, PriceProfile
2018-10-05 22:03:02 +00:00
class CotisationForm(forms.ModelForm):
2018-12-02 15:28:40 +00:00
"""
2019-02-28 12:18:41 +00:00
Form to add and edit :class:`~preferences.models.Cotisation`.
2018-12-02 15:28:40 +00:00
"""
2018-10-05 22:03:02 +00:00
class Meta:
model = Cotisation
fields = "__all__"
2019-06-23 08:54:21 +00:00
def clean(self):
cleaned_data = super().clean()
if cleaned_data.get("amount_ptm") > cleaned_data.get("amount"):
raise ValidationError("La quantité d'argent donnée au club doit être inférieure à\
la quantité d'argent totale")
2018-10-05 22:03:02 +00:00
class PaymentMethodForm(forms.ModelForm):
2018-12-02 15:28:40 +00:00
"""
2019-02-28 12:18:41 +00:00
Form to add and edit :class:`~preferences.models.PaymentMethod`.
2018-12-02 15:28:40 +00:00
"""
2018-10-05 22:03:02 +00:00
class Meta:
model = PaymentMethod
fields = "__all__"
2019-06-23 12:53:18 +00:00
class PriceProfileForm(forms.ModelForm):
"""
Form to add and edit :class:`~preferences.models.PriceProfile`.
"""
class Meta:
model = PriceProfile
fields = "__all__"
2018-10-05 22:03:02 +00:00
class GeneralPreferencesForm(forms.ModelForm):
2018-12-02 15:28:40 +00:00
"""
2019-02-28 12:18:41 +00:00
Form to edit the :class:`~preferences.models.GeneralPreferences`.
2018-12-02 15:28:40 +00:00
"""
2018-10-05 22:03:02 +00:00
class Meta:
model = GeneralPreferences
fields = "__all__"
widgets = {
'global_message': forms.Textarea(attrs={'placeholder': 'Message global à afficher sur le site'}),
'active_message': forms.Textarea(attrs={'placeholder': 'Ce message s\'affichera si le site n\'est pas actif'}),
'president': forms.TextInput(attrs={'placeholder': 'Président'}),
'secretary': forms.TextInput(attrs={'placeholder': 'Secrétaire'}),
'treasurer': forms.TextInput(attrs={'placeholder': 'Trésorier'}),
'phoenixTM_responsible': forms.TextInput(attrs={'placeholder': 'Responsable Phœnix Technopôle Metz'}),
2019-01-19 22:39:48 +00:00
'home_text': forms.Textarea(attrs={'placeholder': 'Ce message sera affiché sur la page d\'accueil'})
2018-10-05 22:03:02 +00:00
}