diff options
author | Dan McGee <dan@archlinux.org> | 2013-03-07 02:53:11 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2013-03-07 02:53:11 +0100 |
commit | 71259ab4c27ca6f00e09e813c7d9c6e8e24d59b4 (patch) | |
tree | 32a7842e35201a6d8b57509057b9449f40ac96b4 | |
parent | 1dbf311774f7894cac870517558d8baee8681f0d (diff) | |
download | archweb-71259ab4c27ca6f00e09e813c7d9c6e8e24d59b4.tar.gz archweb-71259ab4c27ca6f00e09e813c7d9c6e8e24d59b4.tar.xz |
Add mirror CheckLocationAdmin
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | mirrors/admin.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mirrors/admin.py b/mirrors/admin.py index eaa3839..d6ea395 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: |