|
@@ -23,6 +23,7 @@ from urllib.parse import urlencode
|
|
|
|
|
|
from functools import partial, update_wrapper
|
|
|
from datetime import timedelta
|
|
|
+from ipaddress import IPv4Address
|
|
|
|
|
|
from djadhere.utils import get_active_filter
|
|
|
from adhesions.models import Adhesion
|
|
@@ -31,6 +32,7 @@ from .models import Service, ServiceType, IPPrefix, IPResource, IPResourceState,
|
|
|
ServiceAllocation, Antenna, AntennaAllocation, Allocation, \
|
|
|
Route, Tunnel, Switch, Port
|
|
|
from .utils.notifications import notify_allocation
|
|
|
+from .utils.ip_conversion import ipv4_to_ipv6
|
|
|
from .forms import AntennaForm, StopAllocationForm
|
|
|
|
|
|
|
|
@@ -463,7 +465,7 @@ class IPResourceAdmin(admin.ModelAdmin):
|
|
|
return self.get_readonly_fields(request, obj)
|
|
|
|
|
|
def get_readonly_fields(self, request, obj=None):
|
|
|
- fields = ['ip']
|
|
|
+ fields = ['ip', 'ip6']
|
|
|
if obj:
|
|
|
if obj.reserved:
|
|
|
fields += ['reserved']
|
|
@@ -557,6 +559,11 @@ class IPResourceAdmin(admin.ModelAdmin):
|
|
|
route.short_description = 'route'
|
|
|
route.admin_order_field = 'route'
|
|
|
|
|
|
+ def ip6(self, obj):
|
|
|
+ return ipv4_to_ipv6(IPv4Address(obj.ip))
|
|
|
+ ip6.short_description = 'Préfixe IPv6'
|
|
|
+ ip6.admin_order_field = 'ip'
|
|
|
+
|
|
|
def checkmk(self, obj):
|
|
|
return format_html('<a href="{}">{}</a>', obj.checkmk_url, 'voir')
|
|
|
checkmk.short_description = 'CheckMK'
|