summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-03-06 19:53:11 -0600
committerDan McGee <dan@archlinux.org>2013-03-06 19:53:11 -0600
commit71259ab4c27ca6f00e09e813c7d9c6e8e24d59b4 (patch)
tree32a7842e35201a6d8b57509057b9449f40ac96b4
parent1dbf311774f7894cac870517558d8baee8681f0d (diff)
Add mirror CheckLocationAdmin
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/admin.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/mirrors/admin.py b/mirrors/admin.py
index eaa38391..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,6 +67,7 @@ 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', 'active', 'public',
@@ -71,11 +79,19 @@ class MirrorAdmin(admin.ModelAdmin):
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: