Merge "Add validation checks for the update form"

This commit is contained in:
Jenkins 2017-08-18 09:54:07 +00:00 committed by Gerrit Code Review
commit 6c223d59f0
1 changed files with 12 additions and 0 deletions

View File

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