8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 20:03:11 +00:00

Translation: Fix some lazy translations

This commit is contained in:
Maël Kervella 2018-03-31 15:32:26 +00:00
parent aa02016c3a
commit ccab7ff718
2 changed files with 71 additions and 69 deletions

View file

@ -41,6 +41,7 @@ from django.db.models import Q
from django.forms import ModelForm, Form from django.forms import ModelForm, Form
from django.core.validators import MinValueValidator,MaxValueValidator from django.core.validators import MinValueValidator,MaxValueValidator
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _l
from .models import Article, Paiement, Facture, Banque from .models import Article, Paiement, Facture, Banque
from preferences.models import OptionalUser from preferences.models import OptionalUser
@ -111,11 +112,11 @@ class SelectUserArticleForm(FormRevMixin, Form):
# TODO : translate docstring to English # TODO : translate docstring to English
article = forms.ModelChoiceField( article = forms.ModelChoiceField(
queryset=Article.objects.filter(Q(type_user='All') | Q(type_user='Adherent')), queryset=Article.objects.filter(Q(type_user='All') | Q(type_user='Adherent')),
label=_("Article"), label=_l("Article"),
required=True required=True
) )
quantity = forms.IntegerField( quantity = forms.IntegerField(
label=_("Quantity"), label=_l("Quantity"),
validators=[MinValueValidator(1)], validators=[MinValueValidator(1)],
required=True required=True
) )
@ -126,11 +127,11 @@ class SelectClubArticleForm(Form):
# TODO : translate docstring to English # TODO : translate docstring to English
article = forms.ModelChoiceField( article = forms.ModelChoiceField(
queryset=Article.objects.filter(Q(type_user='All') | Q(type_user='Club')), queryset=Article.objects.filter(Q(type_user='All') | Q(type_user='Club')),
label=_("Article"), label=_l("Article"),
required=True required=True
) )
quantity = forms.IntegerField( quantity = forms.IntegerField(
label=_("Quantity"), label=_l("Quantity"),
validators=[MinValueValidator(1)], validators=[MinValueValidator(1)],
required=True required=True
) )
@ -141,22 +142,22 @@ class NewFactureFormPdf(Form):
# TODO : translate docstring to English # TODO : translate docstring to English
article = forms.ModelMultipleChoiceField( article = forms.ModelMultipleChoiceField(
queryset=Article.objects.all(), queryset=Article.objects.all(),
label=_("Article") label=_l("Article")
) )
number = forms.IntegerField( number = forms.IntegerField(
label=_("Quantity"), label=_l("Quantity"),
validators=[MinValueValidator(1)] validators=[MinValueValidator(1)]
) )
paid = forms.BooleanField(label=_("Paid"), required=False) paid = forms.BooleanField(label=_l("Paid"), required=False)
# TODO : change dest field to recipient # TODO : change dest field to recipient
dest = forms.CharField(required=True, max_length=255, label=_("Recipient")) dest = forms.CharField(required=True, max_length=255, label=_l("Recipient"))
# TODO : change chambre field to address # TODO : change chambre field to address
chambre = forms.CharField(required=False, max_length=10, label=_("Address")) chambre = forms.CharField(required=False, max_length=10, label=_l("Address"))
# TODO : change fid field to invoice_id # TODO : change fid field to invoice_id
fid = forms.CharField( fid = forms.CharField(
required=True, required=True,
max_length=10, max_length=10,
label=_("Invoice number") label=_l("Invoice number")
) )
# TODO : change Facture to Invoice # TODO : change Facture to Invoice
@ -196,7 +197,7 @@ class DelArticleForm(FormRevMixin, Form):
# TODO : translate docstring to English # TODO : translate docstring to English
articles = forms.ModelMultipleChoiceField( articles = forms.ModelMultipleChoiceField(
queryset=Article.objects.none(), queryset=Article.objects.none(),
label=_("Existing articles"), label=_l("Existing articles"),
widget=forms.CheckboxSelectMultiple widget=forms.CheckboxSelectMultiple
) )
@ -238,7 +239,7 @@ class DelPaiementForm(FormRevMixin, Form):
# TODO : change paiement to payment # TODO : change paiement to payment
paiements = forms.ModelMultipleChoiceField( paiements = forms.ModelMultipleChoiceField(
queryset=Paiement.objects.none(), queryset=Paiement.objects.none(),
label=_("Existing payment method"), label=_l("Existing payment method"),
widget=forms.CheckboxSelectMultiple widget=forms.CheckboxSelectMultiple
) )
@ -273,7 +274,7 @@ class DelBanqueForm(FormRevMixin, Form):
# TODO : change banque to bank # TODO : change banque to bank
banques = forms.ModelMultipleChoiceField( banques = forms.ModelMultipleChoiceField(
queryset=Banque.objects.none(), queryset=Banque.objects.none(),
label=_("Existing banks"), label=_l("Existing banks"),
widget=forms.CheckboxSelectMultiple widget=forms.CheckboxSelectMultiple
) )
@ -335,7 +336,7 @@ class NewFactureSoldeForm(NewFactureForm):
# TODO : Better name and docstring # TODO : Better name and docstring
class RechargeForm(FormRevMixin, Form): class RechargeForm(FormRevMixin, Form):
value = forms.FloatField( value = forms.FloatField(
label=_("Amount"), label=_l("Amount"),
min_value=0.01, min_value=0.01,
validators = [] validators = []
) )

