diff --git a/muranodashboard/environments/tables.py b/muranodashboard/environments/tables.py index f7a27b3c9..2fab85313 100644 --- a/muranodashboard/environments/tables.py +++ b/muranodashboard/environments/tables.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse, reverse_lazy from django.utils.translation import ugettext_lazy as _ from django import shortcuts @@ -32,7 +32,6 @@ from consts import DEPLOYMENT_STATUS_DISPLAY_CHOICES class CreateService(tables.LinkAction): name = 'CreateService' verbose_name = _('Create Service') - url = 'horizon:murano:environments:create' classes = ('btn-launch', 'ajax-modal') def allowed(self, request, environment): @@ -249,6 +248,17 @@ class ServicesTable(tables.DataTable): operation_updated = tables.Column('operation_updated', verbose_name=_('Time updated')) + def __init__(self, request, **kwargs): + # we need to update CreateService url here because by default actions + # are instantiated in DataTableMetaclass with no args + for action_id, action in self.base_actions.items(): + if isinstance(action, CreateService): + self.base_actions[action_id] = CreateService( + url=reverse('horizon:murano:environments:create', + args=(kwargs.get('environment_id'),))) + break + super(ServicesTable, self).__init__(request, **kwargs) + def get_object_id(self, datum): return datum.id diff --git a/muranodashboard/environments/urls.py b/muranodashboard/environments/urls.py index cb22494e9..3b1bc2bda 100644 --- a/muranodashboard/environments/urls.py +++ b/muranodashboard/environments/urls.py @@ -37,7 +37,7 @@ urlpatterns = patterns( VIEW_MOD, url(r'^environments$', IndexView.as_view(), name='index'), - url(r'^create/$', + url(ENVIRONMENT_ID + r'/create/$', Wizard.as_view( make_forms_getter(initial_forms=initial_forms_maker), condition_dict=get_service_checkers), diff --git a/muranodashboard/environments/views.py b/muranodashboard/environments/views.py index fb20be78a..2af527163 100644 --- a/muranodashboard/environments/views.py +++ b/muranodashboard/environments/views.py @@ -137,8 +137,10 @@ class Wizard(ModalFormMixin, LazyWizard): def get_context_data(self, form, **kwargs): context = super(Wizard, self).get_context_data(form=form, **kwargs) - context['service_descriptions'] = get_service_descriptions( - self.request) + context.update({ + 'service_descriptions': get_service_descriptions(self.request), + 'environment_id': self.kwargs.get('environment_id') + }) if self.steps.index > 0: data = self.get_cleaned_data_for_step('service_choice') service_type = data['service'] diff --git a/muranodashboard/templates/services/_wizard_create.html b/muranodashboard/templates/services/_wizard_create.html index c8ea6c69f..80eb9740d 100644 --- a/muranodashboard/templates/services/_wizard_create.html +++ b/muranodashboard/templates/services/_wizard_create.html @@ -1,7 +1,7 @@ {% extends "common/_modal_form.html" %} {% load i18n humanize %} {% load url from future %} {# fix for django 1.4.9 on CentOS #} -{% block form_action %}{% url 'horizon:murano:environments:create' %}{% endblock %} +{% block form_action %}{% url 'horizon:murano:environments:create' environment_id %}{% endblock %} {% block form_id %}create_service_form{% endblock %} {% block modal_id %}create_service{% endblock %} {% block modal-header %}{% trans "Create Service" %}{% endblock %}