From 5dce3629b71b183dce64c86986ba3f750fa754b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Mon, 23 Jul 2018 23:33:01 +0000 Subject: [PATCH] translation and cleanup --- machines/forms.py | 4 +- .../migrations/0084_auto_20180623_1651.py | 28 ++++++------- .../migrations/0085_auto_20180623_1817.py | 20 --------- .../migrations/0086_auto_20180624_1254.py | 30 ------------- machines/models.py | 22 +++++----- machines/templates/machines/aff_machines.html | 2 +- .../machines/aff_sshfingerprint.html | 26 ++++++------ .../templates/machines/aff_sshfpralgo.html | 42 +++++++++---------- .../machines/index_sshfingerprint.html | 15 ++++--- .../templates/machines/index_sshfpralgo.html | 15 ++++--- machines/templates/machines/machine.html | 31 +++++++------- machines/templates/machines/sidebar.html | 2 +- machines/views.py | 42 +++++++++---------- 13 files changed, 110 insertions(+), 169 deletions(-) delete mode 100644 machines/migrations/0085_auto_20180623_1817.py delete mode 100644 machines/migrations/0086_auto_20180624_1254.py diff --git a/machines/forms.py b/machines/forms.py index 869ad058..e9086ef8 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -600,7 +600,7 @@ class EditOuverturePortListForm(FormRevMixin, ModelForm): class SshFingerprintForm(FormRevMixin, ModelForm): - """Edition d'une sshfingerprint""" + """Edits a SSH fingerprint.""" class Meta: model = SshFingerprint exclude = ('machine',) @@ -615,7 +615,7 @@ class SshFingerprintForm(FormRevMixin, ModelForm): class SshFprAlgoForm(FormRevMixin, ModelForm): - """Edition de la liste des algo pour sshfpr""" + """Edits a SSH fingerprint algorithm.""" class Meta: model = SshFprAlgo fields = '__all__' diff --git a/machines/migrations/0084_auto_20180623_1651.py b/machines/migrations/0084_auto_20180623_1651.py index 443c89ad..04ab125e 100644 --- a/machines/migrations/0084_auto_20180623_1651.py +++ b/machines/migrations/0084_auto_20180623_1651.py @@ -10,7 +10,7 @@ import re2o.mixins class Migration(migrations.Migration): dependencies = [ - ('machines', '0083_role'), + ('machines', '0083_remove_duplicate_rights'), ] operations = [ @@ -18,11 +18,15 @@ class Migration(migrations.Migration): name='SshFingerprint', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('hash_entry', models.TextField(max_length=512)), - ('comment', models.CharField(blank=True, max_length=255, null=True)), + ('pub_key_entry', models.TextField(help_text='SSH public key', max_length=2048)), + ('comment', models.CharField(blank=True, help_text='Comment', max_length=255, null=True)), + ('algo', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='machines.SshFprAlgo')), + ('machine', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='machines.Machine')), ], options={ - 'permissions': (('view_sshfingerprint', 'Peut voir un objet sshfingerprint'),), + 'permissions': (('view_sshfingerprint', 'Can see an SSH fingerprint'),), + 'verbose_name': 'SSH fingerprint', + 'verbose_name_plural': 'SSH fingerprints' }, bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), ), @@ -30,21 +34,13 @@ class Migration(migrations.Migration): name='SshFprAlgo', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.TextField(max_length=256)), + ('name', models.CharField(max_length=256)), ], options={ - 'permissions': (('view_sshfpralgo', 'Peut voir un algo de chiffrement'),), + 'permissions': (('view_sshfpralgo', 'Can see an SSH fingerprint algorithm'),), + 'verbose_name': 'SSH fingerprint algorithm', + 'verbose_name_plural': 'SSH fingerprint algorithms' }, bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), ), - migrations.AddField( - model_name='sshfingerprint', - name='algo', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='machines.SshFprAlgo'), - ), - migrations.AddField( - model_name='sshfingerprint', - name='machine', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='machines.Machine'), - ), ] diff --git a/machines/migrations/0085_auto_20180623_1817.py b/machines/migrations/0085_auto_20180623_1817.py deleted file mode 100644 index 0c3216c5..00000000 --- a/machines/migrations/0085_auto_20180623_1817.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2018-06-23 16:17 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('machines', '0084_auto_20180623_1651'), - ] - - operations = [ - migrations.AlterField( - model_name='sshfpralgo', - name='name', - field=models.CharField(max_length=256), - ), - ] diff --git a/machines/migrations/0086_auto_20180624_1254.py b/machines/migrations/0086_auto_20180624_1254.py deleted file mode 100644 index 7474ac8b..00000000 --- a/machines/migrations/0086_auto_20180624_1254.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2018-06-24 10:54 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('machines', '0085_auto_20180623_1817'), - ] - - operations = [ - migrations.RenameField( - model_name='sshfingerprint', - old_name='hash_entry', - new_name='pub_key_entry', - ), - migrations.AlterField( - model_name='sshfingerprint', - name='comment', - field=models.CharField(blank=True, help_text='Commentaire', max_length=255, null=True), - ), - migrations.AlterField( - model_name='sshfingerprint', - name='pub_key_entry', - field=models.TextField(help_text='Clef publique ssh', max_length=2048), - ), - ] diff --git a/machines/models.py b/machines/models.py index 986fe4d9..6101cffc 100644 --- a/machines/models.py +++ b/machines/models.py @@ -201,14 +201,10 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): return str(self.user) + ' - ' + str(self.id) + ' - ' + str(self.name) class SshFingerprint(RevMixin, AclMixin, models.Model): - """Stockage de la clef ssh publique d'une machine - et calcul de ses hash""" - - PRETTY_NAME = "Clef publique ssh" - + """A fingerpirnt of an SSH public key""" machine = models.ForeignKey('Machine', on_delete=models.CASCADE) pub_key_entry = models.TextField( - help_text="Clef publique ssh", + help_text="SSH public key", max_length=2048 ) algo = models.ForeignKey( @@ -216,7 +212,7 @@ class SshFingerprint(RevMixin, AclMixin, models.Model): on_delete=models.PROTECT ) comment = models.CharField( - help_text="Commentaire", + help_text="Comment", max_length=255, null=True, blank=True @@ -224,8 +220,10 @@ class SshFingerprint(RevMixin, AclMixin, models.Model): class Meta: permissions = ( - ("view_sshfingerprint", "Peut voir un objet sshfingerprint"), + ("view_sshfingerprint", "Can see an SSH fingerprint"), ) + verbose_name = "SSH fingerprint" + verbose_name_plural = "SSH fingerprints" def can_view(self, user_request, *_args, **_kwargs): return self.machine.can_view(user_request, *_args, **_kwargs) @@ -241,15 +239,15 @@ class SshFingerprint(RevMixin, AclMixin, models.Model): class SshFprAlgo(RevMixin, AclMixin, models.Model): - """Un aglorithme de création de la fingerprint ssh""" - PRETTY_NAME = "Algo de clef ssh" - + """An algorithm to compute SSH fingerprints""" name = models.CharField(max_length=256) class Meta: permissions = ( - ("view_sshfpralgo", "Peut voir un algo de chiffrement"), + ("view_sshfpralgo", "Can see an SSH fingerprint algorithm"), ) + verbose_name = "SSH fingerprint algorithm" + verbose_name_plural = "SSH fingerprint algorithms" def __str__(self): return str(self.name) diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index 5db5e836..e5599858 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -122,7 +122,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_create SshFingerprint interface.machine.id %}
  • - Gerer les fingerprint ssh + Manage the SSH fingerprints
  • {% acl_end %} diff --git a/machines/templates/machines/aff_sshfingerprint.html b/machines/templates/machines/aff_sshfingerprint.html index 533f7c9f..5c9691fa 100644 --- a/machines/templates/machines/aff_sshfingerprint.html +++ b/machines/templates/machines/aff_sshfingerprint.html @@ -21,14 +21,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} +
    - - - - + + + + {% for sshfpr in sshfingerprint_list %} @@ -36,14 +38,14 @@ with this program; if not, write to the Free Software Foundation, Inc., - {% endfor %} diff --git a/machines/templates/machines/aff_sshfpralgo.html b/machines/templates/machines/aff_sshfpralgo.html index fe9e78c4..902191ff 100644 --- a/machines/templates/machines/aff_sshfpralgo.html +++ b/machines/templates/machines/aff_sshfpralgo.html @@ -21,27 +21,27 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} -
    Entrée du hashAlgorithme utiliséCommentaireSSH public keyAlgorithm usedComment
    {{ sshfpr.pub_key_entry }} {{ sshfpr.algo }} {{ sshfpr.comment }} - {% can_edit sshfpr %} - {% include 'buttons/edit.html' with href='machines:edit-sshfingerprint' id=sshfpr.id %} - {% acl_end %} - {% can_delete sshfpr %} - {% include 'buttons/suppr.html' with href='machines:del-sshfingerprint' id=sshfpr.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='sshfingerprint' id=sshfpr.id %} + + {% can_edit sshfpr %} + {% include 'buttons/edit.html' with href='machines:edit-sshfingerprint' id=sshfpr.id %} + {% acl_end %} + {% can_delete sshfpr %} + {% include 'buttons/suppr.html' with href='machines:del-sshfingerprint' id=sshfpr.id %} + {% acl_end %} + {% history_button sshfpr %}
    - - - - - - - {% for sshfpralgo in sshfpralgo_list %} +
    Nom de l'algo
    + - - + + - {% endfor %} -
    {{ sshfpralgo.name }} - {% can_edit sshfpralgo %} - {% include 'buttons/edit.html' with href='machines:edit-sshfpralgo' id=sshfpralgo.id %} - {% acl_end %} - {% can_delete sshfpralgo %} - {% include 'buttons/suppr.html' with href='machines:del-sshfpralgo' id=sshfpralgo.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='sshfpralgo' id=sshfpralgo.id %} - Algorithm name
    - + + {% for sshfpralgo in sshfpralgo_list %} + + {{ sshfpralgo.name }} + + {% can_edit sshfpralgo %} + {% include 'buttons/edit.html' with href='machines:edit-sshfpralgo' id=sshfpralgo.id %} + {% acl_end %} + {% can_delete sshfpralgo %} + {% include 'buttons/suppr.html' with href='machines:del-sshfpralgo' id=sshfpralgo.id %} + {% acl_end %} + {% history_button sshfpralgo %} + + + {% endfor %} + diff --git a/machines/templates/machines/index_sshfingerprint.html b/machines/templates/machines/index_sshfingerprint.html index eba872c0..ec511e45 100644 --- a/machines/templates/machines/index_sshfingerprint.html +++ b/machines/templates/machines/index_sshfingerprint.html @@ -27,13 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Machines{% endblock %} {% block content %} -

    Liste des fingerprint ssh

    - {% can_create SshFingerprint machine_id %} - Ajouter une fingerprint ssh - {% acl_end %} - {% include "machines/aff_sshfingerprint.html" with sshfingerprint_list=sshfingerprint_list %} -
    -
    -
    +

    SSH fingerprints

    +{% can_create SshFingerprint machine_id %} + + Add an SSH fingerprint + +{% acl_end %} +{% include "machines/aff_sshfingerprint.html" with sshfingerprint_list=sshfingerprint_list %} {% endblock %} diff --git a/machines/templates/machines/index_sshfpralgo.html b/machines/templates/machines/index_sshfpralgo.html index 90107d0a..1bf50635 100644 --- a/machines/templates/machines/index_sshfpralgo.html +++ b/machines/templates/machines/index_sshfpralgo.html @@ -27,13 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Machines{% endblock %} {% block content %} -

    Liste des algo fingerprint ssh

    - {% can_create SshFprAlgo %} - Ajouter un algo ssh - {% acl_end %} - {% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %} -
    -
    -
    +

    SSH fingerprint algorithms

    +{% can_create SshFprAlgo %} + + Add an SSH fingerprint algorithm + +{% acl_end %} +{% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %} {% endblock %} diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index b49673bb..d5918ef8 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -33,6 +33,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if machineform %} {% bootstrap_form_errors machineform %} {% endif %} +{% if sshfingerprintform %} + {% bootstrap_form_errors sshfingerprintform %} +{% endif %} +{% if sshfpralgoform %} + {% bootstrap_form_errors sshfpralgoform %} +{% endif %} {% if interfaceform %} {% bootstrap_form_errors interfaceform %} {% endif %} @@ -78,15 +84,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if ipv6form %} {% bootstrap_form_errors ipv6form %} {% endif %} -{% if sshfingerprintform %} - {% bootstrap_form_errors sshfingerprintform %} -{% endif %} -{% if sshfpralgoform %} - {% bootstrap_form_errors sshfpralgoform %} -{% endif %} - - -
    {% csrf_token %} @@ -94,6 +91,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,

    Machine

    {% massive_bootstrap_form machineform 'user' %} {% endif %} + {% if sshfingerprintform %} +

    SSH fingerprint

    + {% bootstrap_form sshfingerprintform %} + {% endif %} + {% if sshfpralgoform %} +

    SSH fingerprint algorithm

    + {% bootstrap_form sshfpralgoform %} + {% endif %} {% if interfaceform %}

    Interface

    {% if i_mbf_param %} @@ -162,14 +167,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

    Ipv6

    {% bootstrap_form ipv6form %} {% endif %} - {% if sshfingerprintform %} -

    SshFingerprint

    - {% bootstrap_form sshfingerprintform %} - {% endif %} - {% if sshfpralgoform %} -

    Algorithme de fingerprint ssh

    - {% bootstrap_form sshfpralgoform %} - {% endif %} {% bootstrap_button action_name button_type="submit" icon="star" %}

    diff --git a/machines/templates/machines/sidebar.html b/machines/templates/machines/sidebar.html index 0b272b0a..f897c3a4 100644 --- a/machines/templates/machines/sidebar.html +++ b/machines/templates/machines/sidebar.html @@ -47,7 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view_all SshFprAlgo %} - Algo de fingerprint ssh + SSH fingerprint algorithm {% acl_end %} {% can_view_all IpType %} diff --git a/machines/views.py b/machines/views.py index 1c443980..baba6613 100644 --- a/machines/views.py +++ b/machines/views.py @@ -468,7 +468,7 @@ def del_ipv6list(request, ipv6list, **_kwargs): @can_create(SshFingerprint) @can_edit(Machine) def new_sshfingerprint(request, machine, **_kwargs): - """Nouvelle sshfingerprint""" + """Creates an SSH fingerprint""" sshfingerprint_instance = SshFingerprint(machine=machine) sshfingerprint = SshFingerprintForm( request.POST or None, @@ -476,13 +476,13 @@ def new_sshfingerprint(request, machine, **_kwargs): ) if sshfingerprint.is_valid(): sshfingerprint.save() - messages.success(request, "Fingerprint ssh ajoutée") + messages.success(request, "The SSH fingerprint was added") return redirect(reverse( 'machines:index-sshfingerprint', kwargs={'machineid': str(machine.id)} )) return form( - {'sshfingerprintform': sshfingerprint, 'action_name': 'Créer'}, + {'sshfingerprintform': sshfingerprint, 'action_name': 'Create'}, 'machines/machine.html', request ) @@ -491,7 +491,7 @@ def new_sshfingerprint(request, machine, **_kwargs): @login_required @can_edit(SshFingerprint) def edit_sshfingerprint(request, sshfingerprint_instance, **_kwargs): - """Edition d'une sshfingerprint""" + """Edits an SSH fingerprint""" sshfingerprint = SshFingerprintForm( request.POST or None, instance=sshfingerprint_instance @@ -499,13 +499,13 @@ def edit_sshfingerprint(request, sshfingerprint_instance, **_kwargs): if sshfingerprint.is_valid(): if sshfingerprint.changed_data: sshfingerprint.save() - messages.success(request, "Ssh fingerprint modifiée") + messages.success(request, "The SSH fingerprint was edited") return redirect(reverse( 'machines:index-sshfingerprint', kwargs={'machineid': str(sshfingerprint_instance.machine.id)} )) return form( - {'sshfingerprintform': sshfingerprint, 'action_name': 'Editer'}, + {'sshfingerprintform': sshfingerprint, 'action_name': 'Edit'}, 'machines/machine.html', request ) @@ -514,11 +514,11 @@ def edit_sshfingerprint(request, sshfingerprint_instance, **_kwargs): @login_required @can_delete(SshFingerprint) def del_sshfingerprint(request, sshfingerprint, **_kwargs): - """ Supprime une sshfingerprint""" + """Deletes an SSH fingerprint""" if request.method == "POST": machineid = sshfingerprint.machine.id sshfingerprint.delete() - messages.success(request, "La sshfingerprint a été détruite") + messages.success(request, "The SSH fingerprint was deleted") return redirect(reverse( 'machines:index-sshfingerprint', kwargs={'machineid': str(machineid)} @@ -533,18 +533,18 @@ def del_sshfingerprint(request, sshfingerprint, **_kwargs): @login_required @can_create(SshFprAlgo) def new_sshfpralgo(request, **_kwargs): - """Nouvelle sshfpralgo""" + """Creates an SSH fingeprint algorithm""" sshfpralgo = SshFprAlgoForm( request.POST or None, ) if sshfpralgo.is_valid(): sshfpralgo.save() - messages.success(request, "Algo Fingerprint ssh ajouté") + messages.success(request, "The SSH fingerprint algorithm was added") return redirect(reverse( 'machines:index-sshfpralgo' )) return form( - {'sshfpralgoform': sshfpralgo, 'action_name': 'Créer'}, + {'sshfpralgoform': sshfpralgo, 'action_name': 'Create'}, 'machines/machine.html', request ) @@ -553,7 +553,7 @@ def new_sshfpralgo(request, **_kwargs): @login_required @can_edit(SshFprAlgo) def edit_sshfpralgo(request, sshfpralgo_instance, **_kwargs): - """Edition d'une sshfpralgo""" + """Edits an SSH fingerprint algorithm""" sshfpralgo = SshFprAlgoForm( request.POST or None, instance=sshfpralgo_instance @@ -561,12 +561,12 @@ def edit_sshfpralgo(request, sshfpralgo_instance, **_kwargs): if sshfpralgo.is_valid(): if sshfpralgo.changed_data: sshfpralgo.save() - messages.success(request, "Algo de sshfp modifiée") + messages.success(request, "The SSH fingerprint algorithm was edited") return redirect(reverse( 'machines:index-sshfpralgo' )) return form( - {'sshfpralgoform': sshfpralgo, 'action_name': 'Editer'}, + {'sshfpralgoform': sshfpralgo, 'action_name': 'Edit'}, 'machines/machine.html', request ) @@ -575,16 +575,16 @@ def edit_sshfpralgo(request, sshfpralgo_instance, **_kwargs): @login_required @can_delete(SshFprAlgo) def del_sshfpralgo(request, sshfpralgo, **_kwargs): - """ Supprime une sshfpralgo""" + """Deletes an SSH fingerprint algorithm""" if request.method == "POST": try: sshfpralgo.delete() - messages.success(request, "La sshfpralgo a été détruite") + messages.success(request, "The SSH fingerprint algorithm was deleted") except ProtectedError: messages.error( request, - ("L'algo est affectée à au moins une fingerprint ssh, " - "vous ne pouvez pas le supprimer") + ("This SSH fingerprint algorithm is used by at least one SSH" + "fingerprint and thus can not be deleted.") ) return redirect(reverse( 'machines:index-sshfpralgo' @@ -1524,9 +1524,9 @@ def index_alias(request, interface, interfaceid): @login_required -@can_edit(Machine) +@can_view_all(Machine) def index_sshfingerprint(request, machine, machineid): - """ View used to display the list of existing IPv6 of an interface """ + """View used to display the list of existing SSH fingerprint of a machine""" sshfingerprint_list = SshFingerprint.objects.filter(machine=machine) return render( request, @@ -1538,7 +1538,7 @@ def index_sshfingerprint(request, machine, machineid): @login_required @can_view_all(SshFprAlgo) def index_sshfpralgo(request): - """ View used to display the list of existing sshfrpalgo""" + """View used to display the list of existing SSH fingerprint algorithm""" sshfpralgo_list = SshFprAlgo.objects.all() return render( request,