allow deployments to be linked to dashboards
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index e8d0569..734d284 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -1240,7 +1240,7 @@
 
 class DashboardViewAdmin(PlanetStackBaseAdmin):
     fieldsets = [('Dashboard View Details',
-                   {'fields': ['backend_status_text', 'name', 'url', 'enabled'],
+                   {'fields': ['backend_status_text', 'name', 'url', 'enabled', 'deployments'],
                     'classes': ['suit-tab suit-tab-general']})
                ]
     list_display = ["name", "enabled", "url"]
diff --git a/planetstack/core/models/dashboard.py b/planetstack/core/models/dashboard.py
index 39dcf07..328a2ba 100644
--- a/planetstack/core/models/dashboard.py
+++ b/planetstack/core/models/dashboard.py
@@ -1,6 +1,6 @@
 import os
 from django.db import models
-from core.models import PlCoreBase, Controller
+from core.models import PlCoreBase, Controller, Deployment
 from core.models.site import ControllerLinkManager, ControllerLinkDeletionManager
 from django.contrib.contenttypes import generic
 
@@ -9,6 +9,7 @@
     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)
+    deployments = models.ManyToManyField(Deployment, blank=True, null=True, related_name="dashboardviews", help_text="Deployments that should be included in this view")
 
     def __unicode__(self):  return u'%s' % (self.name)
 
diff --git a/planetstack/core/xoslib/methods/tenantview.py b/planetstack/core/xoslib/methods/tenantview.py
index 77adf57..10323a2 100644
--- a/planetstack/core/xoslib/methods/tenantview.py
+++ b/planetstack/core/xoslib/methods/tenantview.py
@@ -12,19 +12,23 @@
 # This REST API endpoint contains a bunch of misc information that the
 # tenant view needs to display
 
-BLESSED_DEPLOYMENTS = ["ViCCI"] # ["US-MaxPlanck", "US-GeorgiaTech", "US-Princeton", "US-Washington", "US-Stanford"]
-
 def getTenantViewDict(user):
-    blessed_deployments = []
-    for deployment in Deployment.objects.all():
-        if deployment.name in BLESSED_DEPLOYMENTS:
-            blessed_deployments.append(deployment)
+    # compute blessed_deployments by looking for the tenant view, and seeing what
+    # deployments are attached to it.
+    blessed_deployments=[]
+    for dash in DashboardView.objects.all():
+        if (dash.url=="template:xosTenant"):
+            for deployment in dash.deployments.all():
+                if deployment not in blessed_deployments:
+                    blessed_deployments.append(deployment)
+
+    blessed_deployment_ids = [d.id for d in blessed_deployments]
 
     blessed_sites = []
     for site in Site.objects.all():
         good=False
         for deployment in site.deployments.all():
-            if deployment.name in BLESSED_DEPLOYMENTS:
+            if deployment.id in blessed_deployment_ids:
                 # only bless sites that have at least one node in the deployment
                 sitedeployments = SiteDeployment.objects.filter(site=site, deployment=deployment)
                 for sd in sitedeployments.all():
@@ -37,7 +41,7 @@
     for image in Image.objects.all():
         good = False
         for deployment in image.deployments.all():
-            if deployment.name in BLESSED_DEPLOYMENTS:
+            if deployment.id in blessed_deployment_ids:
                  good=True
         if good:
             blessed_images.append(image)
@@ -46,7 +50,7 @@
     for flavor in Flavor.objects.all():
         good = False
         for deployment in flavor.deployments.all():
-            if deployment.name in BLESSED_DEPLOYMENTS:
+            if deployment.id in blessed_deployment_ids:
                  good=True
         if good:
             blessed_flavors.append(flavor)
@@ -74,7 +78,7 @@
     blessed_service_classes = [ServiceClass.objects.get(name="Best Effort")]
 
     return {"id": 0,
-            "blessed_deployment_names": BLESSED_DEPLOYMENTS,
+            "blessed_deployment_names": [deployment.name for deployment in blessed_deployments],
             "blessed_deployments": [deployment.id for deployment in blessed_deployments],
             "blessed_site_names": [site.name for site in blessed_sites],
             "blessed_sites": [site.id for site in blessed_sites],