From 8c7c33381cfe3c1191754742b1ba54964761d851 Mon Sep 17 00:00:00 2001 From: Thai Tran Date: Thu, 17 Nov 2016 11:33:13 -0800 Subject: [PATCH] Consolidated common angular view We have views that references angular.html all over the dashboard. This patch creates a single view for angular views and consolidate others. Change-Id: I31bd7eb1ce9eac5ec4e13531679b12fc5ebbe60b --- horizon/browsers/views.py | 5 +++++ .../developer/resource_browser/urls.py | 4 ++-- .../developer/resource_browser/views.py | 19 ---------------- .../dashboards/admin/flavors/urls.py | 8 +++---- .../dashboards/admin/flavors/views.py | 5 ----- .../dashboards/admin/images/urls.py | 6 ++--- .../dashboards/admin/images/views.py | 5 ----- .../dashboards/project/images/images/urls.py | 5 ++--- .../dashboards/project/images/urls.py | 4 ++-- .../dashboards/project/images/views.py | 5 ----- .../dashboards/project/ngdetails/urls.py | 22 ------------------- .../dashboards/project/ngdetails/views.py | 19 ---------------- .../dashboards/project/ngvolumes/urls.py | 5 ++--- .../dashboards/project/ngvolumes/views.py | 19 ---------------- 14 files changed, 20 insertions(+), 111 deletions(-) delete mode 100644 openstack_dashboard/contrib/developer/resource_browser/views.py delete mode 100644 openstack_dashboard/dashboards/project/ngdetails/urls.py delete mode 100644 openstack_dashboard/dashboards/project/ngdetails/views.py delete mode 100644 openstack_dashboard/dashboards/project/ngvolumes/views.py diff --git a/horizon/browsers/views.py b/horizon/browsers/views.py index 351f48338d..75dfe6e325 100644 --- a/horizon/browsers/views.py +++ b/horizon/browsers/views.py @@ -13,6 +13,7 @@ # under the License. from django.utils.translation import ugettext_lazy as _ +from django.views import generic from horizon.tables import MultiTableView # noqa from horizon.utils import memoized @@ -56,3 +57,7 @@ class ResourceBrowserView(MultiTableView): browser = self.get_browser() context["%s_browser" % browser.name] = browser return context + + +class AngularIndexView(generic.TemplateView): + template_name = 'angular.html' diff --git a/openstack_dashboard/contrib/developer/resource_browser/urls.py b/openstack_dashboard/contrib/developer/resource_browser/urls.py index fb396bf241..339174a850 100644 --- a/openstack_dashboard/contrib/developer/resource_browser/urls.py +++ b/openstack_dashboard/contrib/developer/resource_browser/urls.py @@ -13,8 +13,8 @@ # under the License. from django.conf.urls import url -from openstack_dashboard.contrib.developer.resource_browser import views +from horizon.browsers.views import AngularIndexView urlpatterns = [ - url('', views.IndexView.as_view(), name='index'), + url('', AngularIndexView.as_view(), name='index'), ] diff --git a/openstack_dashboard/contrib/developer/resource_browser/views.py b/openstack_dashboard/contrib/developer/resource_browser/views.py deleted file mode 100644 index e072aeab92..0000000000 --- a/openstack_dashboard/contrib/developer/resource_browser/views.py +++ /dev/null @@ -1,19 +0,0 @@ -# (c) Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# 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. - -from django.views import generic - - -class IndexView(generic.TemplateView): - template_name = 'angular.html' diff --git a/openstack_dashboard/dashboards/admin/flavors/urls.py b/openstack_dashboard/dashboards/admin/flavors/urls.py index 6739aa50a2..5d8f8c7812 100644 --- a/openstack_dashboard/dashboards/admin/flavors/urls.py +++ b/openstack_dashboard/dashboards/admin/flavors/urls.py @@ -18,16 +18,16 @@ from django.conf import settings from django.conf.urls import url - +from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.admin.flavors import views if settings.ANGULAR_FEATURES['flavors_panel']: # New angular panel urlpatterns = [ - url(r'^$', views.AngularIndexView.as_view(), name='index'), - url(r'^create/$', views.AngularIndexView.as_view(), name='create'), - url(r'^(?P[^/]+)/update/$', views.AngularIndexView.as_view(), + url(r'^$', AngularIndexView.as_view(), name='index'), + url(r'^create/$', AngularIndexView.as_view(), name='create'), + url(r'^(?P[^/]+)/update/$', AngularIndexView.as_view(), name='index'), ] else: diff --git a/openstack_dashboard/dashboards/admin/flavors/views.py b/openstack_dashboard/dashboards/admin/flavors/views.py index a4322ce307..0bfc44ed5c 100644 --- a/openstack_dashboard/dashboards/admin/flavors/views.py +++ b/openstack_dashboard/dashboards/admin/flavors/views.py @@ -18,7 +18,6 @@ from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ -from django.views import generic from horizon import exceptions from horizon import tables @@ -35,10 +34,6 @@ from openstack_dashboard.dashboards.admin.flavors \ INDEX_URL = "horizon:admin:flavors:index" -class AngularIndexView(generic.TemplateView): - template_name = 'angular.html' - - class IndexView(tables.DataTableView): table_class = project_tables.FlavorsTable template_name = 'admin/flavors/index.html' diff --git a/openstack_dashboard/dashboards/admin/images/urls.py b/openstack_dashboard/dashboards/admin/images/urls.py index 2c187cc764..c8e1238175 100644 --- a/openstack_dashboard/dashboards/admin/images/urls.py +++ b/openstack_dashboard/dashboards/admin/images/urls.py @@ -18,15 +18,15 @@ from django.conf import settings from django.conf.urls import url - +from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.admin.images import views if settings.ANGULAR_FEATURES['images_panel']: # New angular images urlpatterns = [ - url(r'^$', views.AngularIndexView.as_view(), name='index'), + url(r'^$', AngularIndexView.as_view(), name='index'), url(r'^(?P[^/]+)/detail/$', - views.AngularIndexView.as_view(), name='detail'), + AngularIndexView.as_view(), name='detail'), ] else: urlpatterns = [ diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py index b0d2fd4cfa..799f2f7d8a 100644 --- a/openstack_dashboard/dashboards/admin/images/views.py +++ b/openstack_dashboard/dashboards/admin/images/views.py @@ -24,7 +24,6 @@ from django.conf import settings from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ -from django.views import generic from horizon import exceptions from horizon import messages @@ -42,10 +41,6 @@ from openstack_dashboard.dashboards.admin.images \ LOG = logging.getLogger(__name__) -class AngularIndexView(generic.TemplateView): - template_name = 'angular.html' - - class IndexView(tables.DataTableView): DEFAULT_FILTERS = {'is_public': None} table_class = project_tables.AdminImagesTable diff --git a/openstack_dashboard/dashboards/project/images/images/urls.py b/openstack_dashboard/dashboards/project/images/images/urls.py index 3f9bb78b14..6784c4ff5f 100644 --- a/openstack_dashboard/dashboards/project/images/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/images/urls.py @@ -18,14 +18,13 @@ from django.conf import settings from django.conf.urls import url - +from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.project.images.images import views -from openstack_dashboard.dashboards.project.images import views as imgviews if settings.ANGULAR_FEATURES['images_panel']: urlpatterns = [ - url(r'^(?P[^/]+)/$', imgviews.AngularIndexView.as_view(), + url(r'^(?P[^/]+)/$', AngularIndexView.as_view(), name='detail'), ] else: diff --git a/openstack_dashboard/dashboards/project/images/urls.py b/openstack_dashboard/dashboards/project/images/urls.py index 51a4504ec2..01fa9b0186 100644 --- a/openstack_dashboard/dashboards/project/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/urls.py @@ -19,7 +19,7 @@ from django.conf import settings from django.conf.urls import include from django.conf.urls import url - +from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.project.images.images \ import urls as image_urls from openstack_dashboard.dashboards.project.images.snapshots \ @@ -30,7 +30,7 @@ from openstack_dashboard.dashboards.project.images import views if settings.ANGULAR_FEATURES['images_panel']: # New angular images urlpatterns = [ - url(r'^$', views.AngularIndexView.as_view(), name='index'), + url(r'^$', AngularIndexView.as_view(), name='index'), url(r'', include(image_urls, namespace='images')), url(r'', include(snapshot_urls, namespace='snapshots')), ] diff --git a/openstack_dashboard/dashboards/project/images/views.py b/openstack_dashboard/dashboards/project/images/views.py index 7ed07644e6..621f6d9855 100644 --- a/openstack_dashboard/dashboards/project/images/views.py +++ b/openstack_dashboard/dashboards/project/images/views.py @@ -22,7 +22,6 @@ Views for managing Images and Snapshots. """ from django.utils.translation import ugettext_lazy as _ -from django.views import generic from horizon import exceptions from horizon import messages @@ -35,10 +34,6 @@ from openstack_dashboard.dashboards.project.images.images \ import tables as images_tables -class AngularIndexView(generic.TemplateView): - template_name = 'angular.html' - - class IndexView(tables.DataTableView): table_class = images_tables.ImagesTable template_name = 'project/images/index.html' diff --git a/openstack_dashboard/dashboards/project/ngdetails/urls.py b/openstack_dashboard/dashboards/project/ngdetails/urls.py deleted file mode 100644 index 9c9b76034c..0000000000 --- a/openstack_dashboard/dashboards/project/ngdetails/urls.py +++ /dev/null @@ -1,22 +0,0 @@ -# (c) Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# 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. - -from django.conf.urls import url - -from openstack_dashboard.dashboards.project.ngdetails import views - - -urlpatterns = [ - url('', views.IndexView.as_view(), name='index'), -] diff --git a/openstack_dashboard/dashboards/project/ngdetails/views.py b/openstack_dashboard/dashboards/project/ngdetails/views.py deleted file mode 100644 index e072aeab92..0000000000 --- a/openstack_dashboard/dashboards/project/ngdetails/views.py +++ /dev/null @@ -1,19 +0,0 @@ -# (c) Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# 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. - -from django.views import generic - - -class IndexView(generic.TemplateView): - template_name = 'angular.html' diff --git a/openstack_dashboard/dashboards/project/ngvolumes/urls.py b/openstack_dashboard/dashboards/project/ngvolumes/urls.py index 85c92331ac..fb29ed698a 100644 --- a/openstack_dashboard/dashboards/project/ngvolumes/urls.py +++ b/openstack_dashboard/dashboards/project/ngvolumes/urls.py @@ -13,10 +13,9 @@ # under the License. from django.conf.urls import url - -from openstack_dashboard.dashboards.project.ngvolumes import views +from horizon.browsers.views import AngularIndexView urlpatterns = [ - url('', views.IndexView.as_view(), name='index'), + url('', AngularIndexView.as_view(), name='index'), ] diff --git a/openstack_dashboard/dashboards/project/ngvolumes/views.py b/openstack_dashboard/dashboards/project/ngvolumes/views.py deleted file mode 100644 index fd1a327fac..0000000000 --- a/openstack_dashboard/dashboards/project/ngvolumes/views.py +++ /dev/null @@ -1,19 +0,0 @@ -# (c) Copyright 2016 NEC Corporation, L.P. -# -# 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. - -from django.views import generic - - -class IndexView(generic.TemplateView): - template_name = 'angular.html'