8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-24 16:03:47 +00:00

Text devient Txt

This commit is contained in:
Gabriel Detraz 2017-11-15 15:17:22 +01:00 committed by root
parent 6077a773b5
commit f903138ff9
8 changed files with 47 additions and 28 deletions

View file

@ -27,7 +27,7 @@ from django.contrib import admin
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin
from .models import IpType, Machine, MachineType, Domain, IpList, Interface from .models import IpType, Machine, MachineType, Domain, IpList, Interface
from .models import Extension, SOA, Mx, Ns, Vlan, Text, Nas, Service from .models import Extension, SOA, Mx, Ns, Vlan, Txt, Nas, Service
from .models import OuverturePort, OuverturePortList from .models import OuverturePort, OuverturePortList
@ -63,7 +63,7 @@ class NsAdmin(VersionAdmin):
pass pass
class TextAdmin(VersionAdmin): class TxtAdmin(VersionAdmin):
pass pass
@ -102,7 +102,7 @@ admin.site.register(Extension, ExtensionAdmin)
admin.site.register(SOA, SOAAdmin) admin.site.register(SOA, SOAAdmin)
admin.site.register(Mx, MxAdmin) admin.site.register(Mx, MxAdmin)
admin.site.register(Ns, NsAdmin) admin.site.register(Ns, NsAdmin)
admin.site.register(Text, TextAdmin) admin.site.register(Txt, TxtAdmin)
admin.site.register(IpList, IpListAdmin) admin.site.register(IpList, IpListAdmin)
admin.site.register(Interface, InterfaceAdmin) admin.site.register(Interface, InterfaceAdmin)
admin.site.register(Domain, DomainAdmin) admin.site.register(Domain, DomainAdmin)

View file

@ -47,7 +47,7 @@ from .models import (
Extension, Extension,
SOA, SOA,
Mx, Mx,
Text, Txt,
Ns, Ns,
Service, Service,
Vlan, Vlan,
@ -364,7 +364,7 @@ class DelNsForm(Form):
class TxtForm(ModelForm): class TxtForm(ModelForm):
"""Ajout d'un txt pour une zone""" """Ajout d'un txt pour une zone"""
class Meta: class Meta:
model = Text model = Txt
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -375,7 +375,7 @@ class TxtForm(ModelForm):
class DelTxtForm(Form): class DelTxtForm(Form):
"""Suppression d'un ou plusieurs TXT""" """Suppression d'un ou plusieurs TXT"""
txt = forms.ModelMultipleChoiceField( txt = forms.ModelMultipleChoiceField(
queryset=Text.objects.all(), queryset=Txt.objects.all(),
label="Enregistrements Txt actuels", label="Enregistrements Txt actuels",
widget=forms.CheckboxSelectMultiple widget=forms.CheckboxSelectMultiple
) )

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-11-15 14:14
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('machines', '0064_auto_20171115_0253'),
]
operations = [
migrations.RenameModel(
old_name='Text',
new_name='Txt',
),
]

View file

@ -382,7 +382,7 @@ class Ns(models.Model):
return str(self.zone) + ' ' + str(self.ns) return str(self.zone) + ' ' + str(self.ns)
class Text(models.Model): class Txt(models.Model):
""" Un enregistrement TXT associé à une extension""" """ Un enregistrement TXT associé à une extension"""
PRETTY_NAME = "Enregistrement TXT" PRETTY_NAME = "Enregistrement TXT"
@ -920,13 +920,13 @@ def ns_post_delete(sender, **kwargs):
regen('dns') regen('dns')
@receiver(post_save, sender=Text) @receiver(post_save, sender=Txt)
def text_post_save(sender, **kwargs): def text_post_save(sender, **kwargs):
"""Regeneration dns après modification d'un TXT""" """Regeneration dns après modification d'un TXT"""
regen('dns') regen('dns')
@receiver(post_delete, sender=Text) @receiver(post_delete, sender=Txt)
def text_post_delete(sender, **kwargs): def text_post_delete(sender, **kwargs):
"""Regeneration dns après modification d'un TX""" """Regeneration dns après modification d'un TX"""
regen('dns') regen('dns')

View file

