-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
django: Adapt to the new database model
- Rewrite the serializer for single and multi resource - Adapt admin dashboard - Remove listView for now, admin dashboard is sufficient for testing currently Signed-off-by: Jonas Remmert <jremmert@gmx.net>
- Loading branch information
Showing
11 changed files
with
285 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
from django.contrib import admin | ||
from .models import ( | ||
Device, | ||
ResourceType, | ||
Resource, | ||
Event, | ||
EventResource, | ||
DeviceOperation, | ||
Firmware | ||
) | ||
|
||
# Register your models here. | ||
@admin.register(Device) | ||
class DeviceAdmin(admin.ModelAdmin): | ||
list_display = ('device_id', 'name') | ||
search_fields = ('device_id', 'name') | ||
|
||
@admin.register(ResourceType) | ||
class ResourceTypeAdmin(admin.ModelAdmin): | ||
list_display = ('object_id', 'resource_id', 'name', 'data_type') | ||
search_fields = ('object_id', 'resource_id', 'name') | ||
|
||
@admin.register(Resource) | ||
class ResourceAdmin(admin.ModelAdmin): | ||
list_display = ('device', 'resource_type', 'timestamp') | ||
search_fields = ('device__device_id', 'resource_type__name') | ||
list_filter = ('device', 'resource_type', 'timestamp') | ||
|
||
@admin.register(Event) | ||
class EventAdmin(admin.ModelAdmin): | ||
list_display = ('device', 'event_type', 'start_time', 'end_time') | ||
search_fields = ('device__device_id', 'event_type') | ||
list_filter = ('device', 'event_type') | ||
|
||
@admin.register(EventResource) | ||
class EventResourceAdmin(admin.ModelAdmin): | ||
list_display = ('event', 'resource') | ||
search_fields = ('event__event_type', 'resource__resource_type__name') | ||
list_filter = ('event', 'resource') | ||
|
||
@admin.register(DeviceOperation) | ||
class DeviceOperationAdmin(admin.ModelAdmin): | ||
list_display = ('resource', 'operation_type', 'status', 'timestamp_sent', | ||
'retransmit_counter', 'last_attempt') | ||
search_fields = ('resource__device__device_id', 'operation_type', 'status') | ||
list_filter = ('resource', 'operation_type', 'status', 'timestamp_sent') | ||
|
||
@admin.register(Firmware) | ||
class FirmwareAdmin(admin.ModelAdmin): | ||
list_display = ('version', 'file_name', 'download_url', 'created_at') | ||
search_fields = ('version', 'file_name') | ||
list_filter = ('created_at',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
LWM2M_RESOURCE_MAP = { | ||
(3303, 5700): {"name": "temperature", "data_type": "float"}, | ||
(3303, 5701): {"name": "humidity", "data_type": "float"}, | ||
(3, 0): {"name": "manufacturer", "data_type": "string"}, | ||
(3, 1): {"name": "model_number", "data_type": "string"}, | ||
(3, 2): {"name": "serial_number", "data_type": "string"}, | ||
(3, 3): {"name": "firmware_version", "data_type": "string"}, | ||
(3, 6): {"name": "power_source", "data_type": "int"}, | ||
(3, 7): {"name": "power_source_v", "data_type": "int"}, | ||
(3, 8): {"name": "power_source_i", "data_type": "int"}, | ||
(3, 9): {"name": "battery_level", "data_type": "int"}, | ||
(3, 10): {"name": "memory_free", "data_type": "int"}, | ||
(3, 11): {"name": "error_code", "data_type": "int"}, | ||
(3, 13): {"name": "current_time", "data_type": "time"}, | ||
(3, 14): {"name": "utc_offset", "data_type": "string"}, | ||
(3, 15): {"name": "timezone", "data_type": "string"}, | ||
(3, 16): {"name": "binding_mode", "data_type": "string"}, | ||
(3, 17): {"name": "device_type", "data_type": "string"}, | ||
(3, 18): {"name": "hardware_version", "data_type": "string"}, | ||
(3, 19): {"name": "software_version", "data_type": "string"}, | ||
(3, 20): {"name": "battery_status", "data_type": "int"}, | ||
(3, 21): {"name": "memory_total", "data_type": "int"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.