feat / AEB-62 add additional DB schema for objects logic
This commit is contained in:
@@ -1,31 +1,93 @@
|
||||
from django.contrib import admin
|
||||
from .models import Multiplexor, Channel, SensorType, SignalFormat, Sensor, Metric, Alert
|
||||
from .models import *
|
||||
|
||||
@admin.register(Multiplexor)
|
||||
class MultiplexorAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'ip', 'subnet', 'gateway', 'sd_path')
|
||||
list_filter = ('name', 'ip', 'subnet', 'gateway', 'sd_path')
|
||||
search_fields = ('name', 'ip', 'subnet', 'gateway', 'sd_path')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('ip', 'subnet', 'gateway', 'sd_path')
|
||||
list_display_links = ('name',)
|
||||
|
||||
@admin.register(Channel)
|
||||
class ChannelAdmin(admin.ModelAdmin):
|
||||
list_display = ('multiplexor', 'number', 'position')
|
||||
list_filter = ('multiplexor', 'number', 'position')
|
||||
search_fields = ('multiplexor', 'number', 'position')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('number', 'position')
|
||||
list_display_links = ('multiplexor',)
|
||||
|
||||
@admin.register(SensorType)
|
||||
class SensorTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ('code', 'name', 'description')
|
||||
list_filter = ('code', 'name', 'description')
|
||||
search_fields = ('code', 'name', 'description')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('name', 'description')
|
||||
list_display_links = ('code',)
|
||||
|
||||
|
||||
@admin.register(Metric)
|
||||
class MetricAdmin(admin.ModelAdmin):
|
||||
list_display = ('timestamp', 'sensor', 'raw_value', 'value', 'status')
|
||||
list_filter = ('timestamp', 'sensor', 'status')
|
||||
search_fields = ('timestamp', 'sensor', 'status')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('value', 'status')
|
||||
list_display_links = ('timestamp',)
|
||||
|
||||
@admin.register(Alert)
|
||||
class AlertAdmin(admin.ModelAdmin):
|
||||
list_display = ('sensor', 'metric', 'sensor_type', 'message', 'severity', 'created_at', 'resolved')
|
||||
list_filter = ('sensor', 'metric', 'sensor_type', 'severity')
|
||||
search_fields = ('sensor', 'metric', 'sensor_type', 'severity')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('message', 'severity', 'resolved')
|
||||
list_display_links = ('sensor',)
|
||||
|
||||
@admin.register(SignalFormat)
|
||||
class SignalFormatAdmin(admin.ModelAdmin):
|
||||
list_display = ('sensor_type', 'code', 'unit', 'conversion_rule')
|
||||
list_filter = ('sensor_type', 'code', 'unit', 'conversion_rule')
|
||||
search_fields = ('sensor_type', 'code', 'unit', 'conversion_rule')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('unit', 'conversion_rule')
|
||||
list_display_links = ('sensor_type',)
|
||||
|
||||
@admin.register(Sensor)
|
||||
class SensorAdmin(admin.ModelAdmin):
|
||||
list_display = ('channel', 'sensor_type', 'signal_format', 'serial_number', 'name', 'math_formula')
|
||||
list_display = ('channel', 'sensor_type', 'signal_format', 'serial_number', 'name', 'math_formula')
|
||||
list_filter = ('channel', 'sensor_type', 'signal_format', 'serial_number', 'name', 'math_formula')
|
||||
search_fields = ('channel', 'sensor_type', 'signal_format', 'serial_number', 'name', 'math_formula')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('signal_format', 'serial_number', 'name', 'math_formula')
|
||||
list_display_links = ('channel',)
|
||||
|
||||
@admin.register(Object)
|
||||
class ObjectAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'description', 'image', 'address', 'floors', 'area')
|
||||
list_filter = ('title', 'description', 'image', 'address', 'floors', 'area')
|
||||
search_fields = ('title', 'description', 'image', 'address', 'floors', 'area')
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('image', 'address', 'floors', 'area')
|
||||
list_display_links = ('title',)
|
||||
|
||||
@admin.register(Zone)
|
||||
class ZoneAdmin(admin.ModelAdmin):
|
||||
list_display = ('object', 'name') # Removed sensors from list_display
|
||||
list_filter = ('object', 'name') # Removed sensors from list_filter
|
||||
search_fields = ('object', 'name') # Removed sensors from search_fields
|
||||
list_per_page = 10
|
||||
list_max_show_all = 100
|
||||
list_editable = ('name',) # Changed to tuple with name only
|
||||
list_display_links = ('object',)
|
||||
Reference in New Issue
Block a user