Add validation checks for the update form
Instance reservation does not support update of reservation currently. This patch adds validation checks to the update form and hides unsupported fields if the lease includes instance reservations. Change-Id: I2cb51871ed4ff1d301569ee4a9be21be01aac263 Partially Implements: blueprint climate-dashboard
This commit is contained in:
parent
c4afe8b438
commit
2c11840565
|
@ -45,6 +45,18 @@ class UpdateForm(forms.SelfHandlingForm):
|
|||
attrs={'placeholder': _('Valid suffix are d/h/m (e.g. +1h)')}),
|
||||
required=False)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(UpdateForm, self).__init__(request, *args, **kwargs)
|
||||
for reservation in kwargs['initial']['lease'].reservations:
|
||||
if reservation['resource_type'] == 'virtual:instance':
|
||||
# Hide the start/end_time because they cannot be updated if at
|
||||
# least one virtual:instance reservation is included.
|
||||
# TODO(hiro-kobayashi) remove this part if virtual:instance
|
||||
# reservation gets to support update of the start/end_time.
|
||||
del self.fields['start_time']
|
||||
del self.fields['end_time']
|
||||
return
|
||||
|
||||
def handle(self, request, data):
|
||||
lease_id = data.get('lease_id')
|
||||
|
||||
|
|
Loading…
Reference in New Issue