from django.contrib import admin

from django_admin_listfilter_dropdown.filters import RelatedDropdownFilter, ChoiceDropdownFilter

from . import models

# Register your models here.

class HistoryAdmin(admin.ModelAdmin):
    list_display = ('company_name', 'rss_url', 'sync_date', 'result', 'quantity',)
    list_filter = (
        ('company', RelatedDropdownFilter),
    )

    def company_name(self, instance):
        if instance.company and instance.company.company_name:
            return instance.company.company_name
        else:
            return 'NULL'


admin.site.register(models.HistorySync, HistoryAdmin)
