Commit Graph

111 Commits

Author SHA1 Message Date
Akihiro Motoki d9266fd82c Address RemovedInDjango40Warning (3)
In Django 3.1, django.conf.urls.url() is deprecated
in favor of django.urls.re_path().

https://docs.djangoproject.com/en/4.0/releases/3.1/#id2

Change-Id: I484694f8718f61c022126a1935cf28fce075894b
2022-02-04 16:26:54 +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
David Hill f60220329a Get the timezone offset for the current day instead of January 1st.
This bug only appears to be a cosmetic one where the TZ offset
would be calculated on current_year/01/01 so would remain in
daylight saving offset when displaying the timezones list.

(Note by amotoki)
The minimum version of Babel is bumped to 2.6.0
as Babel 2.3.4 returns "New Zealand Time" instead of "New Zealand
(Auckland) Time" returned from the latest Babel (2.9.0).
It is not a good idea to handle such difference in Babel in our UT
and there is no reason to stick to Bump 2.3.4.
2.6.0 was chosen as it is available in Ubuntu Focal and there is
no more reason than this.

Change-Id: I0600086cc51cf5abcf1631565e75146114189667
Closes-bug: #1822849
2021-03-18 08:29:07 +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 6ba506e281 test: use safer way to override settings
Django provides safer ways to override settings.
We should avoid direct replacement of existing setting.

Change-Id: I1fbcb79d18baaae037536b180989cf69c198fa7d
2020-09-13 09:47:50 +09:00
Zuul 467b218810 Merge "Cleanup for Refactor-error-messages" 2020-09-08 16:32:43 +00:00
manchandavishal be461acd6f Cleanup for Refactor-error-messages
This patch is a clean-up patch for refactor-error-messages bp
which remove the exception message from base message otherwise
the same exception message display twice like
this https://ibb.co/XyFWMdz .

Partially-Implements blueprint refactor-error-messages

Change-Id: I46b632dbb6701785e7d654feff336a27d6ecea9c
2020-09-04 10:39:11 +00:00
Zuul 49df5cffd8 Merge "Avoid stripping leading/traling spaces in password forms" 2020-09-03 16:41:24 +00:00
vmarkov 7f849239ea Support for Keystone password_lock option
This feature was added in Keystone V3 API. Proposed patch adds support
to Horizon

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Closes-bug: #1766485
Change-Id: Ic20a58c76826d703b43fa6a2d77ae5f77dcda1f4
2020-04-10 13:22:53 +03:00
Ivan Kolodyazhny 14e779bbac Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I2de669d8e89b8daeb7ee5405ffab35af6307c40b
2020-03-26 19:45:37 +02:00
Akihiro Motoki 6a07f5a5b4 Avoid stripping leading/traling spaces in password forms
There are cases where leading/trailing spaces are included in passwords
We should not touch passwords input in forms and pass them to auth
backends without any modifications. The detail was discussed in
the mailing list thread [1] referred in the bug comment.

[1] http://lists.openstack.org/pipermail/openstack-discuss/2020-January/thread.html#12223

Change-Id: I98de224cc77a98fa216ec3bc032412325e661e14
Closes-Bug: #1861224
2020-02-05 14:41:49 +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
Akihiro Motoki 7c897b677c Move openstack_dashboard specific settings from horizon
Cookie-based settings related to openstack_dashboard are located
under horizon directory,, but they are not related to "horizon".
This commit moves them to "openstack_dashboard" directory.

Part of blueprint ini-based-configuration
Change-Id: Id48ececdbe819a95485e9a91dc5a1a163a5568c3
2019-09-12 15:05:56 +09:00
Zuul a21c22d3d0 Merge "Define default settings explicitly (openstack_dashboard 5/5)" 2019-07-25 13:05:44 +00:00
Akihiro Motoki 2f1e1899d3 Define default settings explicitly (openstack_dashboard 5/5)
This commit mainly covers settings in the remaining files
under openstack_dashboard.

Note that HORIZON_CONFIG, horizon and openstack_auth are not covered.
They will be covered by follow-up patches.

Part of blueprint ini-based-configuration
Change-Id: Ibd70e030445a073d9a62da9867850f4893135a89
2019-07-08 18:20:32 +09:00
manchandavishal 1ac40ea95f Add exception message when user modify password same as previous
When user change password same as previous password,then user get
an error message "Unable to change password" on Horizon which
does not specify the clear reason why it cannot be change.
This patch corrects the exception raised.

Change-Id: I95acf5c579fd213d64f111010c31fe6c5a0991af
Closes-Bug: #1820102
2019-06-20 13:40:37 +00:00
Radomir Dopieralski 6372a689e2 Don't use check_for_language in the user settings form
That function is buggy and can't handle the Chinese language codes.

Closes-Bug: #1818639
Change-Id: I6ea03949f3ad6db82f5965de3fa028a84edf6cf3
2019-03-06 10:18:20 +01: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 117ec5ddc2 Sync keystone policy
Based on keystone commit cfbc2aa30b7406b4bc77e40a55561d1f46174b5c

