From fc176a60c148ac9c71295811384fee57c218e819 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Mon, 25 Jun 2018 16:50:45 +0200 Subject: [PATCH 1/7] New DNAME model --- machines/admin.py | 6 ++ machines/forms.py | 29 +++++++++ machines/models.py | 32 +++++++++- machines/templates/machines/aff_dname.html | 50 +++++++++++++++ .../templates/machines/index_extension.html | 6 ++ machines/templates/machines/machine.html | 7 ++ machines/urls.py | 3 + machines/views.py | 64 ++++++++++++++++++- re2o/templatetags/acl.py | 1 + 9 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 machines/templates/machines/aff_dname.html diff --git a/machines/admin.py b/machines/admin.py index 0f85007c..eb765748 100644 --- a/machines/admin.py +++ b/machines/admin.py @@ -37,6 +37,7 @@ from .models import ( Ns, Vlan, Txt, + DName, Srv, Nas, Service, @@ -95,6 +96,10 @@ class TxtAdmin(VersionAdmin): """ Admin view of a TXT object """ pass +class DNameAdmin(VersionAdmin): + """ Admin view of a DName object """ + pass + class SrvAdmin(VersionAdmin): """ Admin view of a SRV object """ @@ -144,6 +149,7 @@ admin.site.register(SOA, SOAAdmin) admin.site.register(Mx, MxAdmin) admin.site.register(Ns, NsAdmin) admin.site.register(Txt, TxtAdmin) +admin.site.register(DName, DNameAdmin) admin.site.register(Srv, SrvAdmin) admin.site.register(IpList, IpListAdmin) admin.site.register(Interface, InterfaceAdmin) diff --git a/machines/forms.py b/machines/forms.py index 91df33d4..8ca13311 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -51,6 +51,7 @@ from .models import ( SOA, Mx, Txt, + DName, Ns, Service, Vlan, @@ -409,6 +410,34 @@ class DelTxtForm(FormRevMixin, Form): else: self.fields['txt'].queryset = Txt.objects.all() +class DNameForm(FormRevMixin, ModelForm): + """Ajout d'un DName pour une zone""" + class Meta: + model = DName + fields = '__all__' + + def __init__(self, *args, **kwargs): + prefix = kwargs.pop('prefix', self.Meta.model.__name__) + super(DNameForm, self).__init__(*args, prefix=prefix, **kwargs) + + +class DelDNameForm(FormRevMixin, Form): + """Suppression d'un ou plusieurs DName""" + dnames = forms.ModelMultipleChoiceField( + queryset=Txt.objects.none(), + label="Enregistrements DName actuels", + widget=forms.CheckboxSelectMultiple + ) + + def __init__(self, *args, **kwargs): + instances = kwargs.pop('instances', None) + super(DelDNameForm, self).__init__(*args, **kwargs) + if instances: + self.fields['dnames'].queryset = instances + else: + self.fields['dnames'].queryset = DName.objects.all() + + class SrvForm(FormRevMixin, ModelForm): """Ajout d'un srv pour une zone""" diff --git a/machines/models.py b/machines/models.py index fd4999d6..e73c1fb6 100644 --- a/machines/models.py +++ b/machines/models.py @@ -670,6 +670,27 @@ class Txt(RevMixin, AclMixin, models.Model): return str(self.field1).ljust(15) + " IN TXT " + str(self.field2) +class DName(RevMixin, AclMixin, models.Model): + """ Un enregistrement DName, qui crée un alias depuis la zone spécifié vers l'extension""" + PRETTY_NAME = "Enregistrement DName" + + zone = models.ForeignKey('Extension', on_delete=models.PROTECT) + alias = models.CharField(max_length=255) + + class Meta: + permissions = ( + ("view_dname", "Peut voir un objet dname"), + ) + + def __str__(self): + return str(self.zone) + " : " + str(self.alias) + + @cached_property + def dns_entry(self): + """Renvoie l'enregisterment DNAME complet pour le fichier de zone""" + return str(self.alias) + " IN DNAME " + str(self.zone) + + class Srv(RevMixin, AclMixin, models.Model): """ A SRV record """ PRETTY_NAME = "Enregistrement Srv" @@ -1680,12 +1701,21 @@ def text_post_save(**_kwargs): """Regeneration dns après modification d'un TXT""" regen('dns') - @receiver(post_delete, sender=Txt) def text_post_delete(**_kwargs): """Regeneration dns après modification d'un TX""" regen('dns') +@receiver(post_save, sender=DName) +def dname_post_save(**_kwargs): + """Regeneration dns après modification d'un DName""" + regen('dns') + +@receiver(post_delete, sender=DName) +def DName_post_delete(**_kwargs): + """Regeneration dns après modification d'un DName""" + regen('dns') + @receiver(post_save, sender=Srv) def srv_post_save(**_kwargs): diff --git a/machines/templates/machines/aff_dname.html b/machines/templates/machines/aff_dname.html new file mode 100644 index 00000000..de51aad8 --- /dev/null +++ b/machines/templates/machines/aff_dname.html @@ -0,0 +1,50 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Goulven Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +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 acl %} + + + + + + + + + + + {% for dname in dname_list %} + + + + + + {% endfor %} +
Zone concernéeEnregistrement
{{ dname.zone }}{{ dname.dns_entry }} + {% can_edit dname %} + {% include 'buttons/edit.html' with href='machines:edit-dname' id=dname.id %} + {% acl_end %} + {% include 'buttons/history.html' with href='machines:history' name='dname' id=dname.id %} +
+ + diff --git a/machines/templates/machines/index_extension.html b/machines/templates/machines/index_extension.html index 6ee1bdff..3ec25767 100644 --- a/machines/templates/machines/index_extension.html +++ b/machines/templates/machines/index_extension.html @@ -61,6 +61,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} Supprimer un enregistrement TXT {% include "machines/aff_txt.html" with txt_list=txt_list %} +

