|
|
@@ -3,14 +3,21 @@ from django.core.validators import MinValueValidator, MaxValueValidator
|
|
|
from django.db import models
|
|
|
from netaddr import AddrFormatError, EUI, mac_unix_expanded
|
|
|
|
|
|
+from .constants import *
|
|
|
+
|
|
|
|
|
|
class ASNField(models.BigIntegerField):
|
|
|
description = "32-bit ASN field"
|
|
|
default_validators = [
|
|
|
- MinValueValidator(1),
|
|
|
- MaxValueValidator(4294967295),
|
|
|
+ MinValueValidator(BGP_ASN_MIN),
|
|
|
+ MaxValueValidator(BGP_ASN_MAX),
|
|
|
]
|
|
|
|
|
|
+ def formfield(self, **kwargs):
|
|
|
+ defaults = {'min_value': BGP_ASN_MIN, 'max_value': BGP_ASN_MAX}
|
|
|
+ defaults.update(**kwargs)
|
|
|
+ return super().formfield(**defaults)
|
|
|
+
|
|
|
|
|
|
class mac_unix_expanded_uppercase(mac_unix_expanded):
|
|
|
word_fmt = '%.2X'
|