From d6a61aef42561ea138fcb7b192f3082e018b852b Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sun, 18 Jan 2015 16:33:30 -0800 Subject: [PATCH] add ability to disable dashboards --- planetstack/core/admin.py | 2 +- planetstack/core/dashboard/views/home.py | 7 +++++++ planetstack/core/models/dashboard.py | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py index 5f9efd2..b195b30 100644 --- a/planetstack/core/admin.py +++ b/planetstack/core/admin.py @@ -1293,7 +1293,7 @@ class ControllerDashboardViewInline(PlStackTabularInline): class DashboardViewAdmin(PlanetStackBaseAdmin): fieldsets = [('Dashboard View Details', - {'fields': ['backend_status_text', 'name', 'url'], + {'fields': ['backend_status_text', 'name', 'url', 'enabled'], 'classes': ['suit-tab suit-tab-general']}) ] readonly_fields = ('backend_status_text', ) diff --git a/planetstack/core/dashboard/views/home.py b/planetstack/core/dashboard/views/home.py index 0d9ff74..6f57666 100644 --- a/planetstack/core/dashboard/views/home.py +++ b/planetstack/core/dashboard/views/home.py @@ -75,11 +75,18 @@ class DashboardDynamicView(TemplateView): dashboards.append(customize[0]) for i,view in enumerate(dashboards): + # don't display disabled dashboards + if (not view.enabled): + continue body = body + '
  • %s
  • \n' % (i, view.name) body = body + "\n" for i,view in enumerate(dashboards): + # don't display disabled dashboards + if (not view.enabled): + continue + url = view.url body = body + '
    \n' % i if (view.controllers.all().count()>0): diff --git a/planetstack/core/models/dashboard.py b/planetstack/core/models/dashboard.py index 828acec..39dcf07 100644 --- a/planetstack/core/models/dashboard.py +++ b/planetstack/core/models/dashboard.py @@ -8,6 +8,7 @@ class DashboardView(PlCoreBase): name = models.CharField(max_length=200, unique=True, help_text="Name of the View") url = models.CharField(max_length=1024, help_text="URL of Dashboard") controllers = models.ManyToManyField(Controller, blank=True, related_name="dashboardviews", through='ControllerDashboardView') + enabled = models.BooleanField(default=True) def __unicode__(self): return u'%s' % (self.name) @@ -16,6 +17,7 @@ class ControllerDashboardView(PlCoreBase): deleted_objects = ControllerLinkDeletionManager() controller = models.ForeignKey(Controller, related_name='controllerdashboardviews') dashboardView = models.ForeignKey(DashboardView, related_name='controllerdashboardviews') + enabled = models.BooleanField(default=True) url = models.CharField(max_length=1024, help_text="URL of Dashboard") -- 2.43.0