summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/admin.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/main/admin.py b/main/admin.py
index c2a4054b..20532090 100644
--- a/main/admin.py
+++ b/main/admin.py
@@ -1,3 +1,4 @@
+import re
from django import forms
from django.contrib import admin
from django.contrib.auth.models import User
@@ -31,8 +32,24 @@ class MirrorUrlInlineAdmin(admin.TabularInline):
form = MirrorUrlForm
extra = 3
+# ripped off from django.forms.fields, adding netmask ability
+ipv4nm_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}(/(\d|[1-2]\d|3[0-2])){0,1}$')
+class IPAddressNetmaskField(forms.fields.RegexField):
+ default_error_messages = {
+ 'invalid': u'Enter a valid IPv4 address, possibly including netmask.',
+ }
+
+ def __init__(self, *args, **kwargs):
+ super(IPAddressNetmaskField, self).__init__(ipv4nm_re, *args, **kwargs)
+
+class MirrorRsyncForm(forms.ModelForm):
+ class Meta:
+ model = MirrorRsync
+ ip = IPAddressNetmaskField(label='IP')
+
class MirrorRsyncInlineAdmin(admin.TabularInline):
model = MirrorRsync
+ form = MirrorRsyncForm
extra = 2
class MirrorAdmin(admin.ModelAdmin):