Commit a06082c6 authored by Laouen Fernet's avatar Laouen Fernet

Translation of cotisations/ (front)

parent 0193f474
......@@ -42,4 +42,5 @@ def can_view(user):
if can:
return can, None
else:
return can, _("You don't have the rights to see this application.")
return can, _("You don't have the right to view this application.")
......@@ -40,8 +40,8 @@ from django import forms
from django.db.models import Q
from django.forms import ModelForm, Form
from django.core.validators import MinValueValidator
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _l
from django.utils.translation import ugettext_lazy as _
from django.shortcuts import get_object_or_404
from re2o.field_permissions import FieldPermissionFormMixin
......@@ -93,11 +93,11 @@ class SelectUserArticleForm(FormRevMixin, Form):
queryset=Article.objects.filter(
Q(type_user='All') | Q(type_user='Adherent')
),
label=_l("Article"),
label=_("Article"),
required=True
)
quantity = forms.IntegerField(
label=_l("Quantity"),
label=_("Quantity"),
validators=[MinValueValidator(1)],
required=True
)
......@@ -117,11 +117,11 @@ class SelectClubArticleForm(Form):
queryset=Article.objects.filter(
Q(type_user='All') | Q(type_user='Club')
),
label=_l("Article"),
label=_("Article"),
required=True
)
quantity = forms.IntegerField(
label=_l("Quantity"),
label=_("Quantity"),
validators=[MinValueValidator(1)],
required=True
)
......@@ -161,7 +161,7 @@ class DelArticleForm(FormRevMixin, Form):
"""
articles = forms.ModelMultipleChoiceField(
queryset=Article.objects.none(),
label=_l("Existing articles"),
label=_("Available articles"),
widget=forms.CheckboxSelectMultiple
)
......@@ -201,7 +201,7 @@ class DelPaiementForm(FormRevMixin, Form):
# TODO : change paiement to payment
paiements = forms.ModelMultipleChoiceField(
queryset=Paiement.objects.none(),
label=_l("Existing payment method"),
label=_("Available payment methods"),
widget=forms.CheckboxSelectMultiple
)
......@@ -239,7 +239,7 @@ class DelBanqueForm(FormRevMixin, Form):
# TODO : change banque to bank
banques = forms.ModelMultipleChoiceField(
queryset=Banque.objects.none(),
label=_l("Existing banks"),
label=_("Available banks"),
widget=forms.CheckboxSelectMultiple
)
......@@ -258,13 +258,13 @@ class RechargeForm(FormRevMixin, Form):
Form used to refill a user's balance
"""
value = forms.FloatField(
label=_l("Amount"),
label=_("Amount"),
min_value=0.01,
validators=[]
)
payment = forms.ModelChoiceField(
queryset=Paiement.objects.none(),
label=_l("Payment method")
label=_("Payment method")
)
def __init__(self, *args, user=None, **kwargs):
......@@ -290,3 +290,4 @@ class RechargeForm(FormRevMixin, Form):
}
)
return self.cleaned_data
This diff is collapsed.
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-08-18 11:19
from __future__ import unicode_literals
import cotisations.validators
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import re2o.aes_field
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0032_custom_invoice'),
]
operations = [
migrations.AlterModelOptions(
name='article',
options={'permissions': (('view_article', 'Can view an article object'), ('buy_every_article', 'Can buy every article')), 'verbose_name': 'article', 'verbose_name_plural': 'articles'},
),
migrations.AlterModelOptions(
name='balancepayment',
options={'verbose_name': 'user balance'},
),
migrations.AlterModelOptions(
name='banque',
options={'permissions': (('view_banque', 'Can view a bank object'),), 'verbose_name': 'bank', 'verbose_name_plural': 'banks'},
),
migrations.AlterModelOptions(
name='cotisation',
options={'permissions': (('view_cotisation', 'Can view a subscription object'), ('change_all_cotisation', 'Can edit the previous subscriptions')), 'verbose_name': 'subscription', 'verbose_name_plural': 'subscriptions'},
),
migrations.AlterModelOptions(
name='custominvoice',
options={'permissions': (('view_custominvoice', 'Can view a custom invoice object'),)},
),
migrations.AlterModelOptions(
name='facture',
options={'permissions': (('change_facture_control', 'Can edit the "controlled" state'), ('view_facture', 'Can view an invoice object'), ('change_all_facture', 'Can edit all the previous invoices')), 'verbose_name': 'invoice', 'verbose_name_plural': 'invoices'},
),
migrations.AlterModelOptions(
name='paiement',
options={'permissions': (('view_paiement', 'Can view a payment method object'), ('use_every_payment', 'Can use every payment method')), 'verbose_name': 'payment method', 'verbose_name_plural': 'payment methods'},
),
migrations.AlterModelOptions(
name='vente',
options={'permissions': (('view_vente', 'Can view a purchase object'), ('change_all_vente', 'Can edit all the previous purchases')), 'verbose_name': 'purchase', 'verbose_name_plural': 'purchases'},
),
migrations.AlterField(
model_name='article',
name='available_for_everyone',
field=models.BooleanField(default=False, verbose_name='is available for every user'),
),
migrations.AlterField(
model_name='article',
name='duration',
field=models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)], verbose_name='duration (in months)'),
),
migrations.AlterField(
model_name='article',
name='name',
field=models.CharField(max_length=255, verbose_name='designation'),
),
migrations.AlterField(
model_name='article',
name='prix',
field=models.DecimalField(decimal_places=2, max_digits=5, verbose_name='unit price'),
),
migrations.AlterField(
model_name='article',
name='type_cotisation',
field=models.CharField(blank=True, choices=[('Connexion', 'Connection'), ('Adhesion', 'Membership'), ('All', 'Both of them')], default=None, max_length=255, null=True, verbose_name='subscription type'),
),
migrations.AlterField(
model_name='article',
name='type_user',
field=models.CharField(choices=[('Adherent', 'Member'), ('Club', 'Club'), ('All', 'Both of them')], default='All', max_length=255, verbose_name='type of users concerned'),
),
migrations.AlterField(
model_name='banque',
name='name',
field=models.CharField(max_length=255),
),
migrations.AlterField(
model_name='comnpaypayment',
name='payment_credential',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='ComNpay VAT Number'),
),
migrations.AlterField(
model_name='comnpaypayment',
name='payment_pass',
field=re2o.aes_field.AESEncryptedField(blank=True, max_length=255, null=True, verbose_name='ComNpay secret key'),
),
migrations.AlterField(
model_name='comnpaypayment',
name='production',
field=models.BooleanField(default=True, verbose_name='Production mode enabled (production URL, instead of homologation)'),
),
migrations.AlterField(
model_name='cotisation',
name='date_end',
field=models.DateTimeField(verbose_name='end date'),
),
migrations.AlterField(
model_name='cotisation',
name='date_start',
field=models.DateTimeField(verbose_name='start date'),
),
migrations.AlterField(
model_name='cotisation',
name='type_cotisation',
field=models.CharField(choices=[('Connexion', 'Connection'), ('Adhesion', 'Membership'), ('All', 'Both of them')], default='All', max_length=255, verbose_name='subscription type'),
),
migrations.AlterField(
model_name='cotisation',
name='vente',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='cotisations.Vente', verbose_name='purchase'),
),
migrations.AlterField(
model_name='facture',
name='cheque',
field=models.CharField(blank=True, max_length=255, verbose_name='cheque number'),
),
migrations.AlterField(
model_name='facture',
name='control',
field=models.BooleanField(default=False, verbose_name='controlled'),
),
migrations.AlterField(
model_name='facture',
name='valid',
field=models.BooleanField(default=True, verbose_name='validated'),
),
migrations.AlterField(
model_name='paiement',
name='available_for_everyone',
field=models.BooleanField(default=False, verbose_name='is available for every user'),
),
migrations.AlterField(
model_name='paiement',
name='is_balance',
field=models.BooleanField(default=False, editable=False, help_text='There should be only one balance payment method.', validators=[cotisations.validators.check_no_balance], verbose_name='is user balance'),
),
migrations.AlterField(
model_name='paiement',
name='moyen',
field=models.CharField(max_length=255, verbose_name='method'),
),
migrations.AlterField(
model_name='vente',
name='duration',
field=models.PositiveIntegerField(blank=True, null=True, verbose_name='duration (in months)'),
),
migrations.AlterField(
model_name='vente',
name='facture',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cotisations.BaseInvoice', verbose_name='invoice'),
),
migrations.AlterField(
model_name='vente',
name='name',
field=models.CharField(max_length=255, verbose_name='article'),
),
migrations.AlterField(
model_name='vente',
name='number',
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1)], verbose_name='amount'),
),
migrations.AlterField(
model_name='vente',
name='prix',
field=models.DecimalField(decimal_places=2, max_digits=5, verbose_name='price'),
),
migrations.AlterField(
model_name='vente',
name='type_cotisation',
field=models.CharField(blank=True, choices=[('Connexion', 'Connection'), ('Adhesion', 'Membership'), ('All', 'Both of them')], max_length=255, null=True, verbose_name='subscription type'),
),
]
......@@ -41,8 +41,7 @@ from django.dispatch import receiver
from django.forms import ValidationError
from django.core.validators import MinValueValidator
from django.utils import timezone
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _l
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse
from django.shortcuts import redirect
from django.contrib import messages
......@@ -58,7 +57,7 @@ from cotisations.validators import check_no_balance
class BaseInvoice(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
date = models.DateTimeField(
auto_now_add=True,
verbose_name=_l("Date")
verbose_name=_("Date")
)
# TODO : change prix to price
......@@ -134,17 +133,17 @@ class Facture(BaseInvoice):
cheque = models.CharField(
max_length=255,
blank=True,
verbose_name=_l("Cheque number")
verbose_name=_("cheque number")
)
# TODO : change name to validity for clarity
valid = models.BooleanField(
default=True,
verbose_name=_l("Validated")
verbose_name=_("validated")
)
# TODO : changed name to controlled for clarity
control = models.BooleanField(
default=False,
verbose_name=_l("Controlled")
verbose_name=_("controlled")
)
class Meta:
......@@ -152,14 +151,14 @@ class Facture(BaseInvoice):
permissions = (
# TODO : change facture to invoice
('change_facture_control',
_l("Can change the \"controlled\" state")),
_("Can edit the \"controlled\" state")),
('view_facture',
_l("Can see an invoice's details")),
_("Can view an invoice object")),
('change_all_facture',
_l("Can edit all the previous invoices")),
_("Can edit all the previous invoices")),
)
verbose_name = _l("Invoice")
verbose_name_plural = _l("Invoices")
verbose_name = _("invoice")
verbose_name_plural = _("invoices")
def linked_objects(self):
"""Return linked objects : machine and domain.
......@@ -195,7 +194,7 @@ class Facture(BaseInvoice):
def can_view(self, user_request, *_args, **_kwargs):
if not user_request.has_perm('cotisations.view_facture') and \
self.user != user_request:
return False, _("You don't have the right to see someone else's "
return False, _("You don't have the right to view someone else's "
"invoices history.")
elif not self.valid:
return False, _("The invoice has been invalidated.")
......@@ -222,7 +221,7 @@ class Facture(BaseInvoice):
if user_request.has_perm('cotisations.add_facture'):
return True, None
if len(Paiement.find_allowed_payments(user_request)) <= 0:
return False, _("There are no payment types which you can use.")
return False, _("There are no payment method which you can use.")
if len(Article.find_allowed_articles(user_request)) <= 0:
return False, _("There are no article that you can buy.")
return True, None
......@@ -259,22 +258,22 @@ def facture_post_delete(**kwargs):
class CustomInvoice(BaseInvoice):
class Meta:
permissions = (
('view_custominvoice', _l("Can view a custom invoice")),
('view_custominvoice', _("Can view a custom invoice object")),
)
recipient = models.CharField(
max_length=255,
verbose_name=_l("Recipient")
verbose_name=_("Recipient")
)
payment = models.CharField(
max_length=255,
verbose_name=_l("Payment type")
verbose_name=_("Payment type")
)
address = models.CharField(
max_length=255,
verbose_name=_l("Address")
verbose_name=_("Address")
)
paid = models.BooleanField(
verbose_name="Paid"
verbose_name=_("Paid")
)
......@@ -294,38 +293,38 @@ class Vente(RevMixin, AclMixin, models.Model):
# TODO : change this to English
COTISATION_TYPE = (
('Connexion', _l("Connexion")),
('Adhesion', _l("Membership")),
('All', _l("Both of them")),
('Connexion', _("Connection")),
('Adhesion', _("Membership")),
('All', _("Both of them")),
)
# TODO : change facture to invoice
facture = models.ForeignKey(
'BaseInvoice',
on_delete=models.CASCADE,
verbose_name=_l("Invoice")
verbose_name=_("invoice")
)
# TODO : change number to amount for clarity
number = models.IntegerField(
validators=[MinValueValidator(1)],
verbose_name=_l("Amount")
verbose_name=_("amount")
)
# TODO : change this field for a ForeinKey to Article
name = models.CharField(
max_length=255,
verbose_name=_l("Article")
verbose_name=_("article")
)
# TODO : change prix to price
# TODO : this field is not needed if you use Article ForeignKey
prix = models.DecimalField(
max_digits=5,
decimal_places=2,
verbose_name=_l("Price"))
verbose_name=_("price"))
# TODO : this field is not needed if you use Article ForeignKey
duration = models.PositiveIntegerField(
blank=True,
null=True,
verbose_name=_l("Duration (in whole month)")
verbose_name=_("duration (in months)")
)
# TODO : this field is not needed if you use Article ForeignKey
type_cotisation = models.CharField(
......@@ -333,16 +332,16 @@ class Vente(RevMixin, AclMixin, models.Model):
blank=True,
null=True,
max_length=255,
verbose_name=_l("Type of cotisation")
verbose_name=_("subscription type")
)
class Meta:
permissions = (
('view_vente', _l("Can see a purchase's details")),
('change_all_vente', _l("Can edit all the previous purchases")),
('view_vente', _("Can view a purchase object")),
('change_all_vente', _("Can edit all the previous purchases")),
)
verbose_name = _l("Purchase")
verbose_name_plural = _l("Purchases")
verbose_name = _("purchase")
verbose_name_plural = _("purchases")
# TODO : change prix_total to total_price
def prix_total(self):
......@@ -409,7 +408,7 @@ class Vente(RevMixin, AclMixin, models.Model):
# Checking that if a cotisation is specified, there is also a duration
if self.type_cotisation and not self.duration:
raise ValidationError(
_("A cotisation should always have a duration.")
_("Duration must be specified for a subscription.")
)
self.update_cotisation()
super(Vente, self).save(*args, **kwargs)
......@@ -445,7 +444,7 @@ class Vente(RevMixin, AclMixin, models.Model):
def can_view(self, user_request, *_args, **_kwargs):
if (not user_request.has_perm('cotisations.view_vente') and
self.facture.user != user_request):
return False, _("You don't have the right to see someone "
return False, _("You don't have the right to view someone "
"else's purchase history.")
else:
return True, None
......@@ -508,38 +507,38 @@ class Article(RevMixin, AclMixin, models.Model):
# TODO : Either use TYPE or TYPES in both choices but not both
USER_TYPES = (
('Adherent', _l("Member")),
('Club', _l("Club")),
('All', _l("Both of them")),
('Adherent', _("Member")),
('Club', _("Club")),
('All', _("Both of them")),
)
COTISATION_TYPE = (
('Connexion', _l("Connexion")),
('Adhesion', _l("Membership")),
('All', _l("Both of them")),
('Connexion', _("Connection")),
('Adhesion', _("Membership")),
('All', _("Both of them")),
)
name = models.CharField(
max_length=255,
verbose_name=_l("Designation")
verbose_name=_("designation")
)
# TODO : change prix to price
prix = models.DecimalField(
max_digits=5,
decimal_places=2,
verbose_name=_l("Unitary price")
verbose_name=_("unit price")
)
duration = models.PositiveIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
verbose_name=_l("Duration (in whole month)")
verbose_name=_("duration (in months)")
)
type_user = models.CharField(
choices=USER_TYPES,
default='All',
max_length=255,
verbose_name=_l("Type of users concerned")
verbose_name=_("type of users concerned")
)
type_cotisation = models.CharField(
choices=COTISATION_TYPE,
......@@ -547,31 +546,31 @@ class Article(RevMixin, AclMixin, models.Model):
blank=True,
null=True,
max_length=255,
verbose_name=_l("Type of cotisation")
verbose_name=_("subscription type")
)
available_for_everyone = models.BooleanField(
default=False,
verbose_name=_l("Is available for every user")
verbose_name=_("is available for every user")
)
unique_together = ('name', 'type_user')
class Meta:
permissions = (
('view_article', _l("Can see an article's details")),
('buy_every_article', _l("Can buy every_article"))
('view_article', _("Can view an article object")),
('buy_every_article', _("Can buy every article"))
)
verbose_name = "Article"
verbose_name_plural = "Articles"
verbose_name = "article"
verbose_name_plural = "articles"
def clean(self):
if self.name.lower() == 'solde':
raise ValidationError(
_("Solde is a reserved article name")
_("Balance is a reserved article name.")
)
if self.type_cotisation and not self.duration:
raise ValidationError(
_("Duration must be specified for a cotisation")
_("Duration must be specified for a subscription.")
)
def __str__(self):
......@@ -592,7 +591,7 @@ class Article(RevMixin, AclMixin, models.Model):
self.available_for_everyone
or user.has_perm('cotisations.buy_every_article')
or user.has_perm('cotisations.add_facture'),
_("You cannot buy this Article.")
_("You can't buy this article.")
)
@classmethod
......@@ -618,15 +617,14 @@ class Banque(RevMixin, AclMixin, models.Model):
name = models.CharField(
max_length=255,
verbose_name=_l("Name")
)
class Meta:
permissions = (
('view_banque', _l("Can see a bank's details")),
('view_banque', _("Can view a bank object")),
)
verbose_name = _l("Bank")
verbose_name_plural = _l("Banks")
verbose_name = _("bank")
verbose_name_plural = _("banks")
def __str__(self):
return self.name
......@@ -644,33 +642,33 @@ class Paiement(RevMixin, AclMixin, models.Model):
# TODO : change moyen to method
moyen = models.CharField(
max_length=255,
verbose_name=_l("Method")
verbose_name=_("method")
)
available_for_everyone = models.BooleanField(
default=False,
verbose_name=_l("Is available for every user")
verbose_name=_("is available for every user")
)
is_balance = models.BooleanField(
default=False,
editable=False,
verbose_name=_l("Is user balance"),
help_text=_l("There should be only one balance payment method."),
verbose_name=_("is user balance"),
help_text=_("There should be only one balance payment method."),
validators=[check_no_balance]
)
class Meta:
permissions = (
('view_paiement', _l("Can see a payement's details")),
('use_every_payment', _l("Can use every payement")),
('view_paiement', _("Can view a payment method object")),
('use_every_payment', _("Can use every payment method")),
)
verbose_name = _l("Payment method")
verbose_name_plural = _l("Payment methods")
verbose_name = _("payment method")
verbose_name_plural = _("payment methods")
def __str__(self):
return self.moyen
def clean(self):
"""
"""l
Override of the herited clean function to get a correct name
"""
self.moyen = self.moyen.title()
......@@ -698,8 +696,8 @@ class Paiement(RevMixin, AclMixin, models.Model):