From 0cc15d63c869f41edbe374a4ba979448021940fb Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 26 Jul 2018 21:53:32 +0200 Subject: [PATCH] Traduction + utilisation du mixin de revision --- preferences/admin.py | 2 +- preferences/forms.py | 8 +- preferences/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 1245 bytes preferences/locale/fr/LC_MESSAGES/django.po | 70 ++++++++++++++++++ preferences/migrations/0046_mailcontact.py | 6 +- preferences/models.py | 10 ++- .../preferences/aff_mailcontact.html | 6 +- .../preferences/display_preferences.html | 6 +- preferences/views.py | 39 ++++------ 9 files changed, 108 insertions(+), 39 deletions(-) create mode 100644 preferences/locale/fr/LC_MESSAGES/django.mo create mode 100644 preferences/locale/fr/LC_MESSAGES/django.po diff --git a/preferences/admin.py b/preferences/admin.py index 043370db..5ca90095 100644 --- a/preferences/admin.py +++ b/preferences/admin.py @@ -67,7 +67,7 @@ class ServiceAdmin(VersionAdmin): class MailContactAdmin(VersionAdmin): - """Class admin gestion des adresses mail de contact""" + """Admin class for contact email adresses""" pass diff --git a/preferences/forms.py b/preferences/forms.py index 193beca8..99910f9c 100644 --- a/preferences/forms.py +++ b/preferences/forms.py @@ -27,6 +27,8 @@ from __future__ import unicode_literals from django.forms import ModelForm, Form from django import forms + +from re2o.mixins import FormRevMixin from .models import ( OptionalUser, OptionalMachine, @@ -229,8 +231,8 @@ class DelServiceForm(Form): else: self.fields['services'].queryset = Service.objects.all() -class MailContactForm(ModelForm): - """Edition, ajout d'adresse de contact""" +class MailContactForm(FormRevMixin, ModelForm): + """Edit and add contact email adress""" class Meta: model = MailContact fields = '__all__' @@ -241,7 +243,7 @@ class MailContactForm(ModelForm): class DelMailContactForm(Form): - """Suppression d'adresse de contact""" + """Delete contact email adress""" mailcontacts = forms.ModelMultipleChoiceField( queryset=MailContact.objects.none(), label="Enregistrements adresses actuels", diff --git a/preferences/locale/fr/LC_MESSAGES/django.mo b/preferences/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..21ed01a47b5f1f12bd59e566a77fbaba297530be GIT binary patch literal 1245 zcmZ{jO=}ZD7{^DgZ_#?NN~J13Afi$>CPB1rZE>TVRYy$QZ zX4cX^#>T-KcnEv|o(3O-r$7y!1-Ekld+-AGAHiwx3pfV;08QL4(Bzre&)6h51)c{h z;39l2(A0l(fU(2i2hjBO2|NRS1uuf%!K2_flAHY`cmc^_zIi?--1T} z8AQ44ZU;e=%PbRXmg&*_CTNEpfkB?-IS!(9whB2jI6**OL|!1dQp_1)0Vj%c^5aN* zz9!!HM93EQ?zSWTb;uQkLTOgzA=f+y#Sy1iQa=r~NJ5?`;0k`_OOa?1M-;D-UWZSq z*cYDW!KijFE;2U|nz^Q({D{&dFuEdZqf7aebxnA74SMD&@+BX+&3Sf@z1|?}5Wy`O zZ*X5*wZK~CQlS-_TF%0K=blTeZo5-!E*IK7iKVt0swV>LZrW2;H@2zJYIdy!Qw2d* z6~%0-l*%(!>84e=L6x$7{nm7;QYt}cwfUwn$#dO9*J)dgrd4%lscAQA(~p|VZlUfe zZFQv=snFB0v}tjrUZ-WJ;nHol;neDPoNBf0b~^KrM!nSQp=6;^Yq-0;my4x>c^V!e z)r$lI&7bRQN$81ami%>3Dz4{Nx{KD#uFjNPdea>BpXr9VfXA8{Ph*QlarFiSnBk+8tIBW4#(`GD;m$DZOb|!3Fl)um( zM;(L2DZohO`PAQ, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-26 21:49+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: models.py:256 +msgid "Contact email adress" +msgstr "Adresse email de contact" + +#: models.py:263 +msgid "Description of the associated email adress." +msgstr "Description de l'adresse mail associée." + +#: models.py:273 +msgid "Can see contact email" +msgstr "Peut voir un mail de contact" + +#: templates/preferences/aff_mailcontact.html:30 +msgid "Adress" +msgstr "Adresse" + +#: templates/preferences/aff_mailcontact.html:31 +msgid "Remark" +msgstr "Commentaire" + +#: templates/preferences/display_preferences.html:205 +msgid "Contact email adresses list" +msgstr "Liste des adresses email de contact" + +#: templates/preferences/display_preferences.html:207 +msgid "Add an adress" +msgstr "Ajouter une adresse" + +#: templates/preferences/display_preferences.html:209 +msgid "Delete one or multiple adresses" +msgstr "Supprimer une ou plusieurs adresses" + +#: views.py:210 +msgid "The adress was created." +msgstr "L'adresse a été créée." + +#: views.py:230 +msgid "Email adress updated." +msgstr "L'adresse email a été mise à jour." + +#: views.py:233 +msgid "Edit" +msgstr "Éditer" + +#: views.py:251 +msgid "The email adress was deleted." +msgstr "L'adresse email a été supprimée." + +#: views.py:254 +msgid "Delete" +msgstr "Supprimer" diff --git a/preferences/migrations/0046_mailcontact.py b/preferences/migrations/0046_mailcontact.py index 0c6705e7..1364ff66 100644 --- a/preferences/migrations/0046_mailcontact.py +++ b/preferences/migrations/0046_mailcontact.py @@ -17,11 +17,11 @@ class Migration(migrations.Migration): name='MailContact', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('address', models.EmailField(default='contact@example.org', help_text='Adresse mail de contact', max_length=254)), - ('commentary', models.CharField(blank=True, help_text="Description de l'utilisation de l'adresse mail associée", max_length=256, null=True)), + ('address', models.EmailField(default='contact@example.org', help_text="Contact email adress", max_length=254)), + ('commentary', models.CharField(blank=True, help_text="Description of the associated email adress.", max_length=256, null=True)), ], options={ - 'permissions': (('view_mailcontact', 'Peut voir les mails de contact'),), + 'permissions': (('view_mailcontact', "Can see contact email"),), }, bases=(re2o.mixins.AclMixin, models.Model), ), diff --git a/preferences/models.py b/preferences/models.py index f7d42c10..9226bd4a 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -31,6 +31,7 @@ from django.db.models.signals import post_save from django.dispatch import receiver from django.core.cache import cache from django.forms import ValidationError +from django.utils.translation import ugettext_lazy as _ import machines.models from re2o.mixins import AclMixin @@ -268,17 +269,18 @@ class Service(AclMixin, models.Model): return str(self.name) class MailContact(AclMixin, models.Model): - """Addresse mail de contact associée à un commentaire descriptif""" + """Contact email adress with a commentary.""" address = models.EmailField( default = "contact@example.org", - help_text = "Adresse mail de contact" + help_text = _("Contact email adress") ) commentary = models.CharField( blank = True, null = True, - help_text = "Description de l'utilisation de l'adresse mail associée", + help_text = _( + "Description of the associated email adress."), max_length = 256 ) @@ -288,7 +290,7 @@ class MailContact(AclMixin, models.Model): class Meta: permissions = ( - ("view_mailcontact", "Peut voir les mails de contact"), + ("view_mailcontact", _("Can see contact email")), ) def __str__(self): diff --git a/preferences/templates/preferences/aff_mailcontact.html b/preferences/templates/preferences/aff_mailcontact.html index 76e11d70..a87e03bb 100644 --- a/preferences/templates/preferences/aff_mailcontact.html +++ b/preferences/templates/preferences/aff_mailcontact.html @@ -21,12 +21,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} +{% load i18n %} {% load acl %} +{% load logs_extra %} - - + + diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index eb2fcea8..5d2e2dd0 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load bootstrap3 %} {% load acl %} {% load design %} +{% load i18n %} {% block title %}Création et modification des préférences{% endblock %} @@ -222,10 +223,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,

Liste des adresses mail de contact

+

{% trans "Contact email adresses list" %}

{% can_create preferences.MailContact%} - Ajouter une adresse + {% trans "Add an adress" %} {% acl_end %} - Supprimer une ou plusieurs adresses + {% trans "Delete one or multiple adresses" %} {% include "preferences/aff_mailcontact.html" with mailcontact_list=mailcontact_list %}

diff --git a/preferences/views.py b/preferences/views.py index 1ad0b42d..3c0c4879 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -36,13 +36,16 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.db.models import ProtectedError from django.db import transaction +from django.utils.translation import ugettext as _ from reversion import revisions as reversion from re2o.views import form from re2o.acl import can_create, can_edit, can_delete_set, can_view_all -from .forms import ServiceForm, DelServiceForm, MailContactForm, DelMailContactForm +from .forms import ( + ServiceForm, DelServiceForm, MailContactForm, DelMailContactForm +) from .models import ( Service, MailContact, @@ -197,17 +200,14 @@ def del_service(request, instances): @login_required @can_create(MailContact) def add_mailcontact(request): - """Ajout d'une adresse de contact""" + """Add a contact email adress.""" mailcontact = MailContactForm( request.POST or None, request.FILES or None ) if mailcontact.is_valid(): - with transaction.atomic(), reversion.create_revision(): - mailcontact.save() - reversion.set_user(request.user) - reversion.set_comment("Création") - messages.success(request, "Cette adresse a été ajoutée") + mailcontact.save() + messages.success(request, _("The adress was created.")) return redirect(reverse('preferences:display-options')) return form( {'preferenceform': mailcontact, 'action_name': 'Ajouter'}, @@ -219,21 +219,18 @@ def add_mailcontact(request): @login_required @can_edit(MailContact) def edit_mailcontact(request, mailcontact_instance, **_kwargs): - """Edition des adresses de contacte affichées""" + """Edit contact email adress.""" mailcontact = MailContactForm( request.POST or None, request.FILES or None, instance=mailcontact_instance ) if mailcontact.is_valid(): - with transaction.atomic(), reversion.create_revision(): - mailcontact.save() - reversion.set_user(request.user) - reversion.set_comment("Modification") - messages.success(request, "Adresse modifiée") + mailcontact.save() + messages.success(request, _("Email adress updated.")) return redirect(reverse('preferences:display-options')) return form( - {'preferenceform': mailcontact, 'action_name': 'Editer'}, + {'preferenceform': mailcontact, 'action_name': _('Edit')}, 'preferences/preferences.html', request ) @@ -242,7 +239,7 @@ def edit_mailcontact(request, mailcontact_instance, **_kwargs): @login_required @can_delete_set(MailContact) def del_mailcontact(request, instances): - """Suppression d'une adresse de contact""" + """Delete an email adress""" mailcontacts = DelMailContactForm( request.POST or None, instances=instances @@ -250,17 +247,11 @@ def del_mailcontact(request, instances): if mailcontacts.is_valid(): mailcontacts_dels = mailcontacts.cleaned_data['mailcontacts'] for mailcontacts_del in mailcontacts_dels: - try: - with transaction.atomic(), reversion.create_revision(): - mailcontacts_del.delete() - reversion.set_user(request.user) - messages.success(request, "L'adresse a été supprimée") - except ProtectedError: - messages.error(request, "Erreur le service\ - suivant %s ne peut être supprimé" % mailcontacts_del) + mailcontacts_del.delete() + messages.success(request, _("The email adress was deleted.")) return redirect(reverse('preferences:display-options')) return form( - {'preferenceform': mailcontacts, 'action_name': 'Supprimer'}, + {'preferenceform': mailcontacts, 'action_name': _('Delete')}, 'preferences/preferences.html', request )

AdresseCommentaire{% trans "Adress" %}{% trans "Remark" %}