django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().
https://docs.djangoproject.com/en/4.0/releases/3.0/#id3
Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
Collections Abstract Base Classes have been moved to the
collections.abc module, which was part of the collections
module before[1] [2]. Usage from the collections module
directly is deprecated and will be removed from 3.10.
This commit updates to import abc module explicitly
wherever required as the same will no longer be visible/directly
used from the collections module.
[1] https://docs.python.org/3/library/collections.abc.html
[2] http://paste.openstack.org/show/802512/
Change-Id: I173f4d647474c21c5d062280bd5703edffb4978e
All strings are considered as unicode strings in python 3,
so we no longer need "u" prefix (u'...').
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I796d2fcdca066475bbf29d25cbf2aa67b2b2178b
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.
pylint provides a check for this.
Let's enable 'super-with-arguments' check.
NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.
Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.
Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
Sphinx 3.0.1 complains with:
horizon/horizon/base.py:docstring of horizon.Panel:33:duplicate object
description of horizon.Panel.nav, other instance in contributor/ref/horizon,
use :noindex: for one of them
Fix the two problem.
Change-Id: I98b6212c29dc66cc83a4c337771039796d939561
When user is not logged in and given Dashboard has some `permissions`
defined, `require_perms` decorator was raising `NotAuthorized('You are
not authorized to access %s')` instead of `NotAuthenticated('Please log
in to continue.')`.
This was caused by the order of decorating the views. The decorator
which is applied last is called first in the chain as it wraps the
decorators which were applied before.
This means that to check for authentication before checking permissions
we need to apply the `require_auth` decorator after `require_perms`.
Closes-Bug: 1869708
Change-Id: I94d3fa5c1472bb72c9111cab14c6e05180f88589
Since we don't support Python 2 anymore, we don't need
to use python_2_unicode_compatible decorator.
Change-Id: I2aafc8d07ba95571b381ff65ba9e5c0044e2d959
We have several codes to handle the differences between py2 and py3.
py2 support has been dropped so there is no need for them now.
Change-Id: I30080f4e1a5ac04860c4341d966ee53131eb2022
The get_dashboards() method used sorted(<values>) to sort the
dashboards that have been registered manually. This breaks if
two or more are registered that way because the Dashboard class
doesn't define a natural ordering. The fix is to sort using
the Dashboard name as the sort key. (Unit test included.)
This problem doesn't occur in python 2.7.
P.S.
It turns out that AdminPanel in horizon/test/unit/test_base.py is not
used during the review. It is dropped too as it is a simple change.
Change-Id: I6be10a92a1f43b3e0effee8148987c7e2c5690ff
Closes-bug: #1836295
We don't support Python 2 anymore so we don't need this
compatibility library.
six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.
This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.
Change-Id: I0b567382edf4d68674a7b8d0b02333fb57293958
Resolves the following warning:
DeprecationWarning: Using or importing the ABCs from 'collections'
instead of from 'collections.abc' is deprecated, and in 3.8 it will
stop working
Change-Id: Ib2214e7560cda1ef510c08859d5ee0726eb66b7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
openstack_dashboard/hooks.py:16:0: E0611: No name 'command' in module 'distutils' (no-name-in-module)
openstack_dashboard/dashboards/project/networks/ports/sg_base.py:52:12: E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)
BaseSecurityGroupsAction._get_initial_security_groups() is now marked
as abstract method because this method must be implemented in subclasses.
BaseSecurityGroupsAction.handle() is now dropped because there is
no difference from the parent class (horizon.workflows.Action).
openstack_auth/views.py:211:4: E1206: Not enough arguments for logging format string (logging-too-few-args)
openstack_auth/views.py:269:8: E1206: Not enough arguments for logging format string (logging-too-few-args)
openstack_auth/plugin/base.py:237:20: E1206: Not enough arguments for logging format string (logging-too-few-args)
horizon/base.py:166:24: E1133: Non-iterable value self.policy_rules is used in an iterating context (not-an-iterable)
horizon/tabs/base.py:489:40: E1133: Non-iterable value self.table_classes is used in an iterating context (not-an-iterable)
Change-Id: I0b045d04af251854b5017c9f698e3b40503a0724
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.
Change-Id: Ib039417b4e666c2341f17ac05fd7723bc758816c
Closes-Bug: #1754133
Closes-Bug: #1753557
After Django 2.0 support, we no longer supports Django 1.10 or older
(Actually Django 1.10 seems to work though).
The current django.VERSION branches are all related to Django 1.10
or older, so we can drop all conditions.
py35dj20 job is now voting.
blueprint django2-support
Change-Id: Iefc0ab1c62c82f2842ec7761a9b981da9351cbd2
(In Django 2.0) The django.core.urlresolvers module is removed
in favor of its new location, django.urls.
It was depreacted in Django 1.10:
https://docs.djangoproject.com/en/2.0/releases/1.10/#id3
blueprint django2-support
Change-Id: I46ab5c325491274b8eaffbf848e5d80f83c2fd26
When a user doesn't match the policy rules of a panel then the panel tab
is removed from the menu of the left, but panel views are still
accessible using directly the url (ex /admin/flavors/).
In most of the case, views won't work correctly because of the lack of
right in the backend, but it may cause trouble when you play with
policies.
I think it could be more elegant to return directly a "You are not
authorized to access this page" from the frontend when user try to
access a view of a panel (via url) without matching the policy rules.
Change-Id: I7bc93fed29568adfc14d5bcadfc8728d3b5cf633
Closes-Bug: #1741051
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
As discussed on IRC, reverting temporarily as it breaks sahara-dashboard.
sahara-dashboard requires few changes (moving away from dashboard.Project.register to load the panels) before this can be applied.
This reverts commit fb39de18e4.
Change-Id: I0a77c7ad34c399e4a40cf8b55307be72ff7fe7e0
Panel discovery is done by the _audodiscover() method in
the Dashboard class later
Change-Id: I0261a3cd9ad411185ab68ef4ae3b35a8d7ae3b23
Closes-Bug: #1717149
For now, detailed information about failure on importing panel
module is not shown in warning log. This patch adds information
into warning log why error occured. This clarify the reason the
problem in importing panel/plugins.
Change-Id: Ie3aa725a1bfc81fb7d56a0b195475b8deaa84375
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'.
Furthermore, to specify current navigation and to check access grants
to current panel, each access to Horizon django framework needs its
dashboard and panel objects. It means that we need to specify dashboard
and panel that ngdetails view belongs to.
Also, this patch adds the process and settings to specify dashboard and
panel object for each ngdetails view.
Change-Id: I4bcffd2e222ce2df186551cceba0aa38f600d9c8
Closes-Bug: #1681627
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
This flake8 plugin is already used in tempest.
It enforces loose checking so it sounds good to use.
Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.
Change-Id: I8ccd05eb70350a2441cc2a4d1eafc09ee690b83b
attribute-level imports are not checked by hacking module now.
most noqa is used to disable warnings on attribute-level imports.
This commit drops noqa for this purpose.
After this, there are 8 noqa under horizon/ :)
In addition to this, the following changes are made.
horizon/exceptions.py: The following imports are dropped.
They are not used anywhere.
from django.http import HttpRequest
from django.views.debug import CLEANSED_SUBSTITUTE
horizon/forms/__init__.py:
Some entries were missing in __all__. They are added.
Change-Id: I33b504ef6c396f0675e8a340867e2ca59c77c684
With commit 43e9df85ab the handling
of single policy rules was broken and always returned True for a
single rule.
One of the visible results is that the Admin Dashboard showed up
incorrectly for users that lacked permission to see it. Additionally,
panel in the Admin Dashboard were also visible.
This patch fixes single rule handling, and the visible effects.
Closes-Bug: #1653792
Change-Id: I0c8a0d7b230b6c6b7ee048af84646ca95daee340
We don't want code in our settings.py and local_settings.py, and in
particular we don't want to have to import Python objects from all over
to set them as setting values -- instead, we can specify those as import
path strings. This also solves problems with importing order and loops.
This change is backwards-compatible, in the sense that you can still
import the objects directly and set them as the setting values.
Partially-Implements: blueprint ini-based-configuration
Change-Id: I8a346e55bb98e4e22e0c14a614c45d493d20feb4
Since the content in a Dashboard is not hardcoded, having hardcoded
policy checks to specific services at the dashboard level is wrong.
The Dashboard was designed to evaluate all panels to determine policy
so this type of thing could be avoided. This patch moves the content
specific policy checks to the panels where they apply.
Additionally, this fix uncovered another bug where policy_rules are
wrapped in a list regardless of format. This patch adds a check and
only wraps where necessary.
Change-Id: I79314a45c3c552ebcb3bb7cc881c2467fa009c5d
Closes-Bug: #1643013
Closes-Bug: #1643074
Required modifying our URL pattern decorator to
be compatible with the slightly different callback
attribute mechanism in 1.10
Modified breadcrumb structures to always be 2-tuples
as tuple unpacking is now strictly enforced in 1.10
Also made the following things changed in Django 1.10.
- fixed the now-deprecated TEMPLATE_DEBUG.
- Caught up with Request context change
- SimpleTestCase.urls is removed in 1.10.
ROOT_URLCONF needs to be used instead.
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
Co-Authored-By: Akihiro Motoki <motoki@da.jp.nec.com>
Change-Id: I59cbd8bff117813258539ed0724fe89a9f5b77ee
Implements: blueprint dj110
Django 1.8 altered and deprecated the existing pattern for defining
URLs. This will be removed in 1.10, meaning that many deprecation
warnings show up under Django 1.9. We should fix the URLs promptly to
avoid logspam, and to support Django 1.10 in Newton.
See
https://docs.djangoproject.com/en/1.9/releases/1.8/#django-conf-urls-patterns
Change-Id: I074d20850de59bfe678a3bc72e9f0f25bd743cbf
Partially-Implements: blueprint dj110
Horizon still uses django.utils.importlib which is removed from Django
1.9. We should use:
from importlib import import_module
instead of:
from django.utils.importlib import import_module
Change-Id: I422e14546468cb9c5627e746023948aab107a338
Closes-Bug: #1534522
Partially-Implements: blueprint drop-dj17
Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
These lines of code were introduced as Horizon migrated
through several Django versions and are no longer
needed.
Change-Id: I12aae1a843fccc803859da6337a3274339a3741f
Partially-Implements: blueprint drop-dj17
According to the Horizon documentation for Settings and Configuration,
for a plugin panel, 'If you want the panel to show up without a panel
group, use the panel group “default”'. In some cases, plugin panels were
getting put under the panel group "Other" instead. This is because
the default panel group wasn't getting created during plugin panel
processing when the panel's dashboard class already had some panel
groups defined. Fix this by making sure a default panel group is created
in each dashboard.
Change-Id: I98064c434326aabec16b5d1631e360643609ed40
Closes-Bug: 1403094
From django V1.9 django.utils.datastructures.SortedDict
will be removed and it is deprecated in V1.7.
The similar functionality is added in collections.OrderedDict
from python 2.7.
Horizon code also should avoid the SortedDict class and
start using the OrderedDict class.
This patch replacing the SortedDict with OrderedDict.
Change-Id: I8dfcf7c29fc49b6215451f160cf7a951bf11b5ad
Closes-Bug: #1492270