예제 #1
0
 def get(self, request, *args, **kw):
     template = cache.get('heat_template_' + request.user.username)
     template_name = cache.get('heat_template_name_' + request.user.username)
     if template is None:
         if 'HTTP_REFERER' in request.META:
             return HttpResponseRedirect(request.META['HTTP_REFERER'])
         else:
             return HttpResponseRedirect(reverse('horizon:thermal:stacks:upload'))
     t = HeatTemplate(template)
     context = {'form': t.form(),
                'template_name': template_name}
     return self.render_to_response(context)
예제 #2
0
    def get(self, request, *args, **kw):
        template = request.session.get('heat_template', None)
        template_name = request.session.get('heat_template_name', None)

        if template is None:
            if 'HTTP_REFERER' in request.META:
                return HttpResponseRedirect(request.META['HTTP_REFERER'])
            else:
                return HttpResponseRedirect(reverse('horizon:thermal:stacks:upload'))
        t = HeatTemplate(template)
        context = {'form': t.form(),
                   'template_name': template_name}
        return self.render_to_response(context)
예제 #3
0
 def post(self, request, *args, **kw):
     template = request.session.get('heat_template', None)
     template_name = request.session.get('heat_template_name', None)
     if template is None:
         if 'HTTP_REFERER' in request.META:
             return HttpResponseRedirect(request.META['HTTP_REFERER'])
         else:
             return HttpResponseRedirect(reverse('horizon:thermal:stacks:upload'))
     t = HeatTemplate(template)
     form = t.form(request.POST)
     if form.is_valid():
         try:
             stack_name = form.cleaned_data.pop('stack_name')
             params = {'stack_name': stack_name,
                       'template': t.json,
                       'parameters': form.cleaned_data,}
             result = api.heat.stacks_create(request, params)
         except Exception, e:
             messages.error(request, e)
             return self.render_to_response({'form': form,
                                             'template_name': template_name})