From fedcd092da745becbb3365b4ae0920e960ecd7e6 Mon Sep 17 00:00:00 2001 From: Duk Loi Date: Thu, 21 Apr 2016 16:44:34 -0400 Subject: [PATCH] Fix the active attribute check The datastore version object only contains the active attribute when the user is an admin user. The datastore version object for non-admin users does not have the active attribute. The absence of the active attribute should be considered active. Fixed the active attribute check to account for the case when the attribute is missing. Also modified the test data to create a datastore version without the active attribute to test this scenario. Change-Id: Ie134a69f57b92bc5fab97860d2839bd9c7f496ec Closes-Bug: #1573232 --- trove_dashboard/content/database_clusters/forms.py | 2 +- trove_dashboard/content/databases/workflows/create_instance.py | 2 ++ trove_dashboard/test/test_data/trove_data.py | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/trove_dashboard/content/database_clusters/forms.py b/trove_dashboard/content/database_clusters/forms.py index ba75f8d..18960f3 100644 --- a/trove_dashboard/content/database_clusters/forms.py +++ b/trove_dashboard/content/database_clusters/forms.py @@ -183,7 +183,7 @@ class LaunchForm(forms.SelfHandlingForm): versions = self.datastore_versions(request, ds.name) for version in versions: - if version.name == "inactive": + if hasattr(version, 'active') and not version.active: continue valid_flavor = self.datastore_flavors(request, ds.name, versions[0].name) diff --git a/trove_dashboard/content/databases/workflows/create_instance.py b/trove_dashboard/content/databases/workflows/create_instance.py index 64c48c2..1842858 100644 --- a/trove_dashboard/content/databases/workflows/create_instance.py +++ b/trove_dashboard/content/databases/workflows/create_instance.py @@ -120,6 +120,8 @@ class SetInstanceDetailsAction(workflows.Action): # only add to choices if datastore has at least one version version_choices = () for v in versions: + if hasattr(v, 'active') and not v.active: + continue version_choices = (version_choices + ((ds.name + ',' + v.name, v.name),)) datastore_choices = (ds.name, version_choices) diff --git a/trove_dashboard/test/test_data/trove_data.py b/trove_dashboard/test/test_data/trove_data.py index 6651870..1ad3a63 100644 --- a/trove_dashboard/test/test_data/trove_data.py +++ b/trove_dashboard/test/test_data/trove_data.py @@ -311,7 +311,6 @@ VERSION_TWO = { "name": "5.6", "links": [], "image": "c7956bb5-920e-4299-b68e-2347d830d938", - "active": 1, "datastore": "537fb940-b5eb-40d9-bdbd-91a3dcb9c17d", "packages": "5.6", "id": "500a6d52-8347-4e00-8e4c-f4fa9cf96ae9"