HttpRequest.is_ajax() was marked as deprecated since Django 3.1 and will be
removed in Django 4.0 [1].
While the current implementation of is_ajax() relies on a jQuery-specific way
of signifying AJAX as noted in the Django relnotes, horizon works with this.
Thus this commit copies the existing logic of HttpRequest.is_ajax() to the
horizon repo (as horizon.utils.http.is_ajax()) and consumes it.
https: //docs.djangoproject.com/en/4.0/releases/3.1/#features-deprecated-in-3-1
Change-Id: I3def53033524985818a891a1b9d4659fad4ba2ba
In Django 3.0, django.utils.http.urlquote(), urlquote_plus(),
urlunquote(), and urlunquote_plus() are deprecated in favor of
the functions that they’re aliases for: urllib.parse.quote(),
quote_plus(), unquote(), and unquote_plus().
https: //docs.djangoproject.com/en/4.0/releases/3.0/
Change-Id: I37fcd917cbf87b4d3141cfbdd2675aa38f33f2a4
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
In Django 3.2, assertQuerysetEqual started to compare querystes directly.
As the migration check it checks the first element of the compared items
have a same type. "values()" method of OrderedDict does not return an object
which allows the index access in Python3, so this change breaks our UT.
We need to ensure to pass a list to assertQuerysetEqual.
The commit changes the related codes to ensure a list for such cases.
[1] 3f7b327562
Change-Id: If0a9d17c30de73a9870d0ebf3b3a82a14179c23d
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
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
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
six.reraise can be converted into "raise new_exc from original_exc"
introduced in python3.
In case of horizon.exceptions.handle(), six.reraise was used to
raise the original exception again, so we can convert it into "raise".
six is removed from requirements.txt.
Note that we need to keep six in lower-constraints.txt
as dependent libraries still use six.
Change-Id: I0672a516083727c245f1d4fa5b10eed9cd81a726
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
test_parse_isotime_filter in test_filters is updated to match
TIME_ZONE=UTC. Previously TIME_ZONE was not set in horizon.test.settings
and the default value America/Chicago was used. Horizon uses UTC as the
default value of TIME_ZONE, so it is better to use UTC for testing too.
horizon settings in openstack_dashboard.settings are moved to
under horizon.
Part of blueprint ini-based-configuration
Change-Id: I9abdbbe0dcefc08ffea61143e3c0a87ed87b2e2a
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>
getargspec has been deprecated in py3 with plans to remove it in py3.6.
The recommendation is to move to inspect.signature, but the results of
that call are different than the existing one.
There is also getfullargspec available under py3 that was originally
deprecated, but for the sake of handling 2/3 code, it has been
un-deprecated. This call uses inspect internally, but returns a mostly
compatible result with what getargspec did. This handles getargspec
deprecation by just using getfullargspec instead if it is available
Change-Id: Id0104f7e2b4c43725cb6bcd5e0cd905b19e3133e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change in I8a346e55bb98e4e22e0c14a614c45d493d20feb4 to make
POLICY_CHECK_FUNCTION a string rather than a function was incomplete.
The case in horizon/tables/base.py is problematic in particular and results in
raising the TypeError: 'str' object is not callable error.
There is another instance that is not problematic, but is changed for
consistency sake.
Change-Id: Ifc616e322eb38ec7e5ac218f7f3c5ccec52e40f4
Closes-Bug: #1818292
Multi-process:
If there only one table action, DeleteAction.
Assume the first time retrieving an empty table in one
process, the checkbox is hidden.
In the other process, creating a item, like a instance.
Now, the checkbox is shown in second process.
Then updating the item state in first process, the checkbox
will be hidden. In second process, the checkbox will be shown.
For above case, we need set the checkbox visibility every time
when updating single row by ajax.
Change-Id: Ib230ad775070ee089c8f82e7df3ec30c1cda7aa0
Closes-Bug: #1799151
In case of Cell.status property, the code has a good readability,
so it sounds reasonable to ignore access-member-before-definition,
although access-member-before-definition itself is a useful check.
Change-Id: Ic6f2ec42bac41c62265e6b0e744c256007093ce6
The truncate filter treat an integer as a string and failing.
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: I1a66c3080544e0af8ba02c530351ab4b2d7f9bbd
Closes-Bug: #1504397
We announced in the Rocky cycle that use_mox will be dropped
in the beginning of Stein cycle. This commit drops use_mox and
cleans up mox related stuffs in horizon and openstack_dashboard codes.
Note that openstack_auth is under the mock migration,
so we cannot mox3 from test-requirements.txt.
blueprint mock-framework-in-unit-tests
Change-Id: I189daf2d678bef0fa8219acaab5cf45bbe54178f
The django form field default is "required=True", so this patch
remove the redundant "required=True" in the form.
Change-Id: I3d91ae0638b69d56c1f1b72913ee4995db249007
W503 line break before binary operator
Looking at the code base, it sounds okay to follow this check.
Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
(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
Checkbox in a table assumes BatchAction.
This commit checks whether at least one BatchAction is
included as table actions and displays checkboxes
only when BatchAction is available.
Change-Id: Ia1cba6c59f5d40f7df7f4b98a9f459a6934cfbb7
Closes-Bug: #1744742
At the current moment user can not suspend an
instance from the instance "Details" page if the
instance does not belong to the first page of the
instances list. This is fixed.
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Co-Authored-By: Vladislav Kuzmin <vkuzmin@mirantis.com>
Change-Id: I4d805e4a65e838242af38677cbb9efefc498a96f
Closes-Bug: #1553142
* Clean up unnecessary vertical quotes at the left side
caused by extra spaces at the beginning of lines.
* Do not use backquotes in the title lines
(ref/run_tests.rst, ref/horizon.rst)
When backquotes are used in the first-level title,
it will be included in the navigation at the top-right corner
https://docs.openstack.org/developer/horizon/contributor/ref/index.html
* Remove duplicated contents:: directive in ref/run_tests.sh.
openstackdocstheme generates the toc by default, so having contents::
directive leads to duplicated toc in a page.
Change-Id: Icc641927ad7cd7a8d79632c64a3ce212f0dc0b64
Previously template.render() takes Context or RequestContext object
but after Django 1.8 the method takes a dict and request as separate
arguments. The old way will be dropped in Django 1.10.
This commit update the usage based on the Django 1.8 release notes [1].
commit 95d78a140f addresses this
deprecations but it turns out all similar places are not switched.
I searched the code base more carefully and found more.
I hope this clean up all of them.
After this change, extra_context which was passed to (Request)Context
previously is no longer available in HttpResponse object.
Volume unit test is tightly coupled with the context information
and checks rendered actions using the context. Thus the corresponding
tests no longer work. Since we can use only HttpResponse.content
(which is a rendered HTML), the new tests just check various strings
like ID, link and label of a specific action.
This is tricky, but this is now the only thing we can do.
[1] https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/#get-template-and-select-template
Change-Id: I350c22dc3d7db7b93ca4b823dac1e3d88beef1a7
Previously translated messages are included in log messages
and it was determined what language is chosen by users.
It makes difficult for operators to understand log messgaes.
This commit tries to use English messages for all log messages.
The following policies are applied based on the past discussions
in the bug 1406333 and related reviews.
- English messages are used for log messages.
- log messages include exception messages if possible
to help operators identify what happens.
- Use ID rather than name for log messages
as ID is much more unique compared to name.
- LOG.debug() in success code path are deleted.
We don't log success messages in most places and API calls to
back-end services can be logged from python bindings.
Change-Id: Ie554463908327435d886d0d0f1671fd327c0cd00
Closes-Bug: #1406333
In the API access page, we now see three or four
"Download OpenStack RC" buttons.
This commit packs them into a single menu.
To complete the goal, a new option called "table_actions_menu_label"
is newly introduced to DataTable.
Also the condition to disable an action dropdown menu is changed
so that the action dropdown is not disabled when "multi_select"
feature is not used in a corresponding table.
Otherwise, the dropdown menu is always disabled and there is
no way to enable it in a DataTable with multi_select=False.
Change-Id: I229c69b09c45bb20b3df48c9901d76b89fd27ee4
Closes-Bug: #1680563
Previously DataTable Column checks whether a field exists or not
by checking a result of dict.get(). This has a side effect that
the check complains a field does not exist even when the field
value is None. This commit change the logic to use hasattr to
handle a field with None.
Change-Id: I6ef5ccf90aefd3c407f91a5f3a633d8f68593339
Closes-Bug: #1675912
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
The default bootstrap styling for table rows uses the same classes as
alerts (warning, danger etc). Rather than layering additional logic
around this with a new class, we should just fall back to the documented
boostrap method.
Also resets the warning colour to its default bootstrap variable, rather
than carrying an altered version.
Change-Id: I3472244fcbbd121a8de48d78084554760dab6385
Closes-Bug: 1615632