Liste des enregistrements DNAME

+ {% can_create DName %} + Ajouter un enregistrement DNAME + {% acl_end %} + Supprimer un enregistrement DNAME + {% include "machines/aff_dname.html" with dname_list=dname_list %}

Liste des enregistrements SRV

{% can_create Srv %} Ajouter un enregistrement SRV diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index 0e7082f8..20dee58a 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -54,6 +54,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if nsform %} {% bootstrap_form_errors nsform %} {% endif %} +{% if dnameform %} + {% bootstrap_form_errors dnameform %} +{% endif %} {% if txtform %} {% bootstrap_form_errors txtform %} {% endif %} @@ -122,6 +125,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,

Enregistrement TXT

{% bootstrap_form txtform %} {% endif %} + {% if dnameform %} +

Enregistrement DName

+ {% bootstrap_form dnameform %} + {% endif %} {% if srvform %}

Enregistrement SRV

{% massive_bootstrap_form srvform 'target' %} diff --git a/machines/urls.py b/machines/urls.py index 670c3ce6..bf3d63d8 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -73,6 +73,9 @@ urlpatterns = [ url(r'^add_txt/$', views.add_txt, name='add-txt'), url(r'^edit_txt/(?P[0-9]+)$', views.edit_txt, name='edit-txt'), url(r'^del_txt/$', views.del_txt, name='del-txt'), + url(r'^add_dname/$', views.add_dname, name='add-dname'), + url(r'^edit_dname/(?P[0-9]+)$', views.edit_dname, name='edit-dname'), + url(r'^del_dname/$', views.del_dname, name='del-dname'), url(r'^add_ns/$', views.add_ns, name='add-ns'), url(r'^edit_ns/(?P[0-9]+)$', views.edit_ns, name='edit-ns'), url(r'^del_ns/$', views.del_ns, name='del-ns'), diff --git a/machines/views.py b/machines/views.py index 75c2f483..70274356 100644 --- a/machines/views.py +++ b/machines/views.py @@ -93,6 +93,8 @@ from .forms import ( DelNsForm, TxtForm, DelTxtForm, + DNameForm, + DelDNameForm, MxForm, DelMxForm, VlanForm, @@ -122,6 +124,7 @@ from .models import ( Vlan, Nas, Txt, + DName, Srv, OuverturePortList, OuverturePort, @@ -815,6 +818,63 @@ def del_ns(request, instances): request ) +@login_required +@can_create(DName) +def add_dname(request): + """ View used to add a DName object """ + dname = DNameForm(request.POST or None) + if dname.is_valid(): + dname.save() + messages.success(request, "Cet enregistrement DName a été ajouté") + return redirect(reverse('machines:index-extension')) + return form( + {'dnameform': dname, 'action_name': 'Créer'}, + 'machines/machine.html', + request + ) + + +@login_required +@can_edit(DName) +def edit_dname(request, dname_instance, **_kwargs): + """ View used to edit a DName object """ + dname = DNameForm(request.POST or None, instance=dname_instance) + if dname.is_valid(): + if dname.changed_data: + dname.save() + messages.success(request, "DName modifié") + return redirect(reverse('machines:index-extension')) + return form( + {'dnameform': dname, 'action_name': 'Editer'}, + 'machines/machine.html', + request + ) + + +@login_required +@can_delete_set(DName) +def del_dname(request, instances): + """ View used to delete a DName object """ + dname = DelDNameForm(request.POST or None, instances=instances) + if dname.is_valid(): + dname_dels = dname.cleaned_data['dname'] + for dname_del in dname_dels: + try: + dname_del.delete() + messages.success(request, "Le dname a été supprimé") + except ProtectedError: + messages.error( + request, + ("Erreur le dname suivant %s ne peut être supprimé" + % dname_del) + ) + return redirect(reverse('machines:index-extension')) + return form( + {'dnameform': dname, 'action_name': 'Supprimer'}, + 'machines/machine.html', + request + ) + @login_required @can_create(Txt) @@ -1272,7 +1332,7 @@ def index_nas(request): @login_required -@can_view_all(SOA, Mx, Ns, Txt, Srv, Extension) +@can_view_all(SOA, Mx, Ns, Txt, DName, Srv, Extension) def index_extension(request): """ View displaying the list of existing extensions, the list of existing SOA records, the list of existing MX records , the list of @@ -1292,6 +1352,7 @@ def index_extension(request): .select_related('zone') .select_related('ns__extension')) txt_list = Txt.objects.all().select_related('zone') + dname_list = DName.objects.all().select_related('zone') srv_list = (Srv.objects .all() .select_related('extension') @@ -1305,6 +1366,7 @@ def index_extension(request): 'mx_list': mx_list, 'ns_list': ns_list, 'txt_list': txt_list, + 'dname_list': dname_list, 'srv_list': srv_list } ) diff --git a/re2o/templatetags/acl.py b/re2o/templatetags/acl.py index fccbea1d..d36bdfa7 100644 --- a/re2o/templatetags/acl.py +++ b/re2o/templatetags/acl.py @@ -102,6 +102,7 @@ MODEL_NAME = { 'Mx': machines.models.Mx, 'Ns': machines.models.Ns, 'Txt': machines.models.Txt, + 'DName': machines.models.DName, 'Srv': machines.models.Srv, 'Interface': machines.models.Interface, 'Domain': machines.models.Domain, From a5988e29b8f7b297e679f35cb3813fdb8e967819 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Mon, 25 Jun 2018 17:16:44 +0200 Subject: [PATCH 2/7] migrations for dname --- machines/migrations/0088_dname.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 machines/migrations/0088_dname.py diff --git a/machines/migrations/0088_dname.py b/machines/migrations/0088_dname.py new file mode 100644 index 00000000..2b9b457b --- /dev/null +++ b/machines/migrations/0088_dname.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-06-25 14:33 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import re2o.mixins + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0087_merge_20180624_1648'), + ] + + operations = [ + migrations.CreateModel( + name='DName', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('alias', models.CharField(max_length=255)), + ('zone', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='machines.Extension')), + ], + options={ + 'permissions': (('view_dname', 'Peut voir un objet dname'),), + }, + bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), + ), + ] From 342b7c1173024afe4a485d262dc530c2c88a4224 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Mon, 25 Jun 2018 17:35:40 +0200 Subject: [PATCH 3/7] serializers pour dnames --- api/serializers.py | 7 +++++++ api/urls.py | 1 + api/views.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/api/serializers.py b/api/serializers.py index 10d73349..bff1bd9c 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -191,6 +191,13 @@ class MxSerializer(NamespacedHMSerializer): fields = ('zone', 'priority', 'name', 'api_url') +class DNameSerializer(NamespacedHMSerializer): + """Serialize `machines.models.DName` objects. + """ + class Meta: + model = machines.DName + fields = ('zone', 'alias', 'api_url') + class NsSerializer(NamespacedHMSerializer): """Serialize `machines.models.Ns` objects. """ diff --git a/api/urls.py b/api/urls.py index 374436dc..2947850e 100644 --- a/api/urls.py +++ b/api/urls.py @@ -52,6 +52,7 @@ router.register_viewset(r'machines/extension', views.ExtensionViewSet) router.register_viewset(r'machines/mx', views.MxViewSet) router.register_viewset(r'machines/ns', views.NsViewSet) router.register_viewset(r'machines/txt', views.TxtViewSet) +router.register_viewset(r'machines/dname', views.DNameViewSet) router.register_viewset(r'machines/srv', views.SrvViewSet) router.register_viewset(r'machines/interface', views.InterfaceViewSet) router.register_viewset(r'machines/ipv6list', views.Ipv6ListViewSet) diff --git a/api/views.py b/api/views.py index 4b1b1246..45e083cc 100644 --- a/api/views.py +++ b/api/views.py @@ -163,6 +163,12 @@ class TxtViewSet(viewsets.ReadOnlyModelViewSet): queryset = machines.Txt.objects.all() serializer_class = serializers.TxtSerializer +class DNameViewSet(viewsets.ReadOnlyModelViewSet): + """Exposes list and details of `machines.models.DName` objects. + """ + queryset = machines.DName.objects.all() + serializer_class = serializers.DNameSerializer + class SrvViewSet(viewsets.ReadOnlyModelViewSet): """Exposes list and details of `machines.models.Srv` objects. From 7631ea6c5f9766829fd2baaa52ab220bd1026d3d Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 22 Jul 2018 20:43:38 +0200 Subject: [PATCH 4/7] Correct credit for dname --- machines/models.py | 3 ++- machines/templates/machines/aff_dname.html | 4 +--- machines/views.py | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/machines/models.py b/machines/models.py index e73c1fb6..6a300078 100644 --- a/machines/models.py +++ b/machines/models.py @@ -3,9 +3,10 @@ # se veut agnostique au réseau considéré, de manière à être installable en # quelques clics. # -# Copyright © 2017 Gabriel Détraz +# Copyright © 2016-2018 Gabriel Détraz # Copyright © 2017 Goulven Kermarec # Copyright © 2017 Augustin Lemesle +# Copyright © 2018 Charlie Jacomme # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/machines/templates/machines/aff_dname.html b/machines/templates/machines/aff_dname.html index de51aad8..2bd11994 100644 --- a/machines/templates/machines/aff_dname.html +++ b/machines/templates/machines/aff_dname.html @@ -3,9 +3,7 @@ Re2o est un logiciel d'administration développé initiallement au rezometz. Il se veut agnostique au réseau considéré, de manière à être installable en quelques clics. -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle +Copyright © 2018 Charlie Jacomme This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/machines/views.py b/machines/views.py index 70274356..c36f83d8 100644 --- a/machines/views.py +++ b/machines/views.py @@ -3,10 +3,11 @@ # se veut agnostique au réseau considéré, de manière à être installable en # quelques clics. # -# Copyright © 2017 Gabriel Détraz +# Copyright © 2016-2018 Gabriel Détraz # Copyright © 2017 Goulven Kermarec # Copyright © 2017 Augustin Lemesle -# Copyright © 2017 Maël Kervella +# Copyright © 2017-2018 Maël Kervella +# Copyright © 2018 Charlie Jacomme # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by From 4bd0be94ed4dafcf4fb3a7bed7ffc737f5436011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Mon, 23 Jul 2018 21:19:19 +0000 Subject: [PATCH 5/7] Translate to english --- machines/forms.py | 8 ++++---- machines/migrations/0088_dname.py | 6 ++++-- machines/models.py | 19 +++++++++++-------- machines/templates/machines/aff_dname.html | 18 +++++++++--------- .../templates/machines/index_extension.html | 14 ++++++++++---- machines/templates/machines/machine.html | 8 ++++---- machines/views.py | 16 ++++++++-------- 7 files changed, 50 insertions(+), 39 deletions(-) diff --git a/machines/forms.py b/machines/forms.py index 8ca13311..36cd64f8 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -410,8 +410,9 @@ class DelTxtForm(FormRevMixin, Form): else: self.fields['txt'].queryset = Txt.objects.all() + class DNameForm(FormRevMixin, ModelForm): - """Ajout d'un DName pour une zone""" + """Add a DNAME entry for a zone""" class Meta: model = DName fields = '__all__' @@ -422,10 +423,10 @@ class DNameForm(FormRevMixin, ModelForm): class DelDNameForm(FormRevMixin, Form): - """Suppression d'un ou plusieurs DName""" + """Delete a set of DNAME entries""" dnames = forms.ModelMultipleChoiceField( queryset=Txt.objects.none(), - label="Enregistrements DName actuels", + label="Existing DNAME entries", widget=forms.CheckboxSelectMultiple ) @@ -438,7 +439,6 @@ class DelDNameForm(FormRevMixin, Form): self.fields['dnames'].queryset = DName.objects.all() - class SrvForm(FormRevMixin, ModelForm): """Ajout d'un srv pour une zone""" class Meta: diff --git a/machines/migrations/0088_dname.py b/machines/migrations/0088_dname.py index 2b9b457b..4cbeb492 100644 --- a/machines/migrations/0088_dname.py +++ b/machines/migrations/0088_dname.py @@ -10,7 +10,7 @@ import re2o.mixins class Migration(migrations.Migration): dependencies = [ - ('machines', '0087_merge_20180624_1648'), + ('machines', '0083_remove_duplicate_rights'), ] operations = [ @@ -22,7 +22,9 @@ class Migration(migrations.Migration): ('zone', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='machines.Extension')), ], options={ - 'permissions': (('view_dname', 'Peut voir un objet dname'),), + 'permissions': (('view_dname', 'Can see a dname object'),), + 'verbose_name': 'DNAME entry', + 'verbose_name_plural': 'DNAME entries' }, bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), ), diff --git a/machines/models.py b/machines/models.py index 6a300078..6344cf91 100644 --- a/machines/models.py +++ b/machines/models.py @@ -672,23 +672,23 @@ class Txt(RevMixin, AclMixin, models.Model): class DName(RevMixin, AclMixin, models.Model): - """ Un enregistrement DName, qui crée un alias depuis la zone spécifié vers l'extension""" - PRETTY_NAME = "Enregistrement DName" - + """A DNAME entry for the DNS.""" zone = models.ForeignKey('Extension', on_delete=models.PROTECT) alias = models.CharField(max_length=255) class Meta: permissions = ( - ("view_dname", "Peut voir un objet dname"), + ("view_dname", "Can see a dname object"), ) + verbose_name = "DNAME entry" + verbose_name_plural = "DNAME entries" def __str__(self): return str(self.zone) + " : " + str(self.alias) @cached_property def dns_entry(self): - """Renvoie l'enregisterment DNAME complet pour le fichier de zone""" + """Returns the DNAME record for the DNS zone file.""" return str(self.alias) + " IN DNAME " + str(self.zone) @@ -1702,19 +1702,22 @@ def text_post_save(**_kwargs): """Regeneration dns après modification d'un TXT""" regen('dns') + @receiver(post_delete, sender=Txt) def text_post_delete(**_kwargs): """Regeneration dns après modification d'un TX""" regen('dns') + @receiver(post_save, sender=DName) def dname_post_save(**_kwargs): - """Regeneration dns après modification d'un DName""" + """Updates the DNS regen after modification of a DName object.""" regen('dns') + @receiver(post_delete, sender=DName) -def DName_post_delete(**_kwargs): - """Regeneration dns après modification d'un DName""" +def dname_post_delete(**_kwargs): + """Updates the DNS regen after deletion of a DName object.""" regen('dns') diff --git a/machines/templates/machines/aff_dname.html b/machines/templates/machines/aff_dname.html index 2bd11994..17cd0457 100644 --- a/machines/templates/machines/aff_dname.html +++ b/machines/templates/machines/aff_dname.html @@ -3,7 +3,7 @@ Re2o est un logiciel d'administration développé initiallement au rezometz. Il se veut agnostique au réseau considéré, de manière à être installable en quelques clics. -Copyright © 2018 Charlie Jacomme +Copyright © 2018 Charlie Jacomme This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,21 +25,21 @@ with this program; if not, write to the Free Software Foundation, Inc., - - + + {% for dname in dname_list %} - - + + {% endfor %} diff --git a/machines/templates/machines/index_extension.html b/machines/templates/machines/index_extension.html index 3ec25767..19a0fca4 100644 --- a/machines/templates/machines/index_extension.html +++ b/machines/templates/machines/index_extension.html @@ -61,12 +61,18 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} Supprimer un enregistrement TXT {% include "machines/aff_txt.html" with txt_list=txt_list %} -

Liste des enregistrements DNAME

+ +

DNAME records

{% can_create DName %} - Ajouter un enregistrement DNAME + + {% trans "Add a DNAME record" %} + {% acl_end %} - Supprimer un enregistrement DNAME - {% include "machines/aff_dname.html" with dname_list=dname_list %} + + {% trans "Delete DNAME records" %} + + {% include "machines/aff_dname.html" with dname_list=dname_list %} +

Liste des enregistrements SRV

{% can_create Srv %} Ajouter un enregistrement SRV diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index 20dee58a..0c5a478a 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -54,12 +54,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if nsform %} {% bootstrap_form_errors nsform %} {% endif %} -{% if dnameform %} - {% bootstrap_form_errors dnameform %} -{% endif %} {% if txtform %} {% bootstrap_form_errors txtform %} {% endif %} +{% if dnameform %} + {% bootstrap_form_errors dnameform %} +{% endif %} {% if srvform %} {% bootstrap_form_errors srvform %} {% endif %} @@ -126,7 +126,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% bootstrap_form txtform %} {% endif %} {% if dnameform %} -