View file

@ -57,6 +57,7 @@ from django.db.models import Max
from django.utils import timezone from django.utils import timezone
from machines.models import regen from machines.models import regen
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _l
from re2o.field_permissions import FieldPermissionModelMixin from re2o.field_permissions import FieldPermissionModelMixin
from re2o.mixins import AclMixin, RevMixin from re2o.mixins import AclMixin, RevMixin
@ -84,35 +85,35 @@ class Facture(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
cheque = models.CharField( cheque = models.CharField(
max_length=255, max_length=255,
blank=True, blank=True,
verbose_name=_("Cheque number") verbose_name=_l("Cheque number")
) )
date = models.DateTimeField( date = models.DateTimeField(
auto_now_add=True, auto_now_add=True,
verbose_name=_("Date") verbose_name=_l("Date")
) )
# TODO : change name to validity for clarity # TODO : change name to validity for clarity
valid = models.BooleanField( valid = models.BooleanField(
default=True, default=True,
verbose_name=_("Validated") verbose_name=_l("Validated")
) )
# TODO : changed name to controlled for clarity # TODO : changed name to controlled for clarity
control = models.BooleanField( control = models.BooleanField(
default=False, default=False,
verbose_name=_("Controlled") verbose_name=_l("Controlled")
) )
class Meta: class Meta:
abstract = False abstract = False
permissions = ( permissions = (
# TODO : change facture to invoice # TODO : change facture to invoice
('change_facture_control', _("Can change the \"controlled\" state")), ('change_facture_control', _l("Can change the \"controlled\" state")),
# TODO : seems more likely to be call create_facture_pdf or create_invoice_pdf # TODO : seems more likely to be call create_facture_pdf or create_invoice_pdf
('change_facture_pdf', _("Can create a custom PDF invoice")), ('change_facture_pdf', _l("Can create a custom PDF invoice")),
('view_facture', _("Can see an invoice's details")), ('view_facture', _l("Can see an invoice's details")),
('change_all_facture', _("Can edit all the previous invoices")), ('change_all_facture', _l("Can edit all the previous invoices")),
) )
verbose_name = _("Invoice") verbose_name = _l("Invoice")
verbose_name_plural = _("Invoices") verbose_name_plural = _l("Invoices")
def linked_objects(self): def linked_objects(self):
"""Return linked objects : machine and domain. """Return linked objects : machine and domain.
@ -227,38 +228,38 @@ class Vente(RevMixin, AclMixin, models.Model):
# TODO : change this to English # TODO : change this to English
COTISATION_TYPE = ( COTISATION_TYPE = (
('Connexion', _("Connexion")), ('Connexion', _l("Connexion")),
('Adhesion', _("Membership")), ('Adhesion', _l("Membership")),
('All', _("Both of them")), ('All', _l("Both of them")),
) )
# TODO : change facture to invoice # TODO : change facture to invoice
facture = models.ForeignKey( facture = models.ForeignKey(
'Facture', 'Facture',
on_delete=models.CASCADE, on_delete=models.CASCADE,
verbose_name=_("Invoice") verbose_name=_l("Invoice")
) )
# TODO : change number to amount for clarity # TODO : change number to amount for clarity
number = models.IntegerField( number = models.IntegerField(
validators=[MinValueValidator(1)], validators=[MinValueValidator(1)],
verbose_name=_("Amount") verbose_name=_l("Amount")
) )
# TODO : change this field for a ForeinKey to Article # TODO : change this field for a ForeinKey to Article
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
verbose_name=_("Article") verbose_name=_l("Article")
) )
# TODO : change prix to price # TODO : change prix to price
# TODO : this field is not needed if you use Article ForeignKey # TODO : this field is not needed if you use Article ForeignKey
prix = models.DecimalField( prix = models.DecimalField(
max_digits=5, max_digits=5,
decimal_places=2, decimal_places=2,
verbose_name=_("Price")) verbose_name=_l("Price"))
# TODO : this field is not needed if you use Article ForeignKey # TODO : this field is not needed if you use Article ForeignKey
duration = models.PositiveIntegerField( duration = models.PositiveIntegerField(
blank=True, blank=True,
null=True, null=True,
verbose_name=_("Duration (in whole month)") verbose_name=_l("Duration (in whole month)")
) )
# TODO : this field is not needed if you use Article ForeignKey # TODO : this field is not needed if you use Article ForeignKey
type_cotisation = models.CharField( type_cotisation = models.CharField(
@ -266,16 +267,16 @@ class Vente(RevMixin, AclMixin, models.Model):
blank=True, blank=True,
null=True, null=True,
max_length=255, max_length=255,
verbose_name=_("Type of cotisation") verbose_name=_l("Type of cotisation")
) )
class Meta: class Meta:
permissions = ( permissions = (
('view_vente', _("Can see a purchase's details")), ('view_vente', _l("Can see a purchase's details")),
('change_all_vente', _("Can edit all the previous purchases")), ('change_all_vente', _l("Can edit all the previous purchases")),
) )
verbose_name = _("Purchase") verbose_name = _l("Purchase")
verbose_name_plural = _("Purchases") verbose_name_plural = _l("Purchases")
# TODO : change prix_total to total_price # TODO : change prix_total to total_price
@ -406,38 +407,38 @@ class Article(RevMixin, AclMixin, models.Model):
# TODO : Either use TYPE or TYPES in both choices but not both # TODO : Either use TYPE or TYPES in both choices but not both
USER_TYPES = ( USER_TYPES = (
('Adherent', _("Member")), ('Adherent', _l("Member")),
('Club', _("Club")), ('Club', _l("Club")),
('All', _("Both of them")), ('All', _l("Both of them")),
) )
COTISATION_TYPE = ( COTISATION_TYPE = (
('Connexion', _("Connexion")), ('Connexion', _l("Connexion")),
('Adhesion', _("Membership")), ('Adhesion', _l("Membership")),
('All', _("Both of them")), ('All', _l("Both of them")),
) )
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
verbose_name=_("Designation") verbose_name=_l("Designation")
) )
# TODO : change prix to price # TODO : change prix to price
prix = models.DecimalField( prix = models.DecimalField(
max_digits=5, max_digits=5,
decimal_places=2, decimal_places=2,
verbose_name=_("Unitary price") verbose_name=_l("Unitary price")
) )
duration = models.PositiveIntegerField( duration = models.PositiveIntegerField(
blank=True, blank=True,
null=True, null=True,
validators=[MinValueValidator(0)], validators=[MinValueValidator(0)],
verbose_name=_("Duration (in whole month)") verbose_name=_l("Duration (in whole month)")
) )
type_user = models.CharField( type_user = models.CharField(
choices=USER_TYPES, choices=USER_TYPES,
default='All', default='All',
max_length=255, max_length=255,
verbose_name=_("Type of users concerned") verbose_name=_l("Type of users concerned")
) )
type_cotisation = models.CharField( type_cotisation = models.CharField(
choices=COTISATION_TYPE, choices=COTISATION_TYPE,
@ -445,14 +446,14 @@ class Article(RevMixin, AclMixin, models.Model):
blank=True, blank=True,
null=True, null=True,
max_length=255, max_length=255,
verbose_name=_("Type of cotisation") verbose_name=_l("Type of cotisation")
) )
unique_together = ('name', 'type_user') unique_together = ('name', 'type_user')
class Meta: class Meta:
permissions = ( permissions = (
('view_article', _("Can see an article's details")), ('view_article', _l("Can see an article's details")),
) )
verbose_name = "Article" verbose_name = "Article"
verbose_name_plural = "Articles" verbose_name_plural = "Articles"
@ -477,15 +478,15 @@ class Banque(RevMixin, AclMixin, models.Model):
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
verbose_name=_("Name") verbose_name=_l("Name")
) )
class Meta: class Meta:
permissions = ( permissions = (
('view_banque', _("Can see a bank's details")), ('view_banque', _l("Can see a bank's details")),
) )
verbose_name=_("Bank") verbose_name=_l("Bank")
verbose_name_plural=_("Banks") verbose_name_plural=_l("Banks")
def __str__(self): def __str__(self):
return self.name return self.name
@ -497,27 +498,27 @@ class Paiement(RevMixin, AclMixin, models.Model):
# TODO : translate docstring to English # TODO : translate docstring to English
PAYMENT_TYPES = ( PAYMENT_TYPES = (
(0, _("Standard")), (0, _l("Standard")),
(1, _("Cheque")), (1, _l("Cheque")),
) )
# TODO : change moyen to method # TODO : change moyen to method
moyen = models.CharField( moyen = models.CharField(
max_length=255, max_length=255,
verbose_name=_("Method") verbose_name=_l("Method")
) )
type_paiement = models.IntegerField( type_paiement = models.IntegerField(
choices=PAYMENT_TYPES, choices=PAYMENT_TYPES,
default=0, default=0,
verbose_name=_("Payment type") verbose_name=_l("Payment type")
) )
class Meta: class Meta:
permissions = ( permissions = (
('view_paiement', _("Can see a payement's details")), ('view_paiement', _l("Can see a payement's details")),
) )
verbose_name = _("Payment method") verbose_name = _l("Payment method")
verbose_name_plural = _("Payment methods") verbose_name_plural = _l("Payment methods")
def __str__(self): def __str__(self):
return self.moyen return self.moyen
@ -540,9 +541,9 @@ class Cotisation(RevMixin, AclMixin, models.Model):
# TODO : translate docstring to English # TODO : translate docstring to English
COTISATION_TYPE = ( COTISATION_TYPE = (
('Connexion', _("Connexion")), ('Connexion', _l("Connexion")),
('Adhesion', _("Membership")), ('Adhesion', _l("Membership")),
('All', _("Both of them")), ('All', _l("Both of them")),
) )
# TODO : change vente to purchase # TODO : change vente to purchase
@ -550,25 +551,25 @@ class Cotisation(RevMixin, AclMixin, models.Model):
'Vente', 'Vente',
on_delete=models.CASCADE, on_delete=models.CASCADE,
null=True, null=True,
verbose_name=_("Purchase") verbose_name=_l("Purchase")
) )
type_cotisation = models.CharField( type_cotisation = models.CharField(
choices=COTISATION_TYPE, choices=COTISATION_TYPE,
max_length=255, max_length=255,
default='All', default='All',
verbose_name=_("Type of cotisation") verbose_name=_l("Type of cotisation")
) )
date_start = models.DateTimeField( date_start = models.DateTimeField(
verbose_name=_("Starting date") verbose_name=_l("Starting date")
) )
date_end = models.DateTimeField( date_end = models.DateTimeField(
verbose_name=_("Ending date") verbose_name=_l("Ending date")
) )
class Meta: class Meta:
permissions = ( permissions = (
('view_cotisation', _("Can see a cotisation's details")), ('view_cotisation', _l("Can see a cotisation's details")),
('change_all_cotisation', _("Can edit the previous cotisations")), ('change_all_cotisation', _l("Can edit the previous cotisations")),
) )
def can_edit(self, user_request, *args, **kwargs): def can_edit(self, user_request, *args, **kwargs):