from django.contrib import admin

from scanning.models import PendingScan, Document, DocumentPage, Scan, ScanPage, Transcription

class ScanPageInline(admin.TabularInline):
    model = ScanPage
class ScanAdmin(admin.ModelAdmin):
    model = Scan
    inlines = [ScanPageInline]
admin.site.register(Scan, ScanAdmin)

class PendingScanAdmin(admin.ModelAdmin):
    model = PendingScan
    list_display = ('author', 'editor', 'code', 'created', 'completed')
    search_fields = ('code',)
admin.site.register(PendingScan, PendingScanAdmin)

class AuthorFilter(admin.SimpleListFilter):
    title = 'Author'
    parameter_name = 'author_id'

    def lookups(self, request, model_admin):
        qs = model_admin.queryset(request)
        return sorted(qs.filter(author__profile__blogger=True).order_by().values_list(
                    'author_id', 'author__profile__display_name'
                ).distinct(), key=lambda a: a[1])

    def queryset(self, request, queryset):
        if self.value():
            return queryset.filter(author_id=self.value())
        return queryset

class DocumentAdmin(admin.ModelAdmin):
    list_display = ['get_title', 'author', 'status', 'created']
    search_fields = ['title', 'author__profile__display_name',
                     'body', 'transcription__revisions__body']
    date_hierarchy = 'created'
    list_filter = ['type', 'status', 'author__profile__managed', AuthorFilter]
admin.site.register(Document, DocumentAdmin)

admin.site.register(DocumentPage)
admin.site.register(Transcription)

@@ -524,24 +524,25 @@
 ScanAdmin)%0A%0A
+#
 class Author
@@ -573,16 +573,17 @@
 ilter):%0A
+#
     titl
@@ -595,16 +595,17 @@
 Author'%0A
+#
     para
@@ -629,17 +629,19 @@
 hor_id'%0A
-%0A
+#%0A#
     def 
@@ -673,24 +673,25 @@
 del_admin):%0A
+#
         qs =
@@ -721,16 +721,17 @@
 equest)%0A
+#
         
@@ -809,16 +809,17 @@
 s_list(%0A
+#
         
@@ -875,16 +875,17 @@
 y_name'%0A
+#
         
@@ -926,17 +926,19 @@
 : a%5B1%5D)%0A
-%0A
+#%0A#
     def 
@@ -972,16 +972,17 @@
 ryset):%0A
+#
         
@@ -998,16 +998,17 @@
 alue():%0A
+#
         
@@ -1058,16 +1058,17 @@
 alue())%0A
+#
         
@@ -1344,16 +1344,16 @@
 reated'%0A
-
     list
@@ -1407,16 +1407,18 @@
 managed'
+%5D#
 , Author

Disable busted admin filter