@ -31,7 +31,7 @@ from machines.models import (
IpList, IpList,
MachineType, MachineType,
Domain, Domain,
Text, Txt,
Mx, Mx,
Service_link, Service_link,
Ns, Ns,
@ -195,20 +195,20 @@ class MxSerializer(serializers.ModelSerializer):
return str(obj.dns_entry) return str(obj.dns_entry)
class TextSerializer(serializers.ModelSerializer): class TxtSerializer(serializers.ModelSerializer):
"""Serialisation d'un txt : zone cible et l'entrée txt """Serialisation d'un txt : zone cible et l'entrée txt
sont evaluées à part""" sont evaluées à part"""
zone = serializers.SerializerMethodField('get_zone_name') zone = serializers.SerializerMethodField('get_zone_name')
text_entry = serializers.SerializerMethodField('get_text_name') txt_entry = serializers.SerializerMethodField('get_txt_name')
class Meta: class Meta:
model = Text model = Txt
fields = ('zone', 'text_entry', 'field1', 'field2') fields = ('zone', 'txt_entry', 'field1', 'field2')
def get_zone_name(self, obj): def get_zone_name(self, obj):
return str(obj.zone.name) return str(obj.zone.name)
def get_text_name(self, obj): def get_txt_name(self, obj):
return str(obj.dns_entry) return str(obj.dns_entry)

View file

@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
{% for txt in text_list %} {% for txt in txt_list %}
<tr> <tr>
<td>{{ txt.zone }}</td> <td>{{ txt.zone }}</td>
<td>{{ txt.dns_entry }}</td> <td>{{ txt.dns_entry }}</td>

View file

@ -94,7 +94,7 @@ urlpatterns = [
url(r'^rest/corresp/$', views.corresp, name='corresp'), url(r'^rest/corresp/$', views.corresp, name='corresp'),
url(r'^rest/mx/$', views.mx, name='mx'), url(r'^rest/mx/$', views.mx, name='mx'),
url(r'^rest/ns/$', views.ns, name='ns'), url(r'^rest/ns/$', views.ns, name='ns'),
url(r'^rest/text/$', views.text, name='text'), url(r'^rest/txt/$', views.txt, name='txt'),
url(r'^rest/zones/$', views.zones, name='zones'), url(r'^rest/zones/$', views.zones, name='zones'),
url(r'^rest/service_servers/$', views.service_servers, name='service-servers'), url(r'^rest/service_servers/$', views.service_servers, name='service-servers'),
url(r'^rest/ouverture_ports/$', views.ouverture_ports, name='ouverture-ports'), url(r'^rest/ouverture_ports/$', views.ouverture_ports, name='ouverture-ports'),

View file

@ -48,7 +48,7 @@ from machines.serializers import ( FullInterfaceSerializer,
InterfaceSerializer, InterfaceSerializer,
TypeSerializer, TypeSerializer,
DomainSerializer, DomainSerializer,
TextSerializer, TxtSerializer,
MxSerializer, MxSerializer,
ExtensionSerializer, ExtensionSerializer,
ServiceServersSerializer, ServiceServersSerializer,
@ -109,7 +109,7 @@ from .models import (
Service_link, Service_link,
Vlan, Vlan,
Nas, Nas,
Text, Txt,
OuverturePortList, OuverturePortList,
OuverturePort OuverturePort
) )
@ -721,8 +721,8 @@ def add_txt(request):
@permission_required('infra') @permission_required('infra')
def edit_txt(request, txtid): def edit_txt(request, txtid):
try: try:
txt_instance = Text.objects.get(pk=txtid) txt_instance = Txt.objects.get(pk=txtid)
except Text.DoesNotExist: except Txt.DoesNotExist:
messages.error(request, u"Entrée inexistante" ) messages.error(request, u"Entrée inexistante" )
return redirect(reverse('machines:index-extension')) return redirect(reverse('machines:index-extension'))
txt = TxtForm(request.POST or None, instance=txt_instance) txt = TxtForm(request.POST or None, instance=txt_instance)
@ -1045,8 +1045,8 @@ def index_extension(request):
soa_list = SOA.objects.order_by('name') soa_list = SOA.objects.order_by('name')
mx_list = Mx.objects.order_by('zone').select_related('zone').select_related('name__extension') mx_list = Mx.objects.order_by('zone').select_related('zone').select_related('name__extension')
ns_list = Ns.objects.order_by('zone').select_related('zone').select_related('ns__extension') ns_list = Ns.objects.order_by('zone').select_related('zone').select_related('ns__extension')
text_list = Text.objects.all().select_related('zone') txt_list = Txt.objects.all().select_related('zone')
return render(request, 'machines/index_extension.html', {'extension_list':extension_list, 'soa_list': soa_list, 'mx_list': mx_list, 'ns_list': ns_list, 'text_list' : text_list}) return render(request, 'machines/index_extension.html', {'extension_list':extension_list, 'soa_list': soa_list, 'mx_list': mx_list, 'ns_list': ns_list, 'txt_list' : txt_list})
@login_required @login_required
def index_alias(request, interfaceid): def index_alias(request, interfaceid):
@ -1141,8 +1141,8 @@ def history(request, object, id):
return redirect(reverse('machines:index')) return redirect(reverse('machines:index'))
elif object == 'txt' and request.user.has_perms(('cableur',)): elif object == 'txt' and request.user.has_perms(('cableur',)):
try: try:
object_instance = Text.objects.get(pk=id) object_instance = Txt.objects.get(pk=id)
except Text.DoesNotExist: except Txt.DoesNotExist:
messages.error(request, "Txt inexistant") messages.error(request, "Txt inexistant")
return redirect(reverse('machines:index')) return redirect(reverse('machines:index'))
elif object == 'ns' and request.user.has_perms(('cableur',)): elif object == 'ns' and request.user.has_perms(('cableur',)):
@ -1338,9 +1338,9 @@ def mx(request):
@csrf_exempt @csrf_exempt
@login_required @login_required
@permission_required('serveur') @permission_required('serveur')
def text(request): def txt(request):
text = Text.objects.all().select_related('zone') txt = Txt.objects.all().select_related('zone')
seria = TextSerializer(text, many=True) seria = TxtSerializer(txt, many=True)
return JSONResponse(seria.data) return JSONResponse(seria.data)
@csrf_exempt @csrf_exempt