summaryrefslogtreecommitdiff
path: root/mirrors/admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'mirrors/admin.py')
-rw-r--r--mirrors/admin.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/mirrors/admin.py b/mirrors/admin.py
index b7b9894c..d6ea3950 100644
--- a/mirrors/admin.py
+++ b/mirrors/admin.py
@@ -4,7 +4,9 @@ from urlparse import urlparse, urlunsplit
from django import forms
from django.contrib import admin
-from .models import Mirror, MirrorProtocol, MirrorUrl, MirrorRsync
+from .models import (Mirror, MirrorProtocol, MirrorUrl, MirrorRsync,
+ CheckLocation)
+
class MirrorUrlForm(forms.ModelForm):
class Meta:
@@ -26,12 +28,14 @@ class MirrorUrlForm(forms.ModelForm):
url = urlunsplit((url_parts.scheme, url_parts.netloc, path, '', ''))
return url
+
class MirrorUrlInlineAdmin(admin.TabularInline):
model = MirrorUrl
form = MirrorUrlForm
readonly_fields = ('protocol', 'has_ipv4', 'has_ipv6')
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}$')
@@ -43,16 +47,19 @@ class IPAddressNetmaskField(forms.fields.RegexField):
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 MirrorAdminForm(forms.ModelForm):
class Meta:
model = Mirror
@@ -60,22 +67,31 @@ class MirrorAdminForm(forms.ModelForm):
queryset=Mirror.objects.filter(tier__gte=0, tier__lte=1),
required=False)
+
class MirrorAdmin(admin.ModelAdmin):
form = MirrorAdminForm
- list_display = ('name', 'tier', 'country', 'active', 'public',
- 'isos', 'admin_email')
- list_filter = ('tier', 'active', 'public', 'country')
- search_fields = ('name',)
+ list_display = ('name', 'tier', 'active', 'public',
+ 'isos', 'admin_email', 'alternate_email')
+ list_filter = ('tier', 'active', 'public')
+ search_fields = ('name', 'admin_email', 'alternate_email')
inlines = [
MirrorUrlInlineAdmin,
MirrorRsyncInlineAdmin,
]
+
class MirrorProtocolAdmin(admin.ModelAdmin):
list_display = ('protocol', 'is_download', 'default')
list_filter = ('is_download', 'default')
+
+class CheckLocationAdmin(admin.ModelAdmin):
+ list_display = ('hostname', 'source_ip', 'country', 'created')
+ search_fields = ('hostname', 'source_ip')
+
+
admin.site.register(Mirror, MirrorAdmin)
admin.site.register(MirrorProtocol, MirrorProtocolAdmin)
+admin.site.register(CheckLocation, CheckLocationAdmin)
# vim: set ts=4 sw=4 et: