Add support for tempmon views

This commit is contained in:
Lance Edgar 2016-12-10 11:24:01 -06:00
parent 94993cf553
commit 50509f8f52
3 changed files with 57 additions and 0 deletions

View file

@ -73,6 +73,23 @@
</li>
% endif
% if request.has_any_perm('tempmon.clients.list', 'tempmon.probes.list', 'tempmon.readings.list'):
<li>
<a>TempMon</a>
<ul>
% if request.has_perm('tempmon.clients.list'):
<li>${h.link_to("Clients", url('tempmon.clients'))}</li>
% endif
% if request.has_perm('tempmon.probes.list'):
<li>${h.link_to("Probes", url('tempmon.probes'))}</li>
% endif
% if request.has_perm('tempmon.readings.list'):
<li>${h.link_to("Readings", url('tempmon.readings'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('users.list', 'roles.list', 'settings.list'):
<li>
<a>Admin</a>

View file

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

View file

@ -0,0 +1,39 @@
# -*- 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'
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')