keystone uses policy-in-code now, so there is a lot of differences.
The new file was generated by oslopolicy-sample-generator.

Sorted version diff is http://paste.openstack.org/show/628745/.

Removed policies are:
  default
  identity:change_password
  identity:get_identity_providers

'identity:change_password' is used in horizon.
There seems no corresponding new policy, so the corresponding horizon
rules are dropped in this commit.

Our UT depends on the identity policy file.
This commit updates the UTs in a more robust way.

Change-Id: I76eb9f95c7112bcbad75ee151f363f892298d081
2018-01-26 04:01:05 +09:00
Akihiro Motoki 66e868a5b7 Switch settings password tests to mock
Change-Id: I8ee74d4052a2c04d7890942c646fa07f44e724d2
Partially-Implements: blueprint mock-framework-in-unit-tests
2018-01-09 09:38:43 +09:00
Akihiro Motoki 00f74fc06c Revert "Generate language list automatically"
This reverts commit a880926300.

The reverted implementation depends on LOCALE_PATHS but this assumption
turns out not correct. Django searches messages catalogs LOCALE_PATHS
and locale directory in individual INSTALLED_APPS, but the usage of
LOCALE_PATHS varies on deployers and we cannot assume the default value
of LOCALE_PATSH.

In addition, the logic of auto-generating the language list cannot
handle locale name alias ('fallback' in the Django code).
Django 1.9 or later perfers to zh-hant and zh-hans, and zh-cn and
zh-tw are now defined as fallback.

We can explore a better approach for auto-generation of the language
list, but we do not have more reliable way so far. Cconsidering the
timing of Pike release, the safest approach looks like to revert
the original patch back to the manula maintenance of the lang list.

Languages with over 50% progress (based on the number of translated
messages as total) are listed in settings.LANGUAGES.
(http://paste.openstack.org/show/618254/)

Closes-Bug: #1710131
Change-Id: I5133d6317aba6107fc37bd5f30388c130b1fdaac
2017-08-12 22:30:13 +00:00
Akihiro Motoki a880926300 Generate language list automatically
Previously the available language list is maintained manually.
This commit change horizon to check translation message catalog
is available for each language and generate the language list
automatically. settings.LANGUAGES is still used to determines
the initial set of languages and now defaults to the list provided
by django.

Change-Id: I9d9c934beebd7a641e2feb0d5cdfa839e0efa3c3
Closes-Bug: #1675298
2017-03-27 08:47:50 +00:00
Akihiro Motoki baa4ca8dce hacking: noqa cleanup in openstack_dashboard
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 only 3 noqa under openstack_dashboard/ :)

Change-Id: I4a449802f5dbd6e44e4b8b5c378a555d47d9a99f
2017-03-17 19:38:47 +00:00
Jenkins 93904437f4 Merge "The background colour of the success message changed" 2017-03-06 05:01:44 +00:00
liaozd 296d48074d clean unused imports
Change-Id: I9db0bbe3d24fb04e647fcfca1a3a746df006f85c
2017-02-12 17:58:11 +08:00
Sharat Sharma 618d4e1737 The background colour of the success message changed
When the password is successfully changed, the background colour
of the success message is changed from red to green to avoid
users mistaking it for an error message.

Change-Id: Icbaae9f15d02368539e47cd5e929c19ed67b5fed
Closes-Bug: #1520486
2017-01-18 06:53:09 +00:00
Ana Krivokapic 00958cd40d Add generic session/cookie value getters/setters
Change-Id: I116b67da2c8acd05b2ec05791875cad3c6f7bb2d
Closes-Bug: #1329369
2016-11-21 14:13:22 +01:00
Jenkins 19a659cc30 Merge "take time zone into account" 2016-11-18 19:04:42 +00:00
zhurong 316fedfb5b Make sure new password can not the same with old one
change password same with old one will give the error:
Error: Unable to change password.
This patch make sure new password can not the same with old one.

Change-Id: Ib2261df262ba9bdf2b6d2ecb9cf5ce406893634d
Closes-bug: #1641046
2016-11-11 16:08:46 +08:00
liyingjun b8624947f2 UX: Remove duplicated view title under Settings section
Under Setttings -> User Settings OR -> Change Password
There are two title elements with the same content and shown in the same
area, remove one for better ux.

Change-Id: I863363d8fc79f5144d8ead750ba48878a7fa251b
Closes-bug: #1583319
2016-06-15 14:24:26 +08:00
Kenji Ishii 7b43577172 Fix the issue help_text is not translated in User Setting
help message at the field of number of page size is not tranlated.
When we define any form field, it seems that translation does not
work well if help_text has any variable.
This patch will fix it.

