mirror of
https://github.com/daniviga/bite.git
synced 2024-11-23 05:16:13 +01:00
Commit forgotten changes from last night
This commit is contained in:
parent
ce88e47ed8
commit
ff9157dc7e
23
bite/bite/admin.py
Normal file
23
bite/bite/admin.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
#
|
||||||
|
# BITE - A Basic/IoT/Example
|
||||||
|
# Copyright (C) 2020 Daniele Viganò <daniele@vigano.me>
|
||||||
|
#
|
||||||
|
# BITE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# BITE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
admin.site.site_header = 'BITE administration'
|
||||||
|
admin.site.site_title = 'BITE site administration'
|
|
@ -60,6 +60,7 @@ INSTALLED_APPS = [
|
||||||
'health_check.db',
|
'health_check.db',
|
||||||
# 'health_check.storage',
|
# 'health_check.storage',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
'bite',
|
||||||
'api',
|
'api',
|
||||||
'telemetry',
|
'telemetry',
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,13 +17,29 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pygments import highlight
|
||||||
|
from pygments.lexers import JsonLexer
|
||||||
|
from pygments.formatters import HtmlFormatter
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from telemetry.models import Telemetry
|
from telemetry.models import Telemetry
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Telemetry)
|
@admin.register(Telemetry)
|
||||||
class TelemetryAdmin(admin.ModelAdmin):
|
class TelemetryAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = ('device', 'transport', 'time', 'clock', 'payload',)
|
fields = ('device', 'transport', 'time', 'clock', 'payload_pp',)
|
||||||
|
readonly_fields = fields
|
||||||
list_display = ('__str__', 'device')
|
list_display = ('__str__', 'device')
|
||||||
list_filter = ('time', 'device__serial')
|
list_filter = ('time', 'device__serial')
|
||||||
search_fields = ('device__serial',)
|
search_fields = ('device__serial',)
|
||||||
|
|
||||||
|
def payload_pp(self, instance):
|
||||||
|
response = json.dumps(instance.payload, sort_keys=True, indent=2)
|
||||||
|
formatter = HtmlFormatter(style='colorful')
|
||||||
|
response = highlight(response, JsonLexer(), formatter)
|
||||||
|
style = "<style>" + formatter.get_style_defs() + "</style>"
|
||||||
|
return mark_safe(style + response)
|
||||||
|
|
||||||
|
payload_pp.short_description = 'Payload'
|
||||||
|
|
|
@ -4,4 +4,5 @@ django-health-check
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
paho-mqtt==1.5.0
|
paho-mqtt==1.5.0
|
||||||
asyncio-mqtt==0.5.0
|
asyncio-mqtt==0.5.0
|
||||||
|
pygments
|
||||||
gunicorn
|
gunicorn
|
||||||
|
|
Loading…
Reference in New Issue
Block a user