Commit 6d4024aa by Őry Máté

dashboard: allow selecting new state on forced status update

fixes #255
parent 3ab3e26a
......@@ -720,13 +720,17 @@ class VmStateChangeForm(forms.Form):
"Forcibly interrupt all running activities."),
help_text=_("Set all activities to finished state, "
"but don't interrupt any tasks."))
new_state = forms.ChoiceField(Instance.STATUS, label=_(
"New status"))
def __init__(self, *args, **kwargs):
show_interrupt = kwargs.pop('show_interrupt')
status = kwargs.pop('status')
super(VmStateChangeForm, self).__init__(*args, **kwargs)
if not show_interrupt:
self.fields['interrupt'].widget = HiddenInput()
self.fields['new_state'].initial = status
def helper(self):
......@@ -946,9 +946,11 @@ class VmStateChangeView(FormOperationMixin, VmOperationView):
def get_form_kwargs(self):
inst = self.get_op().instance
active_activities = InstanceActivity.objects.filter(
finished__isnull=True, instance=inst)
show_interrupt = active_activities.exists()
val = super(VmStateChangeView, self).get_form_kwargs()
val.update({'show_interrupt': show_interrupt})
val.update({'show_interrupt': show_interrupt, 'status': inst.status})
return val
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment