forms.py 1.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
from django import forms
from django.forms import ModelForm, Form
from django import forms
from django.core.validators import MinValueValidator
from .models import Panier, Paiement, Commande, Credit, Livraison

class LivraisonForm(ModelForm):
    class Meta:
        model = Livraison
        fields = ['date']

    def __init__(self, *args, **kwargs):
        super(LivraisonForm, self).__init__(*args, **kwargs)
        self.fields['date'].label = 'Date de livraison'

class DelLivraisonForm(ModelForm):
    date = forms.ModelMultipleChoiceField(queryset=Livraison.objects.all(), label="Date de livraison",  widget=forms.CheckboxSelectMultiple)

    class Meta:
        exclude = ['date']
        model = Livraison

class PaiementForm(ModelForm):
    class Meta:
        model = Paiement
        fields = ['moyen']

    def __init__(self, *args, **kwargs):
        super(PaiementForm, self).__init__(*args, **kwargs)
        self.fields['moyen'].label = 'Moyen de paiement à ajouter'

class DelPaiementForm(ModelForm):
    paiements = forms.ModelMultipleChoiceField(queryset=Paiement.objects.all(), label="Moyens de paiement actuels",  widget=forms.CheckboxSelectMultiple)

    class Meta:
        exclude = ['moyen']
        model = Paiement

39 40 41 42 43 44 45 46 47 48 49 50
class PanierForm(ModelForm):
    class Meta:
        model = Panier
        fields = ['nom','prix']

class DelPanierForm(ModelForm):
    paniers = forms.ModelMultipleChoiceField(queryset=Panier.objects.all(), label="Articles en vente actuellement",  widget=forms.CheckboxSelectMultiple)

    class Meta:
        exclude = ['nom','prix']
        model = Panier

51 52 53 54 55 56 57 58
class CreditForm(ModelForm):
    class Meta:
        model = Credit
        fields = ['montant','moyen','validite']

class CreditFullForm(CreditForm):
    class Meta(CreditForm.Meta):
        fields = '__all__'