from django.contrib import admin
from . import models


class ScrapeReportInline(admin.TabularInline):
    model = models.ScrapeReport
    readonly_fields = ('scraper', 'args', 'start_time', 'end_time',
                       'get_object_list')

    def has_add_permission(self, request):
        return False
    can_delete = False

    def get_object_list(self, obj):
        return '\n'.join('{} ({})'.format(o.object_type, o.count) for o in
                         obj.scraped_objects.all())


class ImportObjectsInline(admin.TabularInline):
    model = models.ImportObjects
    readonly_fields = ('object_type', 'insert_count', 'update_count',
                       'noop_count', 'start_time', 'end_time')

    def has_add_permission(self, request):
        return False
    can_delete = False


@admin.register(models.RunPlan)
class RunPlanAdmin(admin.ModelAdmin):
    actions = None

    readonly_fields = ('jurisdiction', 'success', 'start_time', 'end_time',
                       'exception', 'traceback')
    list_filter = ('jurisdiction__name', 'success')
    list_display = ('jurisdiction', 'success', 'start_time')
    inlines = [
        ScrapeReportInline,
        ImportObjectsInline,
    ]

    def has_delete_permission(self, request, obj=None):
        return False

    def has_add_permission(self, request):
        return False

@@ -1326,28 +1326,1382 @@
 uest):%0A        return False%0A
+%0A%0A@admin.register(models.SessionDataQualityReport)%0Aclass SessionDataQualityAdmin(admin.ModelAdmin):%0A    actions = None%0A%0A    readonly_fields = ('legislative_session',%0A                       'bills_missing_actions',%0A                       'bills_missing_sponsors',%0A                       'bills_missing_versions',%0A                       'votes_missing_voters',%0A                       'votes_missing_bill',%0A                       'votes_missing_yes_count',%0A                       'votes_missing_no_count',%0A                       'votes_with_bad_counts',%0A                       'unmatched_sponsor_people',%0A                       'unmatched_sponsor_organizations',%0A                       'unmatched_voters',%0A                       )%0A    list_display = ('jurisdiction_name',%0A                    'legislative_session',%0A                    'bills_missing_actions',%0A                    'bills_missing_sponsors',%0A                    'bills_missing_versions',%0A                    'votes_missing_voters',%0A                    'votes_missing_bill',%0A                    'votes_missing_yes_count',%0A                    'votes_missing_no_count',%0A                    'votes_with_bad_counts',%0A                    )%0A    list_filter = ('legislative_session__jurisdiction__name',)%0A%0A    def jurisdiction_name(self, obj):%0A        return obj.legislative_session.jurisdiction.name%0A

add basic report admin view