Fixing the AJAX function location

This bug addresses the incorrect location of the AJAX function call in api.py and moves it to the correct location in views.py
It also standardizes the AJAX JSON function to use a generic Django class instead of a function.

Change-Id: I445ca58d1e05187c9d05fdb6814039c69543324c
Fixes: bug #1201980
This commit is contained in:
Tim Schnell 2013-07-18 10:02:07 -05:00
parent ef8ca80344
commit 2c1e47d5c5
3 changed files with 12 additions and 11 deletions

View File

@ -1,8 +1,6 @@
import json
import logging
from django.http import HttpResponse
from openstack_dashboard.api.heat import resources_list
from openstack_dashboard.api.heat import stack_get
@ -77,8 +75,3 @@ def d3_data(request, stack_id=''):
}
d3_data['nodes'].append(resource_node)
return json.dumps(d3_data)
def get_d3_data(request, stack_id=''):
return HttpResponse(d3_data(request, stack_id=stack_id),
content_type="application/json")

View File

@ -15,10 +15,10 @@
from django.conf.urls.defaults import patterns
from django.conf.urls.defaults import url
from openstack_dashboard.dashboards.project.stacks.api import get_d3_data
from openstack_dashboard.dashboards.project.stacks.views import CreateStackView
from openstack_dashboard.dashboards.project.stacks.views import DetailView
from openstack_dashboard.dashboards.project.stacks.views import IndexView
from openstack_dashboard.dashboards.project.stacks.views import JSONView
from openstack_dashboard.dashboards.project.stacks.views import ResourceView
from openstack_dashboard.dashboards.project.stacks.views \
import SelectTemplateView
@ -33,7 +33,6 @@ urlpatterns = patterns(
url(r'^stack/(?P<stack_id>[^/]+)/$', DetailView.as_view(), name='detail'),
url(r'^stack/(?P<stack_id>[^/]+)/(?P<resource_name>[^/]+)/$',
ResourceView.as_view(), name='resource'),
#AJAX urls
url(r'^get_d3_data/(?P<stack_id>[^/]+)/$', get_d3_data, name='d3_data')
url(r'^get_d3_data/(?P<stack_id>[^/]+)/$',
JSONView.as_view(), name='d3_data'),
)

View File

@ -22,10 +22,13 @@ from horizon import tabs
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.stacks.api import d3_data
from openstack_dashboard.dashboards.project.stacks.forms import StackCreateForm
from openstack_dashboard.dashboards.project.stacks.forms import TemplateForm
from openstack_dashboard.dashboards.project.stacks.tables import StacksTable
@ -158,3 +161,9 @@ class ResourceView(tabs.TabView):
metadata = self.get_metadata(request, **kwargs)
return self.tab_group_class(
request, resource=resource, metadata=metadata, **kwargs)
class JSONView(generic.View):
def get(self, request, stack_id=''):
return HttpResponse(d3_data(request, stack_id=stack_id),
content_type="application/json")