36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from django.contrib import admin
|
|
|
|
from .models import ParameterUpdateLog, SensorData, SensorParameter
|
|
|
|
|
|
@admin.register(SensorData)
|
|
class SensorDataAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
"farm_uuid",
|
|
"center_location_id",
|
|
"weather_forecast_id",
|
|
"sensor_keys",
|
|
"updated_at",
|
|
)
|
|
list_filter = ("updated_at",)
|
|
search_fields = ("farm_uuid", "center_location_id")
|
|
filter_horizontal = ("plants",)
|
|
|
|
@admin.display(description="sensor keys")
|
|
def sensor_keys(self, obj):
|
|
payload = obj.sensor_payload if isinstance(obj.sensor_payload, dict) else {}
|
|
return ", ".join(payload.keys())
|
|
|
|
|
|
@admin.register(SensorParameter)
|
|
class SensorParameterAdmin(admin.ModelAdmin):
|
|
list_display = ("sensor_key", "code", "name_fa", "unit", "data_type", "created_at")
|
|
search_fields = ("sensor_key", "code", "name_fa")
|
|
list_filter = ("sensor_key", "data_type")
|
|
|
|
|
|
@admin.register(ParameterUpdateLog)
|
|
class ParameterUpdateLogAdmin(admin.ModelAdmin):
|
|
list_display = ("parameter", "action", "updated_at")
|
|
list_filter = ("action", "updated_at")
|