summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShu Muto <shu.mutow@gmail.com>2018-03-14 11:43:12 +0900
committerZhang Hua <joshua.zhang@canonical.com>2019-01-15 13:58:14 +0800
commitc920dc9d42bea38a5ea9d1964161f14a80fe7ae7 (patch)
tree1f0f19c8ba9721640421a4525f69da6bcf4b88b7
parentf557a8dd34e91b60de2f4a192aad3a0861b4b5ac (diff)
downloadhorizon-c920dc9d42bea38a5ea9d1964161f14a80fe7ae7.tar.gz
Fix Angular errors in openstack_auth
Angular errors on login page are caused by loading ngdetails view. Although registration of URL for ngdetails is executed on top level of Horizon, ngdetails view is not needed to be loaded in login page, i.e. openstack_auth side. To fix this issue, this patch moves registration of URL for ngdetails into openstack_dashboard side. Conflicts: openstack_dashboard/test/urls.py openstack_dashboard/urls.py The above conflicts are caused by bp/django2-support which landed in Rocky, particully by https://review.openstack.org/#/c/527323/12. Another problem: ngdetails url doesn't have project prefix after Ocata release, pls see: https://github.com/openstack/horizon/blob/stable/ocata/ \ openstack_dashboard/static/app/core/images/images.service.js#L59 https://github.com/openstack/horizon/blob/stable/pike/ \ openstack_dashboard/static/app/core/images/images.service.js#L69 So the following simple changes need to be made in urls.py in addition to the primitive backport patches. -ngdetails_url = url(r'^ngdetails/', +ngdetails_url = url(r'^project/ngdetails/', Change-Id: Ib039417b4e666c2341f17ac05fd7723bc758816c Closes-Bug: #1754133 Closes-Bug: #1753557 (cherry picked from commit f494c6f2d475bfc936b78fda7ce11ed4d46c7224) (cherry picked from commit 6f6f46dc6d2f38719b114a80edabe2eb01b1ab06) Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
-rw-r--r--horizon/base.py7
-rw-r--r--horizon/test/tests/base.py6
-rw-r--r--openstack_dashboard/test/urls.py5
-rw-r--r--openstack_dashboard/test/views.py23
-rw-r--r--openstack_dashboard/urls.py10
5 files changed, 38 insertions, 13 deletions
diff --git a/horizon/base.py b/horizon/base.py
index 271c287f5..93630e735 100644
--- a/horizon/base.py
+++ b/horizon/base.py
@@ -865,13 +865,6 @@ class Site(Registry, HorizonComponent):
urlpatterns.append(url(r'^%s/' % dash.slug,
include(dash._decorated_urls)))
- # add URL for ngdetails
- views = import_module('horizon.browsers.views')
- urlpatterns.append(url(r'^ngdetails/',
- views.AngularDetailsView.as_view(),
- name='ngdetails'))
- _decorate_urlconf(urlpatterns, require_auth)
-
# Return the three arguments to django.conf.urls.include
return urlpatterns, self.namespace, self.slug
diff --git a/horizon/test/tests/base.py b/horizon/test/tests/base.py
index c330d9744..53869c165 100644
--- a/horizon/test/tests/base.py
+++ b/horizon/test/tests/base.py
@@ -326,12 +326,6 @@ class HorizonTests(BaseHorizonTests):
# Restore settings
settings.SECURE_PROXY_SSL_HEADER = None
- def test_urls_ngdetails(self):
- resp = self.client.get("/ngdetails/")
- self.assertEqual(200, resp.status_code)
- resp = self.client.get("/ngdetails/OS::Glance::Image/xxxxx-xxx")
- self.assertEqual(200, resp.status_code)
-
class GetUserHomeTests(BaseHorizonTests):
"""Test get_user_home parameters."""
diff --git a/openstack_dashboard/test/urls.py b/openstack_dashboard/test/urls.py
index 0aa7c6043..bced344cc 100644
--- a/openstack_dashboard/test/urls.py
+++ b/openstack_dashboard/test/urls.py
@@ -24,6 +24,8 @@ from django.conf.urls import url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # noqa
from django.views import defaults
+from horizon.browsers import views as browsers_views
+
from openstack_dashboard.api import rest
from openstack_dashboard.test.jasmine import jasmine
from openstack_dashboard import views
@@ -36,6 +38,9 @@ urlpatterns = [
url(r'^api/', include(rest.urls)),
url(r'^jasmine/(.*?)$', jasmine.dispatcher),
url(r'', include(horizon.urls)),
+ url(r'^project/ngdetails/',
+ browsers_views.AngularDetailsView.as_view(),
+ name='ngdetails'),
]
# Development static app and project media serving using the staticfiles app.
diff --git a/openstack_dashboard/test/views.py b/openstack_dashboard/test/views.py
new file mode 100644
index 000000000..3523752ed
--- /dev/null
+++ b/openstack_dashboard/test/views.py
@@ -0,0 +1,23 @@
+# 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 openstack_dashboard.test import helpers as test
+
+
+class DashboardViewsTest(test.TestCase):
+
+ def test_urls_ngdetails(self):
+ resp = self.client.get("/project/ngdetails/")
+ self.assertEqual(200, resp.status_code)
+ resp = self.client.get("/project/ngdetails/"
+ "OS::Glance::Image/xxxxx-xxx")
+ self.assertEqual(200, resp.status_code)
diff --git a/openstack_dashboard/urls.py b/openstack_dashboard/urls.py
index 67717c1f5..6369be209 100644
--- a/openstack_dashboard/urls.py
+++ b/openstack_dashboard/urls.py
@@ -28,6 +28,9 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns # noqa
from django.views import defaults
import horizon
+import horizon.base
+from horizon.browsers import views as browsers_views
+from horizon.decorators import require_auth
from openstack_dashboard.api import rest
from openstack_dashboard import views
@@ -38,6 +41,13 @@ urlpatterns = [
url(r'', include(horizon.urls)),
]
+# add URL for ngdetails
+ngdetails_url = url(r'^project/ngdetails/',
+ browsers_views.AngularDetailsView.as_view(),
+ name='ngdetails')
+urlpatterns.append(ngdetails_url)
+horizon.base._decorate_urlconf([ngdetails_url], require_auth)
+
for u in getattr(settings, 'AUTHENTICATION_URLS', ['openstack_auth.urls']):
urlpatterns.append(url(r'^auth/', include(u)))