From 26a5c6cfb3a8be307319214c048e1f833cef4274 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 25 Mar 2019 08:33:43 +0100 Subject: [PATCH] Rename fields of cotisation.Facture --- cotisations/forms.py | 2 +- .../migrations/0040_auto_20190325_0832.py | 35 +++++++++++++++++++ cotisations/models.py | 26 ++++++-------- cotisations/payment_methods/cheque/forms.py | 2 +- cotisations/payment_methods/cheque/views.py | 2 +- cotisations/payment_methods/comnpay/views.py | 4 +-- cotisations/views.py | 2 +- 7 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 cotisations/migrations/0040_auto_20190325_0832.py diff --git a/cotisations/forms.py b/cotisations/forms.py index dd1c9924..e36c02dc 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -68,7 +68,7 @@ class FactureForm(FieldPermissionFormMixin, FormRevMixin, ModelForm): self.fields['user'].label = _("Member") self.fields['user'].empty_label = \ _("Select the proprietary member") - self.fields['valid'].label = _("Validated invoice") + self.fields['validity'].label = _("Validated invoice") else: self.fields = {'paiement': self.fields['paiement']} diff --git a/cotisations/migrations/0040_auto_20190325_0832.py b/cotisations/migrations/0040_auto_20190325_0832.py new file mode 100644 index 00000000..f7d5d3ae --- /dev/null +++ b/cotisations/migrations/0040_auto_20190325_0832.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-03-25 07:32 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cotisations', '0039_auto_20190321_1626'), + ] + + operations = [ + migrations.RenameField( + model_name='facture', + old_name='banque', + new_name='bank', + ), + migrations.RenameField( + model_name='facture', + old_name='cheque', + new_name='cheque_number', + ), + migrations.RenameField( + model_name='facture', + old_name='control', + new_name='controlled', + ), + migrations.RenameField( + model_name='facture', + old_name='valid', + new_name='validity', + ), + ] diff --git a/cotisations/models.py b/cotisations/models.py index c3711abd..1519cb4f 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -125,26 +125,22 @@ class Facture(BaseInvoice): user = models.ForeignKey('users.User', on_delete=models.PROTECT) # TODO : change paiement to payment paiement = models.ForeignKey('Paiement', on_delete=models.PROTECT) - # TODO : change banque to bank - banque = models.ForeignKey( + bank = models.ForeignKey( 'Banque', on_delete=models.PROTECT, blank=True, null=True ) - # TODO : maybe change to cheque nummber because not evident - cheque = models.CharField( + cheque_number = models.CharField( verbose_name=_("cheque number"), max_length=255, blank=True, ) - # TODO : change name to validity for clarity - valid = models.BooleanField( + validity = models.BooleanField( verbose_name=_("validated"), default=False, ) - # TODO : changed name to controlled for clarity - control = models.BooleanField( + controlled = models.BooleanField( verbose_name=_("controlled"), default=False, ) @@ -176,7 +172,7 @@ class Facture(BaseInvoice): return False, _("You don't have the right to edit this user's " "invoices.") elif not user_request.has_perm('cotisations.change_all_facture') and \ - (self.control or not self.valid): + (self.controlled or not self.validity): return False, _("You don't have the right to edit an invoice " "already controlled or invalidated.") else: @@ -190,7 +186,7 @@ class Facture(BaseInvoice): return False, _("You don't have the right to delete this user's " "invoices.") elif not user_request.has_perm('cotisations.change_all_facture') and \ - (self.control or not self.valid): + (self.controlled or not self.validity): return False, _("You don't have the right to delete an invoice " "already controlled or invalidated.") else: @@ -201,7 +197,7 @@ class Facture(BaseInvoice): if self.user != user_request: return False, _("You don't have the right to view someone else's " "invoices history.") - elif not self.valid: + elif not self.validity: return False, _("The invoice has been invalidated.") else: return True, None @@ -238,8 +234,8 @@ class Facture(BaseInvoice): self.field_permissions = { 'control': self.can_change_control, } - self.__original_valid = self.valid - self.__original_control = self.control + self.__original_valid = self.validity + self.__original_control = self.controlled def get_subscription(self): """Returns every subscription associated with this invoice.""" @@ -256,11 +252,11 @@ class Facture(BaseInvoice): def save(self, *args, **kwargs): super(Facture, self).save(*args, **kwargs) - if not self.__original_valid and self.valid: + if not self.__original_valid and self.validity: send_mail_invoice(self) if self.is_subscription() \ and not self.__original_control \ - and self.control \ + and self.controlled \ and CotisationsOption.get_cached_value('send_voucher_mail'): send_mail_voucher(self) diff --git a/cotisations/payment_methods/cheque/forms.py b/cotisations/payment_methods/cheque/forms.py index 37942687..53b7d6b7 100644 --- a/cotisations/payment_methods/cheque/forms.py +++ b/cotisations/payment_methods/cheque/forms.py @@ -28,4 +28,4 @@ class InvoiceForm(FormRevMixin, forms.ModelForm): """A simple form to get the bank a the cheque number.""" class Meta: model = Invoice - fields = ['banque', 'cheque'] + fields = ['bank', 'cheque_number'] diff --git a/cotisations/payment_methods/cheque/views.py b/cotisations/payment_methods/cheque/views.py index 3cce3e5c..eb10e5b2 100644 --- a/cotisations/payment_methods/cheque/views.py +++ b/cotisations/payment_methods/cheque/views.py @@ -41,7 +41,7 @@ def cheque(request, invoice_pk): """This view validate an invoice with the data from a cheque.""" invoice = get_object_or_404(Invoice, pk=invoice_pk) payment_method = find_payment_method(invoice.paiement) - if invoice.valid or not isinstance(payment_method, ChequePayment): + if invoice.validity or not isinstance(payment_method, ChequePayment): messages.error( request, _("You can't pay this invoice with a cheque.") diff --git a/cotisations/payment_methods/comnpay/views.py b/cotisations/payment_methods/comnpay/views.py index 12a5747b..72c08c24 100644 --- a/cotisations/payment_methods/comnpay/views.py +++ b/cotisations/payment_methods/comnpay/views.py @@ -47,7 +47,7 @@ def accept_payment(request, factureid): accepted. """ invoice = get_object_or_404(Facture, id=factureid) - if invoice.valid: + if invoice.validity: messages.success( request, _("The payment of %(amount)s € was accepted.") % { @@ -130,7 +130,7 @@ def ipn(request): # received the failure information. return HttpResponse("HTTP/1.1 200 OK") - facture.valid = True + facture.validity = True facture.save() # Everything worked we send a reponse to Comnpay indicating that diff --git a/cotisations/views.py b/cotisations/views.py index 6b60e1af..79d2b028 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -865,7 +865,7 @@ def control(request): ) control_invoices_formset = modelformset_factory( Facture, - fields=('control', 'valid'), + fields=('controlled', 'validity'), extra=0 ) invoice_list = re2o_paginator(request, invoice_list, pagination_number)