8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

translation and cleanup

This commit is contained in:
Maël Kervella 2018-07-23 23:33:01 +00:00
parent 352a416647
commit 5dce3629b7
13 changed files with 110 additions and 169 deletions

View file

@ -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__'

View file

@ -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'),
),
]

View file

@ -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),
),
]

View file

@ -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),
),
]

View file

@ -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)

View file

@ -122,7 +122,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_create SshFingerprint interface.machine.id %}
<li>
<a href="{% url 'machines:index-sshfingerprint' interface.machine.id %}">
<i class="fa fa-edit"></i> Gerer les fingerprint ssh
<i class="fa fa-edit"></i> Manage the SSH fingerprints
</a>
</li>
{% acl_end %}

View file

@ -21,13 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load logs_extra %}
<div class="table-responsive">
<table class="table table-striped long_text">
<thead>
<tr>
<th class="long_text">Entrée du hash</th>
<th>Algorithme utilisé</th>
<th>Commentaire</th>
<th class="long_text">SSH public key</th>
<th>Algorithm used</th>
<th>Comment</th>
<th></th>
</tr>
</thead>
@ -43,7 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% 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 %}
{% history_button sshfpr %}
</td>
</tr>
{% endfor %}

View file

@ -21,11 +21,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load logs_extra %}
<table class="table table-striped">
<table class="table table-striped">
<thead>
<tr>
<th>Nom de l'algo</th>
<th>Algorithm name</th>
<th></th>
</tr>
</thead>
@ -39,9 +40,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% 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 %}
{% history_button sshfpralgo %}
</td>
</tr>
{% endfor %}
</table>
</table>

View file

@ -27,13 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des fingerprint ssh</h2>
{% can_create SshFingerprint machine_id %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-sshfingerprint' machine_id %}"><i class="fa fa-plus"></i> Ajouter une fingerprint ssh</a>
{% acl_end %}
{% include "machines/aff_sshfingerprint.html" with sshfingerprint_list=sshfingerprint_list %}
<br />
<br />
<br />
<h2>SSH fingerprints</h2>
{% can_create SshFingerprint machine_id %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-sshfingerprint' machine_id %}">
<i class="fa fa-plus"></i> Add an SSH fingerprint
</a>
{% acl_end %}
{% include "machines/aff_sshfingerprint.html" with sshfingerprint_list=sshfingerprint_list %}
{% endblock %}

View file

@ -27,13 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}Machines{% endblock %}
{% block content %}
<h2>Liste des algo fingerprint ssh</h2>
{% can_create SshFprAlgo %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-sshfpralgo' %}"><i class="fa fa-plus"></i> Ajouter un algo ssh</a>
{% acl_end %}
{% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %}
<br />
<br />
<br />
<h2>SSH fingerprint algorithms</h2>
{% can_create SshFprAlgo %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-sshfpralgo' %}">
<i class="fa fa-plus"></i> Add an SSH fingerprint algorithm
</a>
{% acl_end %}
{% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %}
{% endblock %}

View file

@ -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 %}
<form class="form" method="post">
{% csrf_token %}
@ -94,6 +91,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h3>Machine</h3>
{% massive_bootstrap_form machineform 'user' %}
{% endif %}
{% if sshfingerprintform %}
<h3>SSH fingerprint</h3>
{% bootstrap_form sshfingerprintform %}
{% endif %}
{% if sshfpralgoform %}
<h3>SSH fingerprint algorithm</h3>
{% bootstrap_form sshfpralgoform %}
{% endif %}
{% if interfaceform %}
<h3>Interface</h3>
{% if i_mbf_param %}
@ -162,14 +167,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h3>Ipv6</h3>
{% bootstrap_form ipv6form %}
{% endif %}
{% if sshfingerprintform %}
<h3>SshFingerprint</h3>
{% bootstrap_form sshfingerprintform %}
{% endif %}
{% if sshfpralgoform %}
<h3>Algorithme de fingerprint ssh</h3>
{% bootstrap_form sshfpralgoform %}
{% endif %}
{% bootstrap_button action_name button_type="submit" icon="star" %}
</form>
<br />

View file

@ -47,7 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_view_all SshFprAlgo %}
<a class="list-group-item list-group-item-info" href="{% url "machines:index-sshfpralgo" %}">
<i class="fa fa-list-ul"></i>
Algo de fingerprint ssh
SSH fingerprint algorithm
</a>
{% acl_end %}
{% can_view_all IpType %}

View file

@ -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,