SG creation user taken straight to edit rules

When the user creates a security group they are taken straight to
manage security group and can select and make changes to rules.

Change-Id: I2b3422e7816fabf59aca87a76f19cba96f01bddc
closes-bug: #1292084
This commit is contained in:
Sam Wright 2018-01-17 15:05:05 +13:00 committed by Akihiro Motoki
parent 07070c437d
commit 90aa4b2b7e
3 changed files with 10 additions and 3 deletions

View File

@ -197,7 +197,11 @@ class ModalFormView(ModalFormMixin, views.HorizonFormView):
elif isinstance(handled, http.HttpResponse):
return handled
else:
success_url = self.get_success_url()
try:
success_url = self.get_success_url_from_handled(handled)
except AttributeError:
success_url = self.get_success_url()
response = http.HttpResponseRedirect(success_url)
if hasattr(handled, 'to_dict'):
obj_dict = handled.to_dict()

View File

@ -263,7 +263,7 @@ class SecurityGroupsViewTests(test.TestCase):
'name': sec_group.name,
'description': sec_group.description}
res = self.client.post(SG_CREATE_URL, form_data)
self.assertRedirectsNoFollow(res, INDEX_URL)
self.assertRedirectsNoFollow(res, self.detail_url)
self.mock_security_group_create.assert_called_once_with(
test.IsHttpRequest(),
sec_group.name,

View File

@ -168,9 +168,12 @@ class CreateView(forms.ModalFormView):
submit_label = _("Create Security Group")
submit_url = reverse_lazy(
"horizon:project:security_groups:create")
success_url = reverse_lazy('horizon:project:security_groups:index')
page_title = _("Create Security Group")
def get_success_url_from_handled(self, handled):
return reverse('horizon:project:security_groups:detail',
args=[handled.id])
class IndexView(tables.DataTableView):
table_class = project_tables.SecurityGroupsTable