Commits

George Notaras committed 50856b1

Added basic administration interface.

  • Participants
  • Parent commits 35784f5

Comments (0)

Files changed (1)

File src/mydns_manager/admin.py

 from django.contrib import admin
 from django.db.models.loading import cache
 
+
+
+class RRInline(admin.TabularInline):
+    model = cache.get_model('mydns_manager', 'RR')
+    fields = ('name', 'type', 'ttl', 'aux', 'data', 'active', 'date_modified')
+    readonly_fields = ('date_modified', )
+    extra = 3
+
+
+
+class SOAAdmin(admin.ModelAdmin):
+    #form = DomainModelForm
+    #actions = [reload_php_stack, ]
+    
+    fieldsets = (
+        ('', {
+            'fields' : ('origin', 'ns', 'mbox', 'serial', 'active'),
+            #'description' : 'Main virtual host attributes',
+        }),
+        ('Timeouts', {
+            'fields' : ('refresh', 'retry', 'expire', 'minimum', 'ttl'),
+            #'description' : 'Information about the domain.',
+        }),
+        ('Info', {
+            'classes' : ('collapse',),
+            'fields' : ('date_created', 'date_modified', ),
+            #'description' : 'Information about the domain.',
+        }),
+    )
+    readonly_fields = ('date_created', 'date_modified', )
+    list_display = ('origin', 'active', 'date_created', 'date_modified')
+    list_filter = ('active', )
+    search_fields = ('origin', 'mbox')
+    inlines = [RRInline, ]
+    
+    def queryset(self, request):
+        qs = super(SOAAdmin, self).queryset(request)
+        if not request.user.is_superuser:
+            # Non-superusers see the domains they have created
+            qs = qs.filter(created_by=request.user)
+        return qs
+    
+    def save_model(self, request, obj, form, change):
+        if not change:
+            obj.created_by = request.user
+        obj.save()
+
+admin.site.register(cache.get_model('mydns_manager', 'SOA'), SOAAdmin)
+