from django.contrib import admin
from django.contrib.postgres import fields
from django_json_widget.widgets import JSONEditorWidget

from incident.models import Incident,IncidentRecommendations,IncidentCategory,IncidentEffect


class IncidentAdmin(admin.ModelAdmin):
    date_hierarchy = 'timestamp'
    list_display = ('incident_id', 'timestamp', 'title', 'category', 'importance', 'status', 'assigned_to')
    list_filter = ('category', 'status', 'assigned_to')
    list_display_links = ['incident_id']

    formfield_overrides = {
        fields.JSONField: {'widget': JSONEditorWidget},
    }


admin.site.register(Incident, IncidentAdmin)
admin.site.register(IncidentRecommendations)
admin.site.register(IncidentCategory)
admin.site.register(IncidentEffect)
