Commit Graph

69 Commits

Author SHA1 Message Date
Akihiro Motoki 7052b7f065 Address RemovedInDjango40Warning (7)
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
2022-02-04 16:27:32 +09:00
Akihiro Motoki cd7c1b5110 Address RemovedInDjango40Warning (2)
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
2022-02-04 16:22:07 +09:00
Akihiro Motoki a9d5273f3c Address RemovedInDjango40Warning (1)
force_text() is deprecated in favor of force_str()
smart_text() is deprecated in favor of smart_str()

https://docs.djangoproject.com/en/4.0/releases/3.0/#django-utils-encoding-force-text-and-smart-text

Change-Id: Ic462fa8c3dfa26e8196df19fef5044036a9e97b4
2022-01-31 22:42:41 +09:00
Akihiro Motoki a20c4f6f22 workflow: Do not touch dict during iteration
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
2021-09-22 19:41:55 +09:00
Akihiro Motoki e5d09edc20 Use python3-style super()
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
2020-10-15 14:37:20 +09:00
Akihiro Motoki 692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Akihiro Motoki b67ad564c4 pylint: Address no-else-continue/no-else-raise warnings
Change-Id: I1d44c1bf564cf02908113a42b98e06057e993ec7
2020-09-27 12:44:16 +09:00
Ivan Kolodyazhny e976461d85 Remove six usage from horizon package
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
2020-01-15 12:36:11 +02:00
Zuul c9536342c2 Merge "pylint: fix len-as-condition warning" 2019-01-16 14:25:39 +00:00
Akihiro Motoki 4dd8e3d407 pylint: fix bad-mcs-classmethod-argument warning
Change-Id: Idfa421774ac23f673007fe7a7381c5199ccda5e0
2019-01-16 13:16:55 +09:00
Akihiro Motoki c076db20c8 pylint: fix len-as-condition warning
Change-Id: Ib89c1854ad42b96e4caf281160d568fe98430afe
2019-01-16 12:56:20 +09:00
Akihiro Motoki 59beb951a3 pylint: Fix consider-using-(dict|set)-comprehension
Change-Id: I81c694c17106c179a53326a12e78cfa899872970
2019-01-13 00:59:05 +09:00
tstappae 0796adbd87 Change catch type for workflow unregister
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
2018-06-11 17:17:18 +02:00
Akihiro Motoki e50a69d69f Workflow: Make steps pluggable via horizon plugin config
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
2018-04-13 12:57:46 +00:00
Akihiro Motoki e477eafa45 django2: Replace django.core.urlresolves with django.urls
(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
2018-02-17 01:36:48 +09:00
Akihiro Motoki 0c836454b2 Switch render() arguments to the new way
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
2017-06-21 19:32:03 +00:00
Akihiro Motoki 95d78a140f Switch render() arguments to the new way
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
2017-06-17 16:59:10 +00:00
Akihiro Motoki 95629a337e Fix H405 (multi line docstring) warnings (horizon)
H405: multi line docstring summary not separated with an empty line

Partial-Bug: #1696996
Change-Id: I58f71206def1a25f3eda04b9297f1aa7d3caa646
2017-06-09 16:04:57 +00:00
Akihiro Motoki fd55569ab0 Support allowed() in workflows.Step
There are cases where we want to display workflow Step conditionally.

Change-Id: I71ae3ed270d9472190430ac5b4a34682ce3b3f29
Closes-Bug: #1683262
2017-04-17 08:23:48 +00:00
Akihiro Motoki 61091388e9 hacking: noqa cleanup in horizon
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
2017-03-17 19:38:47 +00:00
Akihiro Motoki 35d2becdd6 Fix docstring warnings
Partial-Bug: #1411719
Partial-Bug: #1486222

Change-Id: I2d649295e7425ab73f09f3a5d91076350bf7ed7a
2016-09-24 20:44:48 +09:00
Diana Whitten 03ede4ce5e Modals should inherit from the theme
* 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
2016-06-21 15:54:00 -07:00
Timur Sufiev 4328c72af1 Enhance policy rules to workflow actions
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
2016-06-08 12:47:40 +03:00
Thomas Goirand 8d1ec57045 [Django 1.9] Stop using django.utils.importlib
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>
2016-01-26 11:19:23 +00:00
Jenkins 43c7b1b98f Merge "py3: Replace basestring with six.string_types" 2015-08-22 06:58:37 +00:00
Victor Stinner c25d76646d py3: use @six.python_2_unicode_compatible
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
2015-08-20 15:50:46 -07:00
Victor Stinner 27e3f6c537 py3: Replace basestring with six.string_types
Patch generated by the command:

  sixer.py basestring horizon/ openstack_dashboard/ tools/

Partial-Implements: blueprint porting-python3
Change-Id: I6fd251243a058457f69907eb1111f559a224e1cb
2015-08-19 17:18:32 -07:00
Akihiro Motoki 5dfca25190 Fix E128 errors in horizon/
E128 continuation line under-indented for visual indent

Partial-Bug: #1375929
Change-Id: If4cc09995a74b68a6b037ea8999cebe09c750e65
2014-10-15 13:50:07 +09:00
Akihiro Motoki c228358258 Fix E127 errors in horizon/
E127 continuation line over-indented for visual indent

Partial-Bug: #1375931
Change-Id: Ib9ae85a767a85a360e5a720d8392a20069a8c873
2014-10-01 19:49:41 +09:00
Bhavanishankar Ravindra 95c7c04528 Fix action_class typo and exception message.
Change-Id: Ib3628c201957c9ece61091c657bda94ef6af4d28
2014-08-19 12:29:25 +05:30
Jenkins f24d6decba Merge "Replace force_unicode with force_text" 2014-08-08 00:18:38 +00:00
Jenkins a282435100 Merge "Rename add_error methods: Django 1.7 conflict" 2014-08-07 12:06:57 +00:00
Thomas Goirand 04dd1568c1 Rename add_error methods: Django 1.7 conflict
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
2014-08-07 14:47:28 +08:00
Felipe Reyes af49cf1f15 Replace force_unicode with force_text
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
2014-08-06 14:34:53 +02:00
Tianpeng Wang b716e52ef3 Fix unexpected return from Step::__init__()
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
2014-08-06 05:57:10 +00:00
Christian Berendt 50b85250c8 Use six.add_metaclass instead of __metaclass__
According to http://docs.openstack.org/developer/hacking/ it should
be preferred to use six.add_metaclass instead of __metaclass__.

Change-Id: Iec6550421bcf54f30952d9dc9f3a398288d6a283
2014-06-03 08:11:49 +02:00
He Yongli e790ac070e Remove extraneous vim configuration comments
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
2014-05-06 15:30:10 +08:00
David Lyle f90f5a33e1 Fix form error access for django 1.6
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
2014-02-12 16:34:42 -07:00
Gabriel Pettier 5df27d687d give a fullscreen attribute to workflow, for modal view
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
2014-01-16 18:29:06 +01:00
Vahid Hashemian fc7bd9e30b Fixes some typos spotted in a few Horizon files.
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
2014-01-13 13:15:00 -08:00
Jenkins 21dbd64376 Merge "Wizard UI for Workflow" 2014-01-09 01:58:57 +00:00
Radomir Dopieralski 028332da4a Remove #noqa from most common imports and add them to import_exceptions
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
2014-01-07 12:26:35 +01:00
Radomir Dopieralski ea47f96a66 Wizard UI for Workflow
This BP implements a wizard UI for modal workflow dialog.

implements bp wizard-ui-for-workflow

Change-Id: Ica1a7e085b016417d285eb6355e70836f68ac170
2014-01-07 11:35:49 +01:00
Matthew Wood 788ec08c4f Bad workflow-steps check: has_required_fields
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
2013-12-12 16:24:31 -07:00
Paul Belanger da8c69afa6 Gate on H4xx docstrings for pep8
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>
2013-11-23 12:51:07 -05:00
Ana Krivokapic 084733b137 Fix "it's vs. its" typos
Change-Id: Ib7914a7c0b6636599526d05bfb8bc2bcf3a79744
Closes-Bug: #1252838
2013-11-19 20:38:21 +01:00
simon afaa72185c PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
2013-09-17 20:48:09 +09:00
Jenkins 4a1bb6a614 Merge "Implement required field indicator" 2013-09-03 17:53:30 +00:00
Rob Raymond dbe4a6792b Implement required field indicator
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
2013-09-03 10:47:02 -06:00
Yangyang Zheng 9f95409249 Define flavor for each project
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
2013-09-01 22:14:23 +10:00