diff options
author | Shu Muto <shu-mutou@rf.jp.nec.com> | 2017-11-16 16:55:46 +0900 |
---|---|---|
committer | Zhang Hua <joshua.zhang@canonical.com> | 2019-01-15 11:40:54 +0800 |
commit | f557a8dd34e91b60de2f4a192aad3a0861b4b5ac (patch) | |
tree | 58b8346a78f5d248edc65441d0095d3ec97590ac | |
parent | 2ee37e5ad17204650b99ad981f84dbf2c06ad5d4 (diff) | |
download | horizon-f557a8dd34e91b60de2f4a192aad3a0861b4b5ac.tar.gz |
Enable to refresh ngdetails view
For now, refreshing ngdetails view by browser using F5 key or reload
button, it causes 404 error from django. To fix this issue, this patch
adds the url for '/ngdetails' into django.
To reproduce navigations, each request for views.py requires
'dashboard' and 'panel' object. Otherwise django side returns
500 error.
However the URL for request of details page (i.e. /ngdetails/)
can not provide informations to set the proper navigation.
So this patch set them to default dashboard and default panel.
This patch focuses to prevent 500 error. So the issue for
settings of proper navigation will be fixed by subsequent patch.
Change-Id: Ib9f1fe48b3cdecff5ad56e68a5ba58a41cb35f38
Closes-Bug: #1681627
(cherry picked from commit 077163a03c9aea08efd56251e49d69eb1cc4d093)
(cherry picked from commit a0fc40b4e85d3090e657cca9824de719b33a7ba2)
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
-rw-r--r-- | horizon/base.py | 7 | ||||
-rw-r--r-- | horizon/browsers/views.py | 21 | ||||
-rw-r--r-- | horizon/test/tests/base.py | 6 | ||||
-rw-r--r-- | horizon/test/tests/templates/angular.html | 0 | ||||
-rw-r--r-- | releasenotes/notes/ngdetail-reload-e711a77b2d07191a.yaml | 14 |
5 files changed, 48 insertions, 0 deletions
diff --git a/horizon/base.py b/horizon/base.py index 93630e735..271c287f5 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -865,6 +865,13 @@ 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/browsers/views.py b/horizon/browsers/views.py index 10ef3238d..8701e694d 100644 --- a/horizon/browsers/views.py +++ b/horizon/browsers/views.py @@ -15,6 +15,7 @@ from django.utils.translation import ugettext_lazy as _ from django.views import generic +import horizon from horizon.tables import MultiTableView # noqa from horizon.utils import memoized @@ -83,3 +84,23 @@ class AngularIndexView(generic.TemplateView): else: context["page_title"] = self.page_title return context + + +class AngularDetailsView(generic.TemplateView): + '''View for Angularized details view + + This is used to load ngdetails view via Django. + i.e. refresh or link directly for '^ngdetails/' + ''' + template_name = 'angular.html' + + def get_context_data(self, **kwargs): + context = super(AngularDetailsView, self).get_context_data(**kwargs) + # some parameters are needed for navigation side bar and breadcrumb. + title = _("Horizon") + context["title"] = title + context["page_title"] = title + dashboard = horizon.get_default_dashboard() + self.request.horizon['dashboard'] = dashboard + self.request.horizon['panel'] = dashboard.get_panels()[0] + return context diff --git a/horizon/test/tests/base.py b/horizon/test/tests/base.py index 53869c165..c330d9744 100644 --- a/horizon/test/tests/base.py +++ b/horizon/test/tests/base.py @@ -326,6 +326,12 @@ 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/horizon/test/tests/templates/angular.html b/horizon/test/tests/templates/angular.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/horizon/test/tests/templates/angular.html diff --git a/releasenotes/notes/ngdetail-reload-e711a77b2d07191a.yaml b/releasenotes/notes/ngdetail-reload-e711a77b2d07191a.yaml new file mode 100644 index 000000000..c62ad32a7 --- /dev/null +++ b/releasenotes/notes/ngdetail-reload-e711a77b2d07191a.yaml @@ -0,0 +1,14 @@ +--- +issues: + - | + [:bug:`1746706`] When reloading or opening Angular-based detail page + directly, the navigation menu and breadcrumb list are not recovered + properly and the first panel is focused. + [:bug:`1746709`] when we try to open non-existing Angular-based detail + page, "Not Found" (404) page is not shown. A blank page only with + the navigation menu will be shown. +fixes: + - | + [:bug:`1681627`] A problem that Angular-based detail page (ngdetail page) + cannot be reloaded or opened via direct URL has been fixed. Note that + there are some known issues described in the `Known Issues`_ section. |