Commit c3b3146f authored by Fernet Laouen's avatar Fernet Laouen

Translation of preferences/ (front)

parent 34bf50e7
......@@ -25,6 +25,7 @@
Here are defined some functions to check acl on the application.
"""
from django.utils.translation import ugettext as _
def can_view(user):
......@@ -38,4 +39,6 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can = user.has_module_perms('preferences')
return can, None if can else "Vous ne pouvez pas voir cette application."
return can, None if can else _("You don't have the right to view this"
" application.")
......@@ -27,7 +27,7 @@ from __future__ import unicode_literals
from django.forms import ModelForm, Form
from django import forms
from django.utils.translation import ugettext_lazy as _
from re2o.mixins import FormRevMixin
from .models import (
OptionalUser,
......@@ -56,9 +56,13 @@ class EditOptionalUserForm(ModelForm):
**kwargs
)
self.fields['is_tel_mandatory'].label = (
'Exiger un numéro de téléphone'
_("Telephone number required")
)
self.fields['self_adhesion'].label = 'Auto inscription'
self.fields['gpg_fingerprint'].label = _("GPG fingerprint")
self.fields['all_can_create_club'].label = _("All can create a club")
self.fields['all_can_create_adherent'].label = _("All can create a member")
self.fields['self_adhesion'].label = _("Self registration")
self.fields['shell_default'].label = _("Default shell")
class EditOptionalMachineForm(ModelForm):
......@@ -74,12 +78,17 @@ class EditOptionalMachineForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['password_machine'].label = "Possibilité d'attribuer\
un mot de passe par interface"
self.fields['max_lambdauser_interfaces'].label = "Maximum\
d'interfaces autorisées pour un user normal"
self.fields['max_lambdauser_aliases'].label = "Maximum d'alias\
dns autorisés pour un user normal"
self.fields['password_machine'].label = _("Possibility to set a"
" password per machine")
self.fields['max_lambdauser_interfaces'].label = _("Maximum number of"
" interfaces"
" allowed for a"
" standard user")
self.fields['max_lambdauser_aliases'].label = _("Maximum number of DNS"
" aliases allowed for"
" a standard user")
self.fields['ipv6_mode'].label = _("IPv6 mode")
self.fields['create_machine'].label = _("Can create a machine")
class EditOptionalTopologieForm(ModelForm):
......@@ -95,10 +104,11 @@ class EditOptionalTopologieForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['vlan_decision_ok'].label = "Vlan où placer les\
machines après acceptation RADIUS"
self.fields['vlan_decision_nok'].label = "Vlan où placer les\
machines après rejet RADIUS"
self.fields['radius_general_policy'].label = _("RADIUS general policy")
self.fields['vlan_decision_ok'].label = _("VLAN for machines accepted"
" by RADIUS")
self.fields['vlan_decision_nok'].label = _("VLAN for machines rejected"
" by RADIUS")
class EditGeneralOptionForm(ModelForm):
......@@ -114,18 +124,25 @@ class EditGeneralOptionForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['search_display_page'].label = 'Resultats\
affichés dans une recherche'
self.fields['pagination_number'].label = 'Items par page,\
taille normale (ex users)'
self.fields['pagination_large_number'].label = 'Items par page,\
taille élevée (machines)'
self.fields['req_expire_hrs'].label = 'Temps avant expiration du lien\
de reinitialisation de mot de passe (en heures)'
self.fields['site_name'].label = 'Nom du site web'
self.fields['email_from'].label = "Adresse mail d\
'expedition automatique"
self.fields['GTU_sum_up'].label = "Résumé des CGU"
self.fields['general_message'].label = _("General message")
self.fields['search_display_page'].label = _("Number of results"
" displayed when"
" searching")
self.fields['pagination_number'].label = _("Number of items per page,"
" standard size (e.g."
" users)")
self.fields['pagination_large_number'].label = _("Number of items per"
" page, large size"
" (e.g. machines)")
self.fields['req_expire_hrs'].label = _("Time before expiration of the"
" reset password link (in"
" hours)")
self.fields['site_name'].label = _("Website name")
self.fields['email_from'].label = _("Email address for automatic"
" emailing")
self.fields['GTU_sum_up'].label = _("Summary of the General Terms of"
" Use")
self.fields['GTU'].label = _("General Terms of Use")
class EditAssoOptionForm(ModelForm):
......@@ -141,15 +158,19 @@ class EditAssoOptionForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['name'].label = 'Nom de l\'asso'
self.fields['siret'].label = 'SIRET'
self.fields['adresse1'].label = 'Adresse (ligne 1)'
self.fields['adresse2'].label = 'Adresse (ligne 2)'
self.fields['contact'].label = 'Email de contact'
self.fields['telephone'].label = 'Numéro de téléphone'
self.fields['pseudo'].label = 'Pseudo d\'usage'
self.fields['utilisateur_asso'].label = 'Compte utilisé pour\
faire les modifications depuis /admin'
self.fields['name'].label = _("Organisation name")
self.fields['siret'].label = _("SIRET number")
self.fields['adresse1'].label = _("Address (line 1)")
self.fields['adresse2'].label = _("Address (line 2)")
self.fields['contact'].label = _("Contact email address")
self.fields['telephone'].label = _("Telephone number")
self.fields['pseudo'].label = _("Usual name")
self.fields['utilisateur_asso'].label = _("Account used for editing"
" from /admin")
self.fields['payment'].label = _("Payment")
self.fields['payment_id'].label = _("Payment ID")
self.fields['payment_pass'].label = _("Payment password")
self.fields['description'].label = _("Description")
class EditMailMessageOptionForm(ModelForm):
......@@ -165,10 +186,10 @@ class EditMailMessageOptionForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['welcome_mail_fr'].label = 'Message dans le\
mail de bienvenue en français'
self.fields['welcome_mail_en'].label = 'Message dans le\
mail de bienvenue en anglais'
self.fields['welcome_mail_fr'].label = _("Message for the French"
" welcome email")
self.fields['welcome_mail_en'].label = _("Message for the English"
" welcome email")
class EditHomeOptionForm(ModelForm):
......@@ -184,6 +205,9 @@ class EditHomeOptionForm(ModelForm):
prefix=prefix,
**kwargs
)
self.fields['facebook_url'].label = _("Facebook URL")
self.fields['twitter_url'].label = _("Twitter URL")
self.fields['twitter_account_name'].label = _("Twitter account name")
class ServiceForm(ModelForm):
......@@ -195,13 +219,17 @@ class ServiceForm(ModelForm):
def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['name'].label = _("Name")
self.fields['url'].label = _("URL")
self.fields['description'].label = _("Description")
self.fields['image'].label = _("Image")
class DelServiceForm(Form):
"""Suppression de services sur la page d'accueil"""
services = forms.ModelMultipleChoiceField(
queryset=Service.objects.none(),
label="Enregistrements service actuels",
label=_("Current services"),
widget=forms.CheckboxSelectMultiple
)
......@@ -239,3 +267,4 @@ class DelMailContactForm(Form):
self.fields['mailcontacts'].queryset = instances
else:
self.fields['mailcontacts'].queryset = MailContact.objects.all()
This diff is collapsed.
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-08-18 11:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0049_optionaluser_self_change_shell'),
]
operations = [
migrations.AlterModelOptions(
name='assooption',
options={'permissions': (('view_assooption', 'Can view the organisation options'),), 'verbose_name': 'organisation options'},
),
migrations.AlterModelOptions(
name='generaloption',
options={'permissions': (('view_generaloption', 'Can view the general options'),), 'verbose_name': 'general options'},
),
migrations.AlterModelOptions(
name='homeoption',
options={'permissions': (('view_homeoption', 'Can view the homepage options'),), 'verbose_name': 'homepage options'},
),
migrations.AlterModelOptions(
name='mailcontact',
options={'permissions': (('view_mailcontact', 'Can view a contact email address object'),), 'verbose_name': 'contact email address', 'verbose_name_plural': 'contact email addresses'},
),
migrations.AlterModelOptions(
name='mailmessageoption',
options={'permissions': (('view_mailmessageoption', 'Can view the email message options'),), 'verbose_name': 'email message options'},
),
migrations.AlterModelOptions(
name='optionalmachine',
options={'permissions': (('view_optionalmachine', 'Can view the machine options'),), 'verbose_name': 'machine options'},
),
migrations.AlterModelOptions(
name='optionaltopologie',
options={'permissions': (('view_optionaltopologie', 'Can view the topology options'),), 'verbose_name': 'topology options'},
),
migrations.AlterModelOptions(
name='optionaluser',
options={'permissions': (('view_optionaluser', 'Can view the user options'),), 'verbose_name': 'user options'},
),
migrations.AlterModelOptions(
name='service',
options={'permissions': (('view_service', 'Can view the service options'),), 'verbose_name': 'service', 'verbose_name_plural': 'services'},
),
migrations.AlterField(
model_name='assooption',
name='adresse1',
field=models.CharField(default='Threadneedle Street', max_length=128),
),
migrations.AlterField(
model_name='assooption',
name='adresse2',
field=models.CharField(default='London EC2R 8AH', max_length=128),
),
migrations.AlterField(
model_name='assooption',
name='name',
field=models.CharField(default='Networking organisation school Something', max_length=256),
),
migrations.AlterField(
model_name='assooption',
name='pseudo',
field=models.CharField(default='Organisation', max_length=32),
),
migrations.AlterField(
model_name='generaloption',
name='general_message_en',
field=models.TextField(blank=True, default='', help_text='General message displayed on the English version of the website (e.g. in case of maintenance)'),
),
migrations.AlterField(
model_name='generaloption',
name='general_message_fr',
field=models.TextField(blank=True, default='', help_text='General message displayed on the French version of the website (e.g. in case of maintenance)'),
),
migrations.AlterField(
model_name='homeoption',
name='facebook_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='homeoption',
name='twitter_account_name',
field=models.CharField(blank=True, max_length=32, null=True),
),
migrations.AlterField(
model_name='homeoption',
name='twitter_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='mailcontact',
name='address',
field=models.EmailField(default='contact@example.org', help_text='Contact email address', max_length=254),
),
migrations.AlterField(
model_name='mailcontact',
name='commentary',
field=models.CharField(blank=True, help_text='Description of the associated email address.', max_length=256, null=True),
),
migrations.AlterField(
model_name='optionalmachine',
name='create_machine',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='optionalmachine',
name='ipv6_mode',
field=models.CharField(choices=[('SLAAC', 'Autoconfiguration by RA'), ('DHCPV6', 'IP addresses assigning by DHCPv6'), ('DISABLED', 'Disabled')], default='DISABLED', max_length=32),
),
migrations.AlterField(
model_name='optionaltopologie',
name='radius_general_policy',
field=models.CharField(choices=[('MACHINE', "On the IP range's VLAN of the machine"), ('DEFINED', "Preset in 'VLAN for machines accepted by RADIUS'")], default='DEFINED', max_length=32),
),
migrations.AlterField(
model_name='optionaluser',
name='all_can_create_adherent',
field=models.BooleanField(default=False, help_text='Users can create a member'),
),
migrations.AlterField(
model_name='optionaluser',
name='all_can_create_club',
field=models.BooleanField(default=False, help_text='Users can create a club'),
),
migrations.AlterField(
model_name='optionaluser',
name='max_email_address',
field=models.IntegerField(default=15, help_text='Maximum number of local email addresses for a standard user'),
),
migrations.AlterField(
model_name='optionaluser',
name='self_adhesion',
field=models.BooleanField(default=False, help_text='A new user can create their account on Re2o'),
),
migrations.AlterField(
model_name='optionaluser',
name='self_change_shell',
field=models.BooleanField(default=False, help_text='Users can edit their shell'),
),
]
This diff is collapsed.
......@@ -24,24 +24,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load i18n %}
{% load acl %}
{% load logs_extra %}
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Adress" %}</th>
<th>{% trans "Remark" %}</th>
<th></th>
</tr>
</thead>
{% for mailcontact in mailcontact_list %}
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Address" %}</th>
<th>{% trans "Comment" %}</th>
<th></th>
</tr>
</thead>
{% for mailcontact in mailcontact_list %}
<tr>
<td>{{ mailcontact.address }}</td>
<td>{{ mailcontact.commentary }}</td>
<td class="text-right">
{% can_edit mailcontact %}
{% include 'buttons/edit.html' with href='preferences:edit-mailcontact' id=mailcontact.id %}
{% acl_end %}
{% history_button mailcontact %}
{% can_edit mailcontact %}
{% include 'buttons/edit.html' with href='preferences:edit-mailcontact' id=mailcontact.id %}
{% acl_end %}
{% history_button mailcontact %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>
......@@ -23,30 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load logs_extra %}
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th>Url</th>
<th>Description</th>
<th>Image</th>
<th></th>
<th></th>
</tr>
</thead>
{% for service in service_list %}
{% load i18n %}
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Name" %}</th>
<th>{% trans "URL" %}</th>
<th>{% trans "Description" %}</th>
<th>{% trans "Image" %}</th>
<th></th>
</tr>
</thead>
{% for service in service_list %}
<tr>
<td>{{ service.name }}</td>
<td>{{ service.url }}</td>
<td>{{ service.description }}</td>
<td>{{ service.image }}</td>
<td class="text-right">
{% can_edit service%}
{% include 'buttons/edit.html' with href='preferences:edit-service' id=service.id %}
{% acl_end %}
{% history_button service %}
{% can_edit service%}
{% include 'buttons/edit.html' with href='preferences:edit-service' id=service.id %}
{% acl_end %}
{% history_button service %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>
......@@ -25,20 +25,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load massive_bootstrap_form %}
{% load i18n %}
{% block title %}Création et modification des préférences{% endblock %}
{% block title %}{% trans "Preferences" %}{% endblock %}
{% block content %}
{% bootstrap_form_errors options %}
<h3>Edition des préférences</h3>
<h3>{% trans "Editing of preferences" %}</h3>
<form class="form" method="post" enctype="multipart/form-data">
{% csrf_token %}
{% massive_bootstrap_form options 'utilisateur_asso' %}
{% bootstrap_button "Modifier" button_type="submit" icon="star" %}
{% csrf_token %}
{% massive_bootstrap_form options 'utilisateur_asso' %}
{% trans "Edit" as tr_edit %}
{% bootstrap_button tr_edit button_type="submit" icon="star" %}
</form>
<br />
<br />
<br />
<br />
<br />
<br />
{% endblock %}
......@@ -24,8 +24,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load i18n %}
{% block title %}Création et modification des preferences{% endblock %}
{% block title %}{% trans "Preferences" %}{% endblock %}
{% block content %}
{% if preferenceform %}
......@@ -44,3 +45,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<br />
<br />
{% endblock %}
......@@ -95,14 +95,14 @@ def edit_options(request, section):
model = getattr(models, section, None)
form_instance = getattr(forms, 'Edit' + section + 'Form', None)
if not (model or form_instance):
messages.error(request, "Objet inconnu")
messages.error(request, _("Unknown object"))
return redirect(reverse('preferences:display-options'))
options_instance, _created = model.objects.get_or_create()
can, msg = options_instance.can_edit(request.user)
if not can:
messages.error(request, msg or "Vous ne pouvez pas éditer cette\
option.")
messages.error(request, msg or _("You don't have the right to edit"
" this option."))
return redirect(reverse('index'))
options = form_instance(
request.POST or None,
......@@ -114,11 +114,11 @@ def edit_options(request, section):
options.save()
reversion.set_user(request.user)
reversion.set_comment(
"Champs modifié(s) : %s" % ', '.join(
"Field(s) edited: %s" % ', '.join(
field for field in options.changed_data
)
)
messages.success(request, "Préférences modifiées")
messages.success(request, _("The preferences were edited."))
return redirect(reverse('preferences:display-options'))
return form(
{'options': options},
......@@ -136,11 +136,11 @@ def add_service(request):
with transaction.atomic(), reversion.create_revision():
service.save()
reversion.set_user(request.user)
reversion.set_comment("Création")
messages.success(request, "Ce service a été ajouté")
reversion.set_comment("Creation")
messages.success(request, _("The service was added."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': service, 'action_name': 'Ajouter'},
{'preferenceform': service, 'action_name': _("Add a service")},
'preferences/preferences.html',
request
)
......@@ -160,14 +160,14 @@ def edit_service(request, service_instance, **_kwargs):
service.save()
reversion.set_user(request.user)
reversion.set_comment(
"Champs modifié(s) : %s" % ', '.join(
"Field(s) edited: %s" % ', '.join(
field for field in service.changed_data
)
)
messages.success(request, "Service modifié")
messages.success(request, _("The service was edited."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': service, 'action_name': 'Editer'},
{'preferenceform': service, 'action_name': _("Edit")},
'preferences/preferences.html',
request
)
......@@ -185,13 +185,13 @@ def del_service(request, instances):
with transaction.atomic(), reversion.create_revision():
services_del.delete()
reversion.set_user(request.user)
messages.success(request, "Le service a été supprimé")
messages.success(request, _("The service was deleted."))
except ProtectedError:
messages.error(request, "Erreur le service\
suivant %s ne peut être supprimé" % services_del)
messages.error(request, _("Error: the service %s can't be"
" deleted.") % services_del)
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': services, 'action_name': 'Supprimer'},
{'preferenceform': services, 'action_name': _("Delete")},
'preferences/preferences.html',
request
)
......@@ -207,10 +207,11 @@ def add_mailcontact(request):
)
if mailcontact.is_valid():
mailcontact.save()
messages.success(request, _("The adress was created."))
messages.success(request, _("The contact email address was created."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': mailcontact, 'action_name': 'Ajouter'},
{'preferenceform': mailcontact,
'action_name': _("Add a contact email address")},
'preferences/preferences.html',
request
)
......@@ -227,10 +228,10 @@ def edit_mailcontact(request, mailcontact_instance, **_kwargs):
)
if mailcontact.is_valid():
mailcontact.save()
messages.success(request, _("Email adress updated."))
messages.success(request, _("The contact email address was edited."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': mailcontact, 'action_name': _('Edit')},
{'preferenceform': mailcontact, 'action_name': _("Edit")},
'preferences/preferences.html',
request
)
......@@ -248,10 +249,12 @@ def del_mailcontact(request, instances):
mailcontacts_dels = mailcontacts.cleaned_data['mailcontacts']
for mailcontacts_del in mailcontacts_dels:
mailcontacts_del.delete()
messages.success(request, _("The email adress was deleted."))
messages.success(request,
_("The contact email adress was deleted."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': mailcontacts, 'action_name': _('Delete')},
{'preferenceform': mailcontacts, 'action_name': _("Delete")},
'preferences/preferences.html',
request
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment