Fix adding linked applications to an Environment

They were broken due to the addition of WofkflowManagementForm at the
wizard's last step.

Also remove unused PostgreSQLField from dynamic_ui.

Change-Id: I44b53ef4edc9fda4723531f75aa2e0c4831908fa
This commit is contained in:
Timur Sufiev 2014-04-24 15:00:47 +04:00
parent 0d2dfaf839
commit 3a48e40933
4 changed files with 14 additions and 53 deletions

View File

@ -21,6 +21,9 @@ from muranodashboard.dynamic_ui import services
VIEW_MOD = 'muranodashboard.catalog.views'
wizard_view = env_views.Wizard.as_view(
services.get_app_forms, condition_dict=services.condition_getter)
urlpatterns = patterns(
VIEW_MOD,
url(r'^index$', views.IndexView.as_view(), name='index'),
@ -31,9 +34,12 @@ urlpatterns = patterns(
'switch',
name='switch_env'),
url(r'^add/(?P<environment_id>[^/]+)/(?P<app_id>[^/]+)$',
env_views.Wizard.as_view(services.get_app_forms,
condition_dict=services.condition_getter),
wizard_view,
name='add'),
url(r'^add/(?P<environment_id>[^/]+)/(?P<app_id>[^/]+)/'
r'(?P<do_redirect>[^/]+)/(?P<drop_wm_form>[^/]+)$',
wizard_view,
name='add_many'),
url(r'^quick-add/(?P<app_id>[^/]+)$',
'quick_deploy',
name='quick_add'),

View File

@ -647,19 +647,11 @@ class DatabaseListField(CharField):
self.validate_mssql_identifier(db_name)
class PostgreSqlChoiceField(ChoiceField):
@with_request
def update(self, request, environment_id, **kwargs):
self.choices = [('', _('(No Database)'))]
psql = api.service_list_by_type(request, environment_id, 'postgreSql')
self.choices.extend([(srv.id, srv.name) for srv in psql])
def make_select_cls(fqn):
class DynamicSelect(hz_forms.DynamicChoiceField, CustomPropertiesField):
def __init__(self, *args, **kwargs):
super(DynamicSelect, self).__init__(*args, **kwargs)
self.widget.add_item_link = 'horizon:murano:catalog:add'
self.widget.add_item_link = 'horizon:murano:catalog:add_many'
@with_request
def update(self, request, environment_id, **kwargs):
@ -667,7 +659,8 @@ def make_select_cls(fqn):
if app_id is None:
msg = "Application with FQN='{0}' doesn't exist"
raise KeyError(msg.format(fqn))
self.widget.add_item_link_args = (environment_id, app_id)
self.widget.add_item_link_args = (
environment_id, app_id, False, True)
self.choices = [('', _('Select Application'))]
apps = api.service_list_by_fqn(request, environment_id, fqn)
self.choices.extend([(app['?']['id'], app.name) for app in apps])

View File

@ -16,10 +16,10 @@ import collections
import logging
import types
import yaql
from django import forms
from django.utils.translation import ugettext_lazy as _
import yaql
import muranodashboard.dynamic_ui.fields as fields
import muranodashboard.dynamic_ui.helpers as helpers
from muranodashboard.dynamic_ui import yaql_expression
@ -49,8 +49,7 @@ TYPES.update({
'image': fields.ImageChoiceField,
'azone': fields.AZoneChoiceField,
'text': (fields.CharField, forms.Textarea),
'floatingip': fields.FloatingIpBooleanField,
'psqlDatabase': fields.PostgreSqlChoiceField
'floatingip': fields.FloatingIpBooleanField
})

View File

@ -1,37 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest2 as unittest
from mock import patch
from muranodashboard.common import utils
from muranodashboard.dynamic_ui.fields import PostgreSqlChoiceField
class CustomFieldsTests(unittest.TestCase):
def test_postgresql_choice_field_values(self):
with patch('muranodashboard.dynamic_ui.fields.api') as mock:
mock.service_list_by_type.return_value = [
utils.Bunch(id='id1', name='examplePostgreSQL')]
field = PostgreSqlChoiceField()
field.update({'environment_id': None}, request='request')
choices = dict(field.choices)
self.assertIn('id1', choices)
self.assertEqual(choices['id1'], 'examplePostgreSQL')