Commit 8e5464a1 authored by Dalahro's avatar Dalahro
Browse files

Pour le dns

parent 80fcc69e
......@@ -4,6 +4,7 @@ from machines.models import Interface
class InterfaceSerializer( serializers.ModelSerializer):
class Meta:
model = Interface
fields = ('id','ipv4', 'mac_address')
fields = ('ipv4', 'mac_address', 'dns')
......@@ -16,6 +16,7 @@ urlpatterns = [
url(r'^edit_extension/(?P<extensionid>[0-9]+)$', views.edit_extension, name='edit-extension'),
url(r'^del_extension/$', views.del_extension, name='del-extension'),
url(r'^index_extension/$', views.index_extension, name='index-extension'),
url(r'^rest/mac-ip/$', views.interface_list, name='interface-list'),
url(r'^$', views.index, name='index'),
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),
url(r'^rest/dns-ip/$', views.dns_ip, name='dns-ip'),
......@@ -290,21 +290,31 @@ def index_extension(request):
class JSONResponse(HttpResponse):
def __init__(self, data, **kwargs):
for d in data:
interface = Interface.objects.get(pk=d["id"])
if d["ipv4"] and interface.is_active():
if d["ipv4"]:
d["ipv4"]= IpList.objects.get(pk=d["ipv4"]).__str__()
content = JSONRenderer().render(datas)
content = JSONRenderer().render(data)
kwargs['content_type'] = 'application/json'
super(JSONResponse, self).__init__(content, **kwargs)
def interface_list(request):
interfaces = Interface.objects.all()
seria = InterfaceSerializer(interfaces, many=True)
return JSONResponse(
interface = []
for i in interfaces :
if i.ipv4 and i.is_active():
seria = InterfaceSerializer(interface, many=True)
def mac_ip(request):
seria = interface_list(request)
for s in seria:
return JSONResponse(seria)
def dns_ip(request):
seria = interface_list(request)
for s in seria:
return JSONResponse(seria)
Supports Markdown
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