Commits

George Notaras committed 701a5ae

Improved zone changelist for superusers.

  • Participants
  • Parent commits 551d765

Comments (0)

Files changed (1)

File src/powerdns_manager/admin.py

     form = DomainModelForm
     fields = ('date_modified', 'name', 'type', 'master', 'created_by')
     readonly_fields = ('date_modified', 'created_by')
-    list_display = ('name', 'export_zone_html_link', 'type', 'master', 'date_modified', 'created_by')
-    list_filter = ['type', 'created_by']
+    #list_display = ('name', 'export_zone_html_link', 'type', 'master', 'date_modified', 'created_by')
+    #list_display -- Set by get_list_display()
+    #list_filter = ['type', 'created_by']
+    #list_filter -- Set by get_list_filter()
     search_fields = ['name', 'master', 'created_by']
     verbose_name = 'zone'
     verbose_name_plural = 'zones'
     inlines.append(DomainMetadataInline)
     inlines.append(CryptoKeyInline)
     
+    def get_list_display(self, request):
+        list_display = ['name', 'export_zone_html_link', 'type', 'master', 'date_modified']
+        if request.user.is_superuser:
+            list_display.append('created_by')
+        return list_display
+    
+    def get_list_filter(self, request):
+        list_filter = ['type', ]
+        if request.user.is_superuser:
+            list_filter.append('created_by')
+        return list_filter
+    
     def queryset(self, request):
         qs = super(DomainAdmin, self).queryset(request)
         if not request.user.is_superuser: