Skip to content

Commit

Permalink
Fixing the AJAX function location
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tim Schnell committed Jul 19, 2013
1 parent ef8ca80 commit 2c1e47d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 0 additions & 7 deletions openstack_dashboard/dashboards/project/stacks/api.py
@@ -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

Expand Down Expand Up @@ -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")
7 changes: 3 additions & 4 deletions openstack_dashboard/dashboards/project/stacks/urls.py
Expand Up @@ -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
Expand All @@ -33,7 +33,6 @@
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'),
)
9 changes: 9 additions & 0 deletions openstack_dashboard/dashboards/project/stacks/views.py
Expand Up @@ -22,10 +22,13 @@

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
Expand Down Expand Up @@ -158,3 +161,9 @@ def get_tabs(self, request, **kwargs):
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")

0 comments on commit 2c1e47d

Please sign in to comment.