Enregistrement DName

+

DNAME record

{% bootstrap_form dnameform %} {% endif %} {% if srvform %} diff --git a/machines/views.py b/machines/views.py index c36f83d8..71484952 100644 --- a/machines/views.py +++ b/machines/views.py @@ -826,10 +826,10 @@ def add_dname(request): dname = DNameForm(request.POST or None) if dname.is_valid(): dname.save() - messages.success(request, "Cet enregistrement DName a été ajouté") + messages.success(request, "This DNAME record has been added") return redirect(reverse('machines:index-extension')) return form( - {'dnameform': dname, 'action_name': 'Créer'}, + {'dnameform': dname, 'action_name': "Create"}, 'machines/machine.html', request ) @@ -843,10 +843,10 @@ def edit_dname(request, dname_instance, **_kwargs): if dname.is_valid(): if dname.changed_data: dname.save() - messages.success(request, "DName modifié") + messages.success(request, "DName successfully edited") return redirect(reverse('machines:index-extension')) return form( - {'dnameform': dname, 'action_name': 'Editer'}, + {'dnameform': dname, 'action_name': "Edit"}, 'machines/machine.html', request ) @@ -862,16 +862,16 @@ def del_dname(request, instances): for dname_del in dname_dels: try: dname_del.delete() - messages.success(request, "Le dname a été supprimé") + messages.success(request, + "The DNAME %s has been deleted" % dname_del) except ProtectedError: messages.error( request, - ("Erreur le dname suivant %s ne peut être supprimé" - % dname_del) + "The DNAME %s can not be deleted" % dname_del ) return redirect(reverse('machines:index-extension')) return form( - {'dnameform': dname, 'action_name': 'Supprimer'}, + {'dnameform': dname, 'action_name': 'Delete'}, 'machines/machine.html', request ) From c977eccafd8a48f6bc6f6e248e081513ac6cb60a Mon Sep 17 00:00:00 2001 From: chirac Date: Sun, 29 Jul 2018 13:56:19 +0200 Subject: [PATCH 6/7] Update aff_dname.html --- machines/templates/machines/aff_dname.html | 1 - 1 file changed, 1 deletion(-) diff --git a/machines/templates/machines/aff_dname.html b/machines/templates/machines/aff_dname.html index 17cd0457..8ee3280e 100644 --- a/machines/templates/machines/aff_dname.html +++ b/machines/templates/machines/aff_dname.html @@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc., - {% for dname in dname_list %} From 4e9b0586ed7b20a8982922dca20766c91403fda5 Mon Sep 17 00:00:00 2001 From: chirac Date: Sun, 29 Jul 2018 16:45:12 +0200 Subject: [PATCH 7/7] Update models.py alignement --- machines/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machines/models.py b/machines/models.py index 6344cf91..590e3997 100644 --- a/machines/models.py +++ b/machines/models.py @@ -689,7 +689,7 @@ class DName(RevMixin, AclMixin, models.Model): @cached_property def dns_entry(self): """Returns the DNAME record for the DNS zone file.""" - return str(self.alias) + " IN DNAME " + str(self.zone) + return str(self.alias).ljust(15) + " IN DNAME " + str(self.zone) class Srv(RevMixin, AclMixin, models.Model):
Zone concernéeEnregistrementTarget zoneRecord
{{ dname.zone }}{{ dname.dns_entry }}{{ dname.zone }}{{ dname.dns_entry }} - {% can_edit dname %} - {% include 'buttons/edit.html' with href='machines:edit-dname' id=dname.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='dname' id=dname.id %} + {% can_edit dname %} + {% include 'buttons/edit.html' with href='machines:edit-dname' id=dname.id %} + {% acl_end %} + {% include 'buttons/history.html' with href='machines:history' name='dname' id=dname.id %}
Target zone Record