~ubuntu-branches/ubuntu/utopic/horizon/utopic

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/project/stacks/forms.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-07-25 11:39:09 UTC
  • mfrom: (1.1.42)
  • Revision ID: package-import@ubuntu.com-20140725113909-b8920pdy87itn1ro
Tags: 1:2014.2~b2-0ubuntu1
* New upstream release.
* debian/patches/ubuntu_settings.patch: Refresed
* debian/patches/fix-dashboard-manage.patch: Refreshed
* debian/patches/fix-dashboard-django-wsgi.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from django.utils.translation import ugettext_lazy as _
17
17
from django.views.decorators.debug import sensitive_variables  # noqa
18
18
 
 
19
import six
 
20
 
19
21
from horizon import exceptions
20
22
from horizon import forms
21
23
from horizon import messages
49
51
        help_text = _('From here you can select a template to launch '
50
52
                      'a stack.')
51
53
 
52
 
    choices = [('url', _('URL')),
53
 
               ('file', _('File')),
 
54
    # TODO(jomara) - update URL choice for template & environment files
 
55
    # w/ client side download when applicable
 
56
    base_choices = [('file', _('File')),
54
57
               ('raw', _('Direct Input'))]
 
58
    url_choice = [('url', _('URL'))]
55
59
    attributes = {'class': 'switchable', 'data-slug': 'templatesource'}
56
60
    template_source = forms.ChoiceField(label=_('Template Source'),
57
 
                                        choices=choices,
 
61
                                        choices=base_choices + url_choice,
58
62
                                        widget=forms.Select(attrs=attributes))
59
63
 
60
64
    attributes = create_upload_form_attributes(
90
94
    attributes = {'data-slug': 'envsource', 'class': 'switchable'}
91
95
    environment_source = forms.ChoiceField(
92
96
        label=_('Environment Source'),
93
 
        choices=choices,
 
97
        choices=base_choices,
94
98
        widget=forms.Select(attrs=attributes),
95
99
        required=False)
96
100
 
106
110
 
107
111
    attributes = create_upload_form_attributes(
108
112
        'env',
109
 
        'url',
110
 
        _('Environment URL'))
111
 
    environment_url = forms.URLField(
112
 
        label=_('Environment URL'),
113
 
        help_text=_('An external (HTTP) URL to load the environment from.'),
114
 
        widget=forms.TextInput(attrs=attributes),
115
 
        required=False)
116
 
 
117
 
    attributes = create_upload_form_attributes(
118
 
        'env',
119
113
        'raw',
120
114
        _('Environment Data'))
121
115
    environment_data = forms.CharField(
145
139
        else:
146
140
            kwargs['template_url'] = cleaned['template_url']
147
141
 
 
142
        if cleaned['environment_data']:
 
143
            kwargs['environment'] = cleaned['environment_data']
 
144
 
148
145
        try:
149
146
            validated = api.heat.template_validate(self.request, **kwargs)
150
147
            cleaned['template_validate'] = validated
208
205
    def create_kwargs(self, data):
209
206
        kwargs = {'parameters': data['template_validate'],
210
207
                  'environment_data': data['environment_data'],
211
 
                  'environment_url': data['environment_url'],
212
208
                  'template_data': data['template_data'],
213
209
                  'template_url': data['template_url']}
214
210
        if data.get('stack_id'):
255
251
    environment_data = forms.CharField(
256
252
        widget=forms.widgets.HiddenInput,
257
253
        required=False)
258
 
    environment_url = forms.CharField(
259
 
        widget=forms.widgets.HiddenInput,
260
 
        required=False)
261
254
    parameters = forms.CharField(
262
255
        widget=forms.widgets.HiddenInput,
263
256
        required=True)
336
329
    @sensitive_variables('password')
337
330
    def handle(self, request, data):
338
331
        prefix_length = len(self.param_prefix)
339
 
        params_list = [(k[prefix_length:], v) for (k, v) in data.iteritems()
 
332
        params_list = [(k[prefix_length:], v) for (k, v) in six.iteritems(data)
340
333
                       if k.startswith(self.param_prefix)]
341
334
        fields = {
342
335
            'stack_name': data.get('stack_name'),
353
346
 
354
347
        if data.get('environment_data'):
355
348
            fields['environment'] = data.get('environment_data')
356
 
        elif data.get('environment_url'):
357
 
            fields['environment_url'] = data.get('environment_url')
358
349
 
359
350
        try:
360
351
            api.heat.stack_create(self.request, **fields)
380
371
    @sensitive_variables('password')
381
372
    def handle(self, request, data):
382
373
        prefix_length = len(self.param_prefix)
383
 
        params_list = [(k[prefix_length:], v) for (k, v) in data.iteritems()
 
374
        params_list = [(k[prefix_length:], v) for (k, v) in six.iteritems(data)
384
375
                       if k.startswith(self.param_prefix)]
385
376
 
386
377
        stack_id = data.get('stack_id')