From c0e3a9c4f4c6f400dcc03d961c72c268d52cec2a Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 22 Jul 2017 17:57:58 +0200 Subject: [PATCH] Fix merde de 5-1 --- cotisations/admin.py | 2 +- cotisations/forms.py | 6 +++--- .../migrations/0018_paiement_type_paiement.py | 21 +++++++++++++++++++ cotisations/models.py | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 cotisations/migrations/0018_paiement_type_paiement.py diff --git a/cotisations/admin.py b/cotisations/admin.py index 6c4e71cf..3699e023 100644 --- a/cotisations/admin.py +++ b/cotisations/admin.py @@ -38,7 +38,7 @@ class BanqueAdmin(VersionAdmin): list_display = ('name',) class PaiementAdmin(VersionAdmin): - list_display = ('moyen',) + list_display = ('moyen','type_paiement') class CotisationAdmin(VersionAdmin): list_display = ('vente','date_start','date_end') diff --git a/cotisations/forms.py b/cotisations/forms.py index e323bf63..9bee0d2a 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -46,7 +46,7 @@ class NewFactureForm(ModelForm): banque = cleaned_data.get("banque") if not paiement: raise forms.ValidationError("Le moyen de paiement est obligatoire.") - elif paiement.type_ == "check" and not (cheque and banque): + elif paiement.type_paiement == "check" and not (cheque and banque): raise forms.ValidationError("Le numéro de chèque et la banque sont obligatoires.") return cleaned_data @@ -112,12 +112,12 @@ class DelArticleForm(ModelForm): class PaiementForm(ModelForm): class Meta: model = Paiement - fields = ['moyen', 'type_'] + fields = ['moyen', 'type_paiement'] def __init__(self, *args, **kwargs): super(PaiementForm, self).__init__(*args, **kwargs) self.fields['moyen'].label = 'Moyen de paiement à ajouter' - self.fields['type_'].label = 'Type de paiement à ajouter' + self.fields['type_paiement'].label = 'Type de paiement à ajouter' class DelPaiementForm(ModelForm): paiements = forms.ModelMultipleChoiceField(queryset=Paiement.objects.all(), label="Moyens de paiement actuels", widget=forms.CheckboxSelectMultiple) diff --git a/cotisations/migrations/0018_paiement_type_paiement.py b/cotisations/migrations/0018_paiement_type_paiement.py new file mode 100644 index 00000000..488fcf47 --- /dev/null +++ b/cotisations/migrations/0018_paiement_type_paiement.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-07-22 15:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cotisations', '0017_auto_20170718_2329'), + ] + + operations = [ + migrations.AddField( + model_name='paiement', + name='type_paiement', + field=models.CharField(choices=[('check', 'Chèque'), (None, 'Autre')], default=None, max_length=255), + preserve_default=False, + ), + ] diff --git a/cotisations/models.py b/cotisations/models.py index e6efcd80..3c9f0085 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -111,7 +111,7 @@ class Article(models.Model): help_text="Durée exprimée en mois entiers", blank=True, null=True, - min_value=0) + validators=[MinValueValidator(0)]) def clean(self): if self.name.lower() == "solde": @@ -136,7 +136,7 @@ class Paiement(models.Model): ) moyen = models.CharField(max_length=255) - type_ = models.ChoiceField(choices=PAYMENT_TYPES) + type_paiement = models.CharField(choices=PAYMENT_TYPES, max_length=255) def __str__(self): return self.moyen