From b044790d51137d39561174b84ea36d3984aa6890 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 22 Mar 2020 16:39:42 -0500 Subject: [PATCH] Add Tempmon Appliance views, menu link also remove edit/delete restrictions for tempmon clients, probes. now we just let the normal permissions handle that --- rattail_demo/web/menus.py | 5 ++++ rattail_demo/web/views/__init__.py | 2 +- rattail_demo/web/views/tempmon.py | 48 ------------------------------ 3 files changed, 6 insertions(+), 49 deletions(-) delete mode 100644 rattail_demo/web/views/tempmon.py diff --git a/rattail_demo/web/menus.py b/rattail_demo/web/menus.py index 9b699e9..9e73781 100644 --- a/rattail_demo/web/menus.py +++ b/rattail_demo/web/menus.py @@ -151,6 +151,11 @@ def simple_menus(request): 'title': "TempMon", 'type': 'menu', 'items': [ + { + 'title': "Appliances", + 'url': url('tempmon.appliances'), + 'perm': 'tempmon.appliances.list', + }, { 'title': "Clients", 'url': url('tempmon.clients'), diff --git a/rattail_demo/web/views/__init__.py b/rattail_demo/web/views/__init__.py index 8784dd8..b954f35 100644 --- a/rattail_demo/web/views/__init__.py +++ b/rattail_demo/web/views/__init__.py @@ -29,7 +29,7 @@ def includeme(config): config.include('rattail_demo.web.views.settings') config.include('tailbone.views.stores') 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('tailbone.views.users') config.include('rattail_demo.web.views.vendors') diff --git a/rattail_demo/web/views/tempmon.py b/rattail_demo/web/views/tempmon.py deleted file mode 100644 index 8b36dce..0000000 --- a/rattail_demo/web/views/tempmon.py +++ /dev/null @@ -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')