Commits

Łukasz Langa  committed 2eddf6d

optional Django 1.4+ forward/reverse domain filter

  • Participants
  • Parent commits 13d3d24

Comments (0)

Files changed (5)

File powerdns/admin.py

 # -*- coding: utf-8 -*-
 
-from django.forms import NullBooleanSelect
 from django.contrib import admin
 from django.contrib.admin.widgets import AdminRadioSelect
 from django.db import models
+from django.forms import NullBooleanSelect
+from django.utils.translation import ugettext_lazy as _
 from powerdns.models import (CryptoKey, Domain, DomainMetadata, Record,
                              SuperMaster)
 
     pass
 
 
+try:
+    from django.contrib.admin import SimpleListFilter
+except ImportError:
+    _domain_filters = ('type', 'last_check', 'account',)
+else:
+    class ReverseDomainListFilter(SimpleListFilter):
+        title = _('domain class')
+
+        # Parameter for the filter that will be used in the URL query.
+        parameter_name = 'domain_class'
+
+        def lookups(self, request, model_admin):
+            return (
+                ('fwd', _('domain:forward')),
+                ('rev', _('domain:reverse')),
+            )
+
+        def queryset(self, request, queryset):
+            q = (models.Q(name__endswith='.in-addr.arpa') |
+                 models.Q(name__endswith='.ip6.arpa'))
+            if self.value() == 'fwd':
+                return queryset.exclude(q)
+            if self.value() == 'rev':
+                return queryset.filter(q)
+    _domain_filters = (
+        ReverseDomainListFilter, 'type', 'last_check', 'account',
+    )
+
+
 class RecordAdmin(admin.ModelAdmin):
     list_display = (
         'name', 'type', 'content', 'domain', 'ttl', 'prio', 'change_date',
     list_per_page = 250
     save_on_top = True
     search_fields = ('name', 'content',)
-    #radio_fields = {'auth': admin.HORIZONTAL}
     readonly_fields = ('change_date', 'ordername',)
     fieldsets = (
         (None, {
 class DomainAdmin(admin.ModelAdmin):
     inlines = [DomainMetadataInline]
     list_display = ('name', 'type', 'last_check', 'account',)
-    list_filter = ('type', 'last_check', 'account',)
+    list_filter = _domain_filters
     list_per_page = 250
     save_on_top = True
     search_fields = ('name',)

File powerdns/locale/en/LC_MESSAGES/django.mo

Binary file modified.

File powerdns/locale/en/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-03 18:03-0500\n"
+"POT-Creation-Date: 2012-11-06 01:34+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: models.py:40
+#: admin.py:22
+msgid "domain class"
+msgstr ""
+
+#: admin.py:29
+msgid "domain:forward"
+msgstr "forward"
+
+#: admin.py:30
+msgid "domain:reverse"
+msgstr "reverse"
+
+#: models.py:47
 #, python-format
 msgid "%s is not allowed to end in a period!"
 msgstr ""
 
-#: models.py:49
+#: models.py:57
 msgid "Enter a valid IPv6 address."
 msgstr ""
 
-#: models.py:61 models.py:95
+#: models.py:70 models.py:104
 msgid "name"
 msgstr ""
 
-#: models.py:63
+#: models.py:72
 msgid "master"
 msgstr ""
 
-#: models.py:65
+#: models.py:74
 msgid "last check"
 msgstr ""
 
-#: models.py:67 models.py:102
+#: models.py:76 models.py:111
 msgid "type"
 msgstr ""
 
-#: models.py:70
+#: models.py:79
 msgid "notified serial"
 msgstr ""
 
-#: models.py:73 models.py:241
+#: models.py:82 models.py:250
 msgid "account"
 msgstr ""
 
-#: models.py:78 models.py:93 models.py:256 models.py:272
+#: models.py:87 models.py:102 models.py:265 models.py:281
 msgid "domain"
 msgstr ""
 
-#: models.py:79
+#: models.py:88
 msgid "domains"
 msgstr ""
 
-#: models.py:97
+#: models.py:106
 msgid ""
 "Actual name of a record. Must not end in a '.' and be fully qualified - it "
 "is not relative to the name of the domain!"
 msgstr ""
 
-#: models.py:103
+#: models.py:112
 msgid "Record qtype"
 msgstr ""
 
-#: models.py:106 models.py:258 models.py:277
+#: models.py:115 models.py:267 models.py:286
 msgid "content"
 msgstr ""
 
-#: models.py:108
+#: models.py:117
 msgid ""
 "The 'right hand side' of a DNS record. For an A record, this is the IP "
 "address"
 msgstr ""
 
-#: models.py:112
+#: models.py:121
 msgid "TTL"
 msgstr ""
 
-#: models.py:113
+#: models.py:122
 msgid "TTL in seconds"
 msgstr ""
 
-#: models.py:116
+#: models.py:125
 msgid "priority"
 msgstr ""
 
-#: models.py:117
+#: models.py:126
 msgid ""
 "For MX records, this should be the priority of the mail exchanger specified"
 msgstr ""
 
-#: models.py:121
+#: models.py:130
 msgid "change date"
 msgstr ""
 
-#: models.py:122
+#: models.py:131
 msgid ""
 "Set automatically by the system to trigger SOA updates and slave "
 "notifications"
 msgstr ""
 
-#: models.py:126
+#: models.py:135
 msgid "DNSSEC Order"
 msgstr ""
 
-#: models.py:129
+#: models.py:138
 msgid "authoritative"
 msgstr ""
 
-#: models.py:130
+#: models.py:139
 msgid ""
 "Should be set for data for which is itself authoritative, which includes the "
 "SOA record and our own NS records but not set for NS records which are used "
 "for delegation or any delegation related glue (A, AAAA) records"
 msgstr ""
 
-#: models.py:141
+#: models.py:150
 msgid "record"
 msgstr ""
 
-#: models.py:142
+#: models.py:151
 msgid "records"
 msgstr ""
 
-#: models.py:238
+#: models.py:247
 msgid "IP"
 msgstr ""
 
-#: models.py:239
+#: models.py:248
 msgid "name server"
 msgstr ""
 
-#: models.py:248
+#: models.py:257
 msgid "supermaster"
 msgstr ""
 
-#: models.py:249
+#: models.py:258
 msgid "supermasters"
 msgstr ""
 
-#: models.py:257
+#: models.py:266
 msgid "kind"
 msgstr ""
 
-#: models.py:263 models.py:264
+#: models.py:272 models.py:273
 msgid "domain metadata"
 msgstr ""
 
-#: models.py:275
+#: models.py:284
 msgid "flags"
 msgstr ""
 
-#: models.py:276
+#: models.py:285
 msgid "active"
 msgstr ""
 
-#: models.py:282
+#: models.py:291
 msgid "crypto key"
 msgstr ""
 
-#: models.py:283
+#: models.py:292
 msgid "crypto keys"
 msgstr ""

File powerdns/locale/pl/LC_MESSAGES/django.mo

Binary file modified.

File powerdns/locale/pl/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-03 18:03-0500\n"
+"POT-Creation-Date: 2012-11-06 01:34+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
 "|| n%100>=20) ? 1 : 2)\n"
 
-#: models.py:40
+#: admin.py:22
+msgid "domain class"
+msgstr "klasa domeny"
+
+#: admin.py:29
+msgid "domain:forward"
+msgstr "Zwykłe"
+
+#: admin.py:30
+msgid "domain:reverse"
+msgstr "Wsteczne"
+
+#: models.py:47
 #, python-format
 msgid "%s is not allowed to end in a period!"
 msgstr "%s nie może kończyć się kropką!"
 
-#: models.py:49
+#: models.py:57
 msgid "Enter a valid IPv6 address."
 msgstr "Wpisz poprawny adres IPv6."
 
-#: models.py:61 models.py:95
+#: models.py:70 models.py:104
 msgid "name"
 msgstr "nazwa"
 
-#: models.py:63
+#: models.py:72
 msgid "master"
 msgstr "master"
 
-#: models.py:65
+#: models.py:74
 msgid "last check"
 msgstr "ostatnie sprawdzenie"
 
-#: models.py:67 models.py:102
+#: models.py:76 models.py:111
 msgid "type"
 msgstr "typ"
 
-#: models.py:70
+#: models.py:79
 msgid "notified serial"
 msgstr "notyfikowany nr seryjny"
 
-#: models.py:73 models.py:241
+#: models.py:82 models.py:250
 msgid "account"
 msgstr "konto"
 
-#: models.py:78 models.py:93 models.py:256 models.py:272
+#: models.py:87 models.py:102 models.py:265 models.py:281
 msgid "domain"
 msgstr "domena"
 
-#: models.py:79
+#: models.py:88
 msgid "domains"
 msgstr "domeny"
 
-#: models.py:97
+#: models.py:106
 msgid ""
 "Actual name of a record. Must not end in a '.' and be fully qualified - it "
 "is not relative to the name of the domain!"
 "Nazwa rekordu. Nie może kończyć się kropką i musi być pełni kwalifikowana - "
 "nie jest relatywna do nazwy domeny!"
 
-#: models.py:103
+#: models.py:112
 msgid "Record qtype"
 msgstr "qtyp rekordu"
 
-#: models.py:106 models.py:258 models.py:277
+#: models.py:115 models.py:267 models.py:286
 msgid "content"
 msgstr "treść"
 
-#: models.py:108
+#: models.py:117
 msgid ""
 "The 'right hand side' of a DNS record. For an A record, this is the IP "
 "address"
 msgstr "'Prawa strona' rekordu DNS. Dla rekordów typu A, jest to adres IP"
 
-#: models.py:112
+#: models.py:121
 msgid "TTL"
 msgstr "TTL"
 
-#: models.py:113
+#: models.py:122
 msgid "TTL in seconds"
 msgstr "TTL w sekundach"
 
-#: models.py:116
+#: models.py:125
 msgid "priority"
 msgstr "priorytet"
 
-#: models.py:117
+#: models.py:126
 msgid ""
 "For MX records, this should be the priority of the mail exchanger specified"
 msgstr ""
 "Dla rekordów MX, powinien być to priorytet serwera poczty elektronicznej"
 
-#: models.py:121
+#: models.py:130
 msgid "change date"
 msgstr "data zmiany"
 
-#: models.py:122
+#: models.py:131
 msgid ""
 "Set automatically by the system to trigger SOA updates and slave "
 "notifications"
 "Ustawiane automatycznie przez system, by wymusić aktualizację SOA i serwerów "
 "slave"
 
-#: models.py:126
+#: models.py:135
 msgid "DNSSEC Order"
 msgstr ""
 
-#: models.py:129
+#: models.py:138
 msgid "authoritative"
 msgstr "autorytatywny"
 
-#: models.py:130
+#: models.py:139
 msgid ""
 "Should be set for data for which is itself authoritative, which includes the "
 "SOA record and our own NS records but not set for NS records which are used "
 "używanych do delegacji lub rekordów klejących (A, AAAA) związanych z "
 "delegacją"
 
-#: models.py:141
+#: models.py:150
 msgid "record"
 msgstr "rekord"
 
-#: models.py:142
+#: models.py:151
 msgid "records"
 msgstr "rekordy"
 
-#: models.py:238
+#: models.py:247
 msgid "IP"
 msgstr "IP"
 
-#: models.py:239
+#: models.py:248
 msgid "name server"
 msgstr "serwer nazw"
 
-#: models.py:248
+#: models.py:257
 msgid "supermaster"
 msgstr "supermaster"
 
-#: models.py:249
+#: models.py:258
 msgid "supermasters"
 msgstr "supermastery"
 
-#: models.py:257
+#: models.py:266
 msgid "kind"
 msgstr "rodzaj"
 
-#: models.py:263 models.py:264
+#: models.py:272 models.py:273
 msgid "domain metadata"
 msgstr "metadane domeny"
 
-#: models.py:275
+#: models.py:284
 msgid "flags"
 msgstr "flagi"
 
-#: models.py:276
+#: models.py:285
 msgid "active"
 msgstr "aktywny"
 
-#: models.py:282
+#: models.py:291
 msgid "crypto key"
 msgstr "klucz kryptograficzny"
 
-#: models.py:283
+#: models.py:292
 msgid "crypto keys"
 msgstr "klucze kryptograficzne"