hotcooler/hotcooler/admins.py
Lance Edgar e46b18f674 Add initial schema migration, with basic tempmon table clones
plus expose new tables in the admin
2017-04-01 18:34:01 -05:00

70 lines
1.7 KiB
Python

"""
Admin resources for hotcooler
"""
from websauna.system.admin.modeladmin import model_admin
from websauna.system.admin.modeladmin import ModelAdmin
# Import our models
from . import models
@model_admin(traverse_id='client')
class ClientAdmin(ModelAdmin):
"""Admin resource for tempmon client model.
This class declares a resource for client model admin root folder with listing and add views.
"""
#: Label as shown in admin
title = "Clients"
#: Used in admin listings etc. user visible messages
#: TODO: This mechanism will be phased out in the future versions with gettext or similar replacement for languages that have plulars one, two, many
singular_name = "client"
plural_name = "clients"
#: Which models this model admin controls
model = models.Client
class Resource(ModelAdmin.Resource):
"""Declare resource for each individual client.
View, edit and delete views are registered against this resource.
"""
def get_title(self):
return str(self.get_object())
@model_admin(traverse_id='probe')
class ProbeAdmin(ModelAdmin):
"""Admin resource for probe model."""
title = "Probes"
singular_name = "probe"
plural_name = "probes"
model = models.Probe
class Resource(ModelAdmin.Resource):
def get_title(self):
return str(self.get_object())
@model_admin(traverse_id='reading')
class ReadingAdmin(ModelAdmin):
"""Admin resource for reading model."""
title = "Readings"
singular_name = "reading"
plural_name = "readings"
model = models.Reading
class Resource(ModelAdmin.Resource):
def get_title(self):
return str(self.get_object())