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
This commit is contained in:
Duk Loi 2016-04-21 16:44:34 -04:00
parent 537a450a2a
commit fedcd092da
3 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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"