Change-Id: I106e00c0fdc073999f879ffa032e11fde7735953
Closes-Bug: #1563021
2016-04-21 07:55:43 +00:00
Jenkins dc8c01c929 Merge "Update URLs to Django 1.8+ style" 2016-04-11 18:10:51 +00:00
Jenkins 56f5ccf63a Merge "Change the super argument to use the current class" 2016-03-30 15:17:15 +00:00
Rob Cresswell 15e83c6448 Update URLs to Django 1.8+ style
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
2016-03-28 11:03:08 +01:00
Matthias Runge 4b1cb06f95 take time zone into account
Previously, settings fell back to UTC
rather than using what was configured in local_settings.

Change-Id: I39113b90364fb53b3a14b2f0ad26637a438fee04
Closes-Bug: #1554522
2016-03-08 14:36:11 +01:00
Kenji Ishii 79c531a1c4 Fix an error which cause on Feb 29 in user setting
In Feb 29(leap year), when users update user settings, error will occur.
Settings expiration is a year later and this calculation is incorrect.
This patch will fix it.

Change-Id: Id2bc6741ad3366969fbb73dc64c23430ce66f2aa
Closes-Bug: #1551099
2016-02-29 14:34:54 -07:00
Lucas Palm 25312e8a46 Add the max value to the tooltip for the "Items per Page" field
Currently, the tooltip for the "Items per Page" field on the User
Settings page does not show the maximum value that the field could be.
Instead, the user must first enter the invalid value, only to receive an
error notification that then shows the max value that the field will
accept.

To resolve this issue, the maximum value is displayed along with the
other help text in the tooltip.  The maximum value has a default value
of 1000 unless set otherwise.

Change-Id: I267cb5ac067f7f0b27224ca8dbba0c8e19199477
Closes-Bug: #1418430
2016-01-14 15:51:30 +00:00
zhu.rong 1546981cc6 Change the super argument to use the current class
Change the super argument to use the current class not use the parent class

Change-Id: Idfa64561cb474bf2d23ac1a3e23e62b173695cd8
2015-11-25 15:41:37 +08:00
Rob Cresswell ef9bc28870 Remove legacy models.py files
There are a number of models.py files lying around. This is legacy (see
https://code.djangoproject.com/ticket/7198). This patch removes those
files.

Closes-Bug: 1516589
Change-Id: I84868107cad3a037079b24403ce1f5a8789de654
2015-11-16 11:41:13 +00:00
Richard Jones 89ce71c4e9 Remove some old (pre-1.8) Django compatibility code
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
2015-11-06 06:55:22 +00:00
Victor Stinner 674a45ffe0 Replace mox with mox3
mox doesn't work on Python 3, whereas mox3 works on Python 2 and Python
3. Cinder, Nova and many other projects already replaced mox with mox3.
mox3 is now maintained by OpenStack.

Partial-Implements: blueprint porting-python3
Change-Id: I10e6a9754ebd58a2640d73ec8966527c3aa1fe9a
2015-07-13 15:02:10 +02:00
Ganesh Narayanan bd3ec44a46 Added more details to items per page help text
"Items per page" value setting is applicable only to those pages 
that have API supported pagination.  For example, if "Items per page"
value is set to say "3" and if we go to Admin > Identity Panel > Users
page, more than "3" items will be displayed if present.  This is
confusing to users.  So as part of this commit, the help text is modified
to reflect this limitation.

Change-Id: Ibbd4771829f0c312134eb275c797780be2b78410
Closes-Bug: 1431364
2015-04-16 03:38:15 +00:00
Rob Cresswell 95fdaedc49 Refactor modal forms for Settings dashboard
Refactor of User settings & Password modals
Based on merged patch: https://review.openstack.org/#/c/123472/

Change-Id: Ibadfda67edc6c8c2c0a9c42c7f0ec982497005ef
Partially-Implements: blueprint form-template-to-view
2015-02-22 13:00:24 +00:00
Jenkins 7d36214474 Merge "Reduce page title duplication in settings and test" 2015-02-17 16:13:28 +00:00
Wu Wenxiang d08868cd31 Remove unused import NoReverseMatch
Remove unused import NoReverseMatch in file:
openstack_dashboard/dashboards/settings/password/tests.py

Change-Id: Iede897000063e8fae0f60c2650e3430c0896d30f
2015-02-14 00:20:49 +08:00
Sam Betts 49f844024a Reduce page title duplication in settings and test
Patch https://review.openstack.org/#/c/142802 adds a method of
reducing duplication of page title logic, this patch applies that change
to the project settings and the test panel views.

Change-Id: I4af59bb3c051dcd24e46aacd91c49b8fcc6c10c7
Partial-Bug: 1413749
2015-02-12 13:07:27 +00:00
Jenkins 924ee8506a Merge "Integration test for showing logout message (password change)" 2015-01-30 20:28:54 +00:00
Jenkins f9d6f965aa Merge "Adds ability to set default log length" 2015-01-10 22:58:17 +00:00
Julie Pichon 11c21626c0 Integration test for showing logout message (password change)
This replaces the unit test that had to be disabled.

Change-Id: I0921bd1164a10d0d33a8f00e522ae47ebdf4887e
Closes-Bug: #1333144
2015-01-06 15:09:43 +00:00