forked from ungleich-public/ipv6ula
[IPv6ULA] update the delete functon
This commit is contained in:
parent
d6a02cf945
commit
e13b5e97bd
2 changed files with 1 additions and 26 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django import forms
|
||||
import ipaddress
|
||||
from .models import validate_ula_prefix, ULA, validate_owner_ula_prefix
|
||||
from .models import validate_ula_prefix, ULA
|
||||
from django.core.exceptions import ValidationError
|
||||
import logging
|
||||
|
||||
|
|
|
|||
|
|
@ -31,31 +31,6 @@ def validate_ula_prefix(prefix):
|
|||
params = {'prefix': net }
|
||||
)
|
||||
|
||||
def validate_owner_ula_prefix(prefix):
|
||||
ula_net = ipaddress.IPv6Network("fd00::/8")
|
||||
net_str = f"{prefix}/48"
|
||||
net = ipaddress.IPv6Network(net_str, strict=False)
|
||||
|
||||
if not net.subnet_of(ula_net):
|
||||
raise ValidationError(
|
||||
_(f"Prefix {net} is not within ULA range ({ula_net})"),
|
||||
code='invalid',
|
||||
params = {'prefix': net }
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
ULA.objects.get(prefix=str(net[0]))
|
||||
except ULA.DoesNotExist:
|
||||
raise ValidationError(
|
||||
_(f"Prefix {net} is not your prefix"),
|
||||
code='invalid',
|
||||
params = {'prefix': net }
|
||||
)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
class User(AbstractUser):
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue