Merge "Reset role's nodes to 0 if it has no flavor"
This commit is contained in:
commit
67a52dc978
@ -57,3 +57,12 @@ class EditPlan(forms.EditPlan):
|
|||||||
LOG.exception(e)
|
LOG.exception(e)
|
||||||
return False
|
return False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
cleaned_data = super(EditPlan, self).clean()
|
||||||
|
# If a role has no flavor, it should have no nodes.
|
||||||
|
for key, value in cleaned_data.items():
|
||||||
|
if key.endswith('-flavor'):
|
||||||
|
if not value:
|
||||||
|
cleaned_data[key.replace('-flavor', '-count')] = 0
|
||||||
|
return cleaned_data
|
||||||
|
@ -139,11 +139,14 @@ class IndexView(views.IndexView):
|
|||||||
if 'form' in data:
|
if 'form' in data:
|
||||||
role['flavor_field'] = data['form'][role['id'] + '-flavor']
|
role['flavor_field'] = data['form'][role['id'] + '-flavor']
|
||||||
flavor = role['role'].flavor(data['plan'])
|
flavor = role['role'].flavor(data['plan'])
|
||||||
if flavor and flavor.id in [f.id for f in flavors]:
|
if flavor and flavor.name in [f.name for f in flavors]:
|
||||||
role['flavor_name'] = flavor.name
|
role['flavor_name'] = flavor.name
|
||||||
flavor_roles.setdefault(flavor.name, []).append(role)
|
flavor_roles.setdefault(flavor.name, []).append(role)
|
||||||
else:
|
else:
|
||||||
role['flavor_name'] = ''
|
role['flavor_name'] = ''
|
||||||
|
field = role.get('flavor_field')
|
||||||
|
if field:
|
||||||
|
field.initial = 0
|
||||||
free_roles.append(role)
|
free_roles.append(role)
|
||||||
data['free_roles'] = free_roles
|
data['free_roles'] = free_roles
|
||||||
data['flavors'] = list(
|
data['flavors'] = list(
|
||||||
|
Loading…
Reference in New Issue
Block a user