Add Tempmon Appliance views, menu link

also remove edit/delete restrictions for tempmon clients, probes.  now we just
let the normal permissions handle that
This commit is contained in:
Lance Edgar 2020-03-22 16:39:42 -05:00
parent 099fe14de1
commit b044790d51
3 changed files with 6 additions and 49 deletions

View file

@ -151,6 +151,11 @@ def simple_menus(request):
'title': "TempMon", 'title': "TempMon",
'type': 'menu', 'type': 'menu',
'items': [ 'items': [
{
'title': "Appliances",
'url': url('tempmon.appliances'),
'perm': 'tempmon.appliances.list',
},
{ {
'title': "Clients", 'title': "Clients",
'url': url('tempmon.clients'), 'url': url('tempmon.clients'),

View file

@ -29,7 +29,7 @@ def includeme(config):
config.include('rattail_demo.web.views.settings') config.include('rattail_demo.web.views.settings')
config.include('tailbone.views.stores') config.include('tailbone.views.stores')
config.include('tailbone.views.subdepartments') config.include('tailbone.views.subdepartments')
config.include('rattail_demo.web.views.tempmon') config.include('tailbone.views.tempmon')
config.include('rattail_demo.web.views.upgrades') config.include('rattail_demo.web.views.upgrades')
config.include('tailbone.views.users') config.include('tailbone.views.users')
config.include('rattail_demo.web.views.vendors') config.include('rattail_demo.web.views.vendors')

View file

@ -1,48 +0,0 @@
# -*- coding: utf-8 -*-
"""
Tempmon views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views.tempmon.clients import TempmonClientView as BaseTempmonClientView
from tailbone.views.tempmon.probes import TempmonProbeView as BaseTempmonProbeView
class TempmonClientView(BaseTempmonClientView):
"""
Prevent edit/delete for 'demo' client
"""
def editable_instance(self, client):
return client.config_key != 'demo'
def deletable_instance(self, client):
return client.config_key != 'demo'
def restartable_client(self, client):
return client.config_key == 'demo'
def get_restart_cmd(self, client):
if self.rattail_config.production():
return ['ssh', 'demo.rattailproject.org', 'sudo service demo-tempmon-client restart']
# just mock it out when testing
return ['sleep', '2']
class TempmonProbeView(BaseTempmonProbeView):
"""
Prevent edit/delete for 'demo' probe
"""
def editable_instance(self, probe):
return probe.config_key != 'demo'
def deletable_instance(self, probe):
return probe.config_key != 'demo'
def includeme(config):
TempmonClientView.defaults(config)
TempmonProbeView.defaults(config)
config.include('tailbone.views.tempmon.readings')