Commit Graph

19 Commits

Author SHA1 Message Date
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
YuehuiLei 87f498bee5 Drop the usage of unicode prefix from unicode strings
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
2021-02-12 13:05:27 -06: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 74df97f57c pylint: Fix unnecessary-comprehension warning
'unnecessary-comprehension' warning is emitted when
unnecessary use of a comprehension is found.

classes attribute in Action can be a tuple,
so we need list() to ensure it is a list before adding 'disabled'.
I think it is time to introduce a method in Action class or somewhere
but it should be handled separately.

Change-Id: I16a98d56b6d0bd0af234b00735c6ed576620df7e
2020-09-27 12:44:16 +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
Ivan Kolodyazhny d870b40583 Remove six usage from openstack_dashboard 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: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Corey Bryant 6f4742457f Switch from django string_concat to format_lazy
string_concat was removed in django 2.1 when it reached the end
of it's deprecation cycle. It was removed because the same behavior
can be achieved with format_lazy.

For more details see:
https://docs.djangoproject.com/en/2.2/releases/2.1/

Change-Id: I5e1c9bdfa1d0e049e0516198abbdb76be1667216
Closes-Bug: #1836671
Partial-Bug: #1789046
2019-07-19 16:50:16 -04:00
pengyuesheng c81af496cf Quote keypair name in keypair panel
Key pair name has multiple spaces and cannot be deleted
under keypair panel.
This patch is quote keypair name.

Change-Id: I7f70032b315579c11059cf71d9c29083b5738854
Closes-Bug: #1824959
2019-06-03 13:16:07 +08:00
Daniel Vincze e332cef01c Add key_type selection on Keypairs form
Key type can be selected through both Django and Angular panels.
This change will allow X509 Public Certificates to be imported
or created through Horizon.

Also, the key type is being showed in the keypairs list.

Change-Id: I0a07b4805e6af96f06ec12d2e86708c94946e9c9
Closes-Bug: 1816041
2019-03-13 16:32:06 +02: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 df0a18e7a3 quota: retrieve quota (limit) and usage at once
Previously tenant_quota_usages() uses list API operations
to count usages. It is not efficient. This commit changes
the limit APIs from nova and cinder to retrieve usages.

blueprint make-quotas-great-again
Change-Id: I2c9a479758a1dfe134e5fabf16ab02831338718d
2017-12-13 20:27:02 +09:00
Feilong Wang 7e4dd6191f Rename "Import Key Pair" to "Import Public Key"
The text "Import Key Pair" is not accurate technically, using "Import
Public Key" to make more sense.

Change-Id: Ifd313c150cb0ee07c86e5f3834aaee43a0fb801b
2017-10-11 16:29:59 +13:00
Mykhailo Dovgal ca0f293cb6 Fix tenant_quota_usages function calls caching
This patch changes type of 'targets' input parameter in
tenant_quota_usages function from list -> tuple. It provides
possibility for @memoized decorator to cache function calls.

Change-Id: I3c32c3b65ae91e8487fda6148f259fe1931d7c9f
Closes-Bug: #1700578
2017-06-26 17:36:07 +03:00
Jenkins f5b2561a09 Merge "Use POST not GET for keypair generation" 2017-06-16 09:00:05 +00:00
Akihiro Motoki 359467b401 Retrieve quota and usage only for resources really required
tenant_quota_usage() is used to retrieve quota and usage
to determine if a resource can be created.
However, tenant_quota_usage retrieves quota and usage for
all resources and it can be a performance problem.

This commit allows to load quota and usage only for resources
which are actually required.

Closes-Bug: #1675504
Change-Id: Iab7322a337a451a1a040cc2f4b55cc319b1ffc4c
2017-06-14 08:53:32 +00:00
Matt Borland d07fedc45f Use POST not GET for keypair generation
This patch fixes the Cross-Site Request Forgery (CSRF) attack against
the keypair generation pages:
- HORIZON_URL/project/key_pairs/PAIRNAME/generate/
- HORIZON_URL/project/key_pairs/PAIRNAME/download/
These pages exposed creating and/or overwriting a keypair with a given
name via a CSRF attack.

This patch closes these holes by using only POST-based keypair creation,
and exposing the keypair in the contents of a modal dialog instead of a
download, which ultimately requires a GET.  It uses the same client-side
features for both the Launch Instance keypair creation and Compute / Key
Pairs panel.

Closes-Bug: 1575913
Change-Id: Ie5ca28ff2bd806eb1481eba6f419b797b68856b6
2017-06-08 11:13:31 -07:00
Vladislav Kuzmin b2d24fedd4 Disable 'Import Key Pair' button if Key Pairs Quota is exceeded
Button "Import key pairs" is active with the same title.
When try to import key pair, it fails with unclear alert
"Failed to import key pair." (no words about quota limit).

Change-Id: I514bda4077326e5ede51b37160c61408b7661c1e
2017-05-29 15:18:09 +04:00
Yaguang Tang c61ae4f083 Update Horizon to use latest nova policy rules for validation
As Nova's API is unified to os_compute_api, the API policies are also
updated to use this format, Horizon needs to use Nova  policy enforce
rules in the codebase. This patch also update nova_policy.json using
oslo-config-generator for Nova policy file.

Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
Implements: blueprint update-nova-enforce-policies

Change-Id: Id7d01a39930c88592301a5035f0befe5293a78fa
2017-03-13 13:43:02 +00:00
Rob Cresswell 1a58a1fd60 Make Key Pairs tab a panel under Compute
As part of the breaking up of Access and Security, move the Key Pairs
tab to a new panel under Compute. Separate patches will address Floating
IPs, Security Groups, and API Access.

Fixes include:
- Should be significantly faster to access Key Pairs, as we are no
longer running multiple API calls for the other Access & Security tabs
at the same time. Hooray for speed!
- Should be easier for new users to find where Key Pairs are located.
- Reduce reuse of identical translatable strings
- Use common templates instead of duplication
- Updated policy rules and added missing rules to table get_data
- Small cleanup of the Key Pair download page, which was previously
using modal classes despite not being a modal.

Change-Id: I66f1f65a2cb49bd10e0364b12efba4346f373ed3
Implements: blueprint reorganise-access-and-security
2017-01-30 12:52:12 +00:00