generated from erangel1/generic-template
initial commit. phase 1 complete
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""Django admin registration for all core models."""
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Edge, HeartbeatLog, Network, Node, WikiPage
|
||||
|
||||
|
||||
@admin.register(Node)
|
||||
class NodeAdmin(admin.ModelAdmin): # type: ignore[type-arg]
|
||||
list_display = ("label", "node_type", "status", "ip_address", "discovery_source", "updated_at")
|
||||
list_filter = ("node_type", "status", "discovery_source")
|
||||
search_fields = ("label", "ip_address", "mac_address", "external_id")
|
||||
readonly_fields = ("id", "created_at", "updated_at")
|
||||
ordering = ("label",)
|
||||
list_per_page = 50
|
||||
|
||||
|
||||
@admin.register(Edge)
|
||||
class EdgeAdmin(admin.ModelAdmin): # type: ignore[type-arg]
|
||||
list_display = ("source", "target", "edge_type", "weight", "created_at")
|
||||
list_filter = ("edge_type",)
|
||||
raw_id_fields = ("source", "target")
|
||||
readonly_fields = ("id", "created_at")
|
||||
list_per_page = 50
|
||||
|
||||
|
||||
@admin.register(Network)
|
||||
class NetworkAdmin(admin.ModelAdmin): # type: ignore[type-arg]
|
||||
list_display = ("name", "cidr", "vlan_id", "gateway", "created_at")
|
||||
search_fields = ("name", "cidr")
|
||||
readonly_fields = ("id", "created_at", "updated_at")
|
||||
list_per_page = 50
|
||||
|
||||
|
||||
@admin.register(WikiPage)
|
||||
class WikiPageAdmin(admin.ModelAdmin): # type: ignore[type-arg]
|
||||
list_display = ("node", "last_edited_by", "updated_at")
|
||||
raw_id_fields = ("node", "last_edited_by")
|
||||
readonly_fields = ("id", "created_at", "updated_at")
|
||||
list_per_page = 50
|
||||
|
||||
|
||||
@admin.register(HeartbeatLog)
|
||||
class HeartbeatLogAdmin(admin.ModelAdmin): # type: ignore[type-arg]
|
||||
list_display = ("node", "status", "check_type", "response_time_ms", "timestamp")
|
||||
list_filter = ("status", "check_type")
|
||||
raw_id_fields = ("node",)
|
||||
readonly_fields = ("id", "timestamp")
|
||||
date_hierarchy = "timestamp"
|
||||
list_per_page = 100
|
||||
Reference in New Issue
Block a user