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
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
Django 3.2 stored the field information as dict instead OrderedDict
because python 3.7+ ensure the field order of dict as the language spec.
We cannot touch dict itself during iteration. We need to pass a list
instead of a value from .items() itself to avoid the error.
Change-Id: Ie22865995d14fa60c16cf2cea582aa0eec46b65d
Closes-Bug: #1944548
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 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
Since _cls_registry is now a list, removing a non-existing
element throws a ValueError instead of a KeyError.
This did not result in the desired NotRegistered exception.
Change-Id: I2ae7381ce65a0c8fa7deed2c08bfc51e1685f09e
Closes-Bug: 1776187
This commit enhances django workflow implementation to allow horizon
plugins to add workflow steps to a workflow in other repository like
the main horizon repo. New setting "EXTRA_STEPS" is introduced to
the horizon plugin 'enabled' file.
To this aim, the workflow class looks up HORIZON_CONFIG['extra_steps']
with its class full name and loads them as extra steps if any.
HORIZON_CONFIG['extra_steps'] are populated via horizon plugin settings.
This commit completes the blueprint.
blueprint horizon-plugin-tab-for-info-and-quotas
Change-Id: I347d113f47587932e4f583d3152e781ad1a4849f
(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
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 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].
[1] https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/#get-template-and-select-template
Change-Id: I0c180146e499c9e48425c7eb4b73792baa6cdb0c
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
* Fullscreen Modals have been removed
These weren't working properly anyways, and the styling is very
unpleasant: https://i.imgur.com/QfvGli7.png
* Added two more modal sizes: xs and xl, and added all modals sizes
to the theme preview page. Also updated the theme preview page
to use fa-close instead of 'x'.
* Cleaned up Spinner css to use modal sizes properly. Themability
of spinner to come later.
* Confirmation Modal JavaScript was cleaned up, and contents turned
into an easier to digest client side template. Themability of
client side templates show cased in 'material' design.
* 'material' confirmation dialog was altered to show how themes can
make use of overriding client-side templates.
* Moved the Bootstrap helper variables into its own file.
* Added helper variables for various modal calculations.
Change-Id: I599ad2ffcf3034a24a19bc87e6ebed3eab079f45
Policy rules are a more flexible way (than permissions) to determine
what Dashboards/Panels/Table actions are visible for the given
user. But workflow actions (and thus workflow steps) do not use
them. As a consequence, there are situations when according to the
backend service policies (e.g. Neutron) an action represented by a
workflow step is denied for the user (e.g. user is not permitted to
create subnets), yet he sees the corresponding steps in Horizon,
provides and submits the data which leads to an error from Neutron
side. More appropriate behavior here for Horizon would be to not show
to the user the workflow steps he is not able to complete - and if
these steps are required for successfully completing the workflow,
make him unable to start the workflow itself.
Implements: blueprint add-policy-rules-to-workflow-actions
Change-Id: Idededa3dee361e4a42106921a9f332a69c14ae21
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>
Put the @six.python_2_unicode_compatible decorator on classes defining a
__unicode__() method to support Python 3, and rename __unicode__() to
__str__().
Partial-Implements: blueprint porting-python3
Change-Id: I0be33e1a777c98e02140ef9eafaf0c1068a7f408
In Django 1.7, Forms have an add_error() method and our definition
was conflicting with Django's method. Thanks to hertzog@debian.org
for the patch.
Close-bug: #1352919
Change-Id: I1f558cf7f3198a68629738a011e9cae0c3749320
Django changed the name to force_unicode and it's only available in
python2 as an alias of force_text. The new name is available since
Django 1.4.2
Closes-Bug: #1345642
Change-Id: Ida8c545ceec7c31999f2497d540a0dc5a653d286
The __init__() method should always returns None, this patch fix a unexpected
return statement with a TypeError exception, which should be corrected to a
raise statement.
Change-Id: I96d081ab23ac499d6151161d1ae59864c78ea44e
Closes-Bug: 1353270
According to http://docs.openstack.org/developer/hacking/ it should
be preferred to use six.add_metaclass instead of __metaclass__.
Change-Id: Iec6550421bcf54f30952d9dc9f3a398288d6a283
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4
at the top of source code files, except for files in
openstack/common.
Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
In Django 1.6, the _get_errors() method is not available in
django 1.6, while errors is a property on forms that is available.
Partially-implements: blueprint django-1point6
Change-Id: I959fbb50fc33b927251d00ebd70592bb90b92cff
add a fullscreen attribute on Workflow (default to False)
use the fullscreen class in workflow template if True
add .modal.fullscreen rule in horizon.less
add documentation of the fullscreen attribute on Workflow
rework modal system to use a layout context variable, use static_page if
not modal, modal else, and use fullscreen if workflow is fullscreen
add tests for fullscreen logic
implements bp Modals-and-supporting-different-screen-sizes
Change-Id: I8663067ed655d60365857c237732fe4f5cc1e982
It fixes a few typos spotted in comments and debug/exception messages of these Horizon files:
horizon/tables/base.py
horizon/tables/formset.py
horizon/tables/views.py
horizon/utils/functions.py
horizon/workflows/base.py
Change-Id: I7f3069df3f60a6a788f71870f9b49ffe23fdb5a6
Closes-Bug: #1268712
We have a lot of import with #noqa that is there to ignore h302,
because it's traditional to import and use a name directly, instead
of a whole module. This hides other errors and gives people the
impression that it's actually fine to import non-modules, you just
have to slap #noqa on those lines.
I went through the code and identified about a dozen names that are
most commonly imported this way. I remove the #noqa tag from them,
and added them to the list in import_exceptions.
I also removed a few unused imports that were revealed in the process.
Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
Many of the tabs on the Instance Creation screen don't show a "*"
despite having require fields. This is due to faulty logic in determining
whether the workflow-step has require fields. (Previously, only keys from
the contributes list were checked.)
Change-Id: Id609da27c51f8d4725683d7fd1534ead0c3bb984
Closes-Bug: 1252005
In an effort to help horizon more friendly to OpenStack hacking
guidelines, we now gate on H40* violations.
Change-Id: Id07294543660368d2f7f5ac363710176ab23b874
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
Change Horizon's use of forms to set 'required' css class for required fields.
Change template _form_fields.html to include Django field classes in order
to honor above setting.
Also changed horizon workflow to set "required" class on tabs of steps
that contain required fields.
Horizon CSS appends an asterisk after the field label
and tab text based on "required" classname.
The current indicator is based on review with horizon UX
people and can be customized easily.
Change-Id: I03261328d70abcefd13f609088ccb4d58ef30067
Implements: blueprint required-fields
Change CreateFlavor/EditFlavor forms to CreateFlavor/UpdateFlavor
workflows. Provide access flavor management in each project. Add
the filtering function in Flavors page.
Implements blueprint define-flavor-for-project
Change-Id: I723bbf250a46af8de58de06a907f6efc737778db