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

from correlation.models import Rule, Group


class RuleAdmin(admin.ModelAdmin):
    list_display = ("name", "depth", "created", "updated")
    list_display_links = ["name"]

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


class GroupAdmin(admin.ModelAdmin):
    list_display = ("name",)
    list_display_links = ["name"]


admin.site.register(Rule, RuleAdmin)
admin.site.register(Group, GroupAdmin)
