51 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
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
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
ec970fd6e8 Handle partial dict setting
In Train cycle, we moved the definition of default values
to openstack_dashboard/defaults.py. The current code accesses
a dict member using []. It requires operators to define a dict
setting with a full member.

This commit allows to use dict-type settings with partial members.

A new function is introduced to retrieve a dict-type setting
considering default values defined in
{openstack_dashboard,horizon,openstack_auth}/defaults.py

Change-Id: I7ff0ad4bca698aef9c0eba370b0570200a14367a
Closes-Bug: #1843104
2019-09-26 14:31:17 +09:00
Akihiro Motoki
53486be43f Define default settings explicitly (openstack_dashboard 2/5)
This commit mainly covers settings
in openstack_dashboard/dashboards/admin/.

Part of blueprint ini-based-configuration
Change-Id: Ifb3e9401a926ba9e035e1b498a4a4493c1b594f5
2019-04-24 02:32:47 +09:00
Akihiro Motoki
59beb951a3 pylint: Fix consider-using-(dict|set)-comprehension
Change-Id: I81c694c17106c179a53326a12e78cfa899872970
2019-01-13 00:59:05 +09:00
Akihiro Motoki
11eb4e9d3e Fix W503 warnings
W503 line break before binary operator

Looking at the code base, it sounds okay to follow this check.

Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
2018-04-11 18:13:47 +09: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
365df575ae python3: long does not exist in python 3
In Python 2 there are two integer types 'int' and 'float',
but in Python 3 'int' handles all integers.

blueprint django2-support
Change-Id: Ic9e054a0e5015d60cfc966e70409a3016719ae11
2017-12-12 19:54:26 +09:00
Gábor Antal
34a3aa0ba8 Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
2017-03-31 20:59:16 +09:00
Rob Cresswell
560f23a1c9 Add default common template to python table views
Many of the Python table views are using identical (or nearly identical)
table templates. This patch adds a common template and makes it the
default for a DataTableView, which allows us to remove many similar
templates and redundant lines of code.

Change-Id: I1e4e15e695ee1f21f4d44f141a854e30f1e567a1
Closes-Bug: 1653986
2017-01-05 08:59:35 +00:00
Thai Tran
8c7c33381c Consolidated common angular view
We have views that references angular.html all over the dashboard.
This patch creates a single view for angular views and consolidate others.

Change-Id: I31bd7eb1ce9eac5ec4e13531679b12fc5ebbe60b
2016-11-17 12:07:16 -08:00
Luis Daniel Castellanos
e15b61f58a Update admin filter first setting to a dict
Previously the ADMIN_FILTER_DATA_FIRST setting was a True/False
setting that was taking over all the admin views leaving
operators without the opportunity to set this setting to views
individually.

This patch changes the setting to a dict where it can be specified
which panels/views will implement this setting individually.

Implements blueprint: admin-views-filter-first

Change-Id: I50deab878f68c1cc519aa9b47feaa2c58bb8eacc
2016-09-14 15:52:20 -05:00
Luis Daniel Castellanos
adabe6ec3b Remove admin_filter_first from horizon module to avoid confusion
The admin_filter_first attribute in
'horizon.tables.views.MultiTableMixin' causes confusion since "admin"
is an OpenStack concept. The intention of this attribute is just to
provide a setting that allows views to request for a search criteria
first before loading data, not to merge concepts between 'horizon' and
'openstack_dashboard'. Removing the setting from it's original position
and permorming the check of the setting in each admin view that
whishes to implement admin-filter-first should eliminate this confusion

Change-Id: I77fb0566155e5e5b868cb86c5718ca7048d5d7d4
2016-08-18 15:24:41 -05:00
Matt Borland
20bc6e1516 Make 'switch' between legacy and Angular Images
This patch follows on the example that the Containers set, providing
a 'switch' in the panel-enablement file that currently defaults to
'legacy' (Python-based Images panel) and allows for 'angular' (Angular-
based Images panel).

To be clear, this does NOT enable Angular Images.  It's just setting the
stage to do so at some point, or to allow deployers/devs to easily switch
between the two.

A switch both for HORIZON_CONFIG and for integration tests is necessary
due to the way integration tests operate.

Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Change-Id: I12cd33552218ed1082d2d9a2ae8982639a217a6a
Partially-Implements: blueprint angularize-images-table
2016-08-05 08:17:21 -06:00
Luis Daniel Castellanos
488efd784f Implement admin_filter_first in Instances and Images Admin Views
Implementing ADMIN_FILTER_DATA_FIRST setting will allow operators to
require admin users provide a search criteria first before loading
data into the Admin views.
Starting with Instances and Images admin views since they already have
server side filtering options.

Implements blueprint: admin-views-filter-first

Change-Id: I846690854fd443bb98692674bf9fe6733dd04263
2016-06-23 10:18:11 -05:00
Bo Wang
340e67c17a Add policy checks in images panels
check policy of getting images in:
project/images
project/ngimages
admin/images

Only block listing images but not whole panel if failed on policy check.
Create, Delete and other actions are controlled by according policys.
give a message "Insufficient privilege level to get images." to user
if polciy checks failed.

Closes-Bug: #1529012
Change-Id: I97ab081425dd56fa7c3208efb58ba8b041eaba24
2016-05-16 21:03:37 +08:00
Jenkins
e8fec35f71 Merge "The update image should be changed to edit image" 2016-02-17 10:30:06 +00:00
space
b06d5a5db6 The update image should be changed to edit image
The edit image and the update image is not uniform in the horizon.
Changed the update image to the edit image because there is only
a few places to use the update image.

Change-Id: I6ccca2e9da0d770d92a281cc4cb681c0507469dc
Closes-Bug: #1540755
2016-02-16 15:37:58 +08:00
Timur Sufiev
f8e595b0fa Sort images list in ascending alphabetical order
Move most of the pagination-logic to `api.glance.image_list_detailed`,
thus making code in Admin/Project->Images->get_data() less confusing
(and remove hard-coded 'asc'|'desc' values).

Also prepare to get images both from glanceclient.v1 and
glanceclient.v2 (which doesn't set `is_public` attr on images using
`visibility` attr instead).

Change-Id: Ibe6d3dd1e94a1d1fbf95382599a5f53c3559ce5a
Closes-Bug: #1534670
Closes-Bug: #1336317
2016-01-30 12:00:03 +00:00
Szymon Wroblewski
3c2ce866df Angularize metadata update modals
Update table action to use new angular modal dialog.
Remove "Metadata Update" views.

Implemenents: blueprint angularize-metadata-update-modals
Change-Id: I7b3d2eab8c0830dc44a45901981eb0e71009c038
2015-08-25 13:29:03 +00:00
Victor Stinner
070bde3e21 Replace dict.iteritems() with six.iteritems(dict)
The iteritems() method of Python 2 dictionaries was renamed to items()
on Python 3. The overhead of creating a temporary list for items() on
Python 2 is negligible.

Replace also dict.itervalues() with six.itervalues(dict) in
horizon/test/utils.py.

Partial-Implements: blueprint porting-python3
Change-Id: Ib2d62236be2620c4626099ce80e6c8a9397a4533
2015-07-24 12:20:56 +02:00
jingliuqing
7df40517ff Add project column for admin images tables
Now some panel in admin page has project column for resources,
such as instances, volumes, networks, ... we should add images
project column for admin images tables.

Change-Id: Ic31c19aab080e2ca11b43eb684cde9a578ea421a
Implements: blueprint add-tenant-name-for-admin-image
2015-06-16 15:19:04 +08:00
Justin Pomeroy
12550cb9b9 Add support for Docker image format
The 'Docker' format is added to the default list of supported
formats so it can be selected from the list of formats when creating
or updating an image. When the docker format is selected, the
disk_format and container_format properties are set appropriately.
This also includes changes to the Format column and filter for the
Images table to handle this type.

Closes-Bug: #1455179
Change-Id: Ie705c86d47c0b6035373b9311454748122185988
2015-05-29 11:15:11 -05:00
Jenkins
dc3a5ea101 Merge "Clean modal forms for Images panel" 2015-04-23 11:58:38 +00:00
Rob Cresswell
49e40509eb Fixes inconsistent Edit between tables & details
This patch addresses several instances where clicking Edit on a Detail
page (such as Edit Port on the Port Detail Page) gave either more or
less options than the equivalent action in the Table. This patch fixes
any occurences so that Edit ___ show the same form and fields regardless
of where it is clicked

Closes-bug: 1408346
Change-Id: Ic2599d594b627bd7ab584d1a314360921e41a203
2015-03-23 10:43:47 +00:00
Cindy Lu
2415de13a2 Clean modal forms for Images panel
Refactoring Images modals.
Based on merged patch: https://review.openstack.org/#/c/123472/

Co-Authored-By: Rob Cresswell <rcresswe@cisco.com>
Co-Authored-By: Cindy Lu <clu@us.ibm.com>
Change-Id: I289dd4876e85f0ea1aa9f1d88c4915c897e8ea5b
Partially-Implements: blueprint form-template-to-view
2015-03-12 12:01:16 +00:00
George Peristerakis
b146406d9a Replaced hard coded values with oslo_utils.units constants
Replaced the hard coded values to oslo constants for clarity reasons.

Change-Id: I2bc3240372c518e210ec7d5e7c8b78cd21b94573
2015-02-27 14:49:32 -05:00
Sam Betts
a88c80143b Reduce page title duplication in Admin Images
Patch https://review.openstack.org/#/c/142802 adds a method of
reducing duplication of page title logic, this patch applies that change
to the admin images views.

Change-Id: I53941fadee5338b20ee9c958edc9105757b42b0d
Partial-Bug: 1413749
2015-02-11 16:33:08 +00:00
Akihiro Motoki
393642fd02 Fix E128 errors in openstack_dashboard/dashboards/admin/
E128 continuation line under-indented for visual indent

Partial-Bug: #1375929
Change-Id: I7a258d624f35b602da07c9b8604fb26c63287824
2014-10-15 13:50:07 +09:00
Bartosz Fic
c1171ed16d Images metadata cleanup
Adapt review comments on https://review.openstack.org/#/c/112874/
to admin/images/views.py regarding exception handling.

Change-Id: I31d96f37d1a4184f3df75a7ccb4a870477645307
Closes-Bug: 1370061
Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
2014-09-18 16:18:13 +02:00
Michal Dulko
2e3299dc57 Widget to expose the metadata catalog from glance
In Juno, Glance is providing a metadata definitions catalog[1][2] where
users can register the available metadata definitions that can be used
on different types of resources (images, artifacts, volumes, flavors,
aggregates, etc). This includes both simple tags and key / value pairs
(properties, specs, etc).

This widget will get the metadata definitions from Glance
and will let the user add the metadata to the resource being edited.
It provides value validation as well as description information
about the metadata.

An implementation for Images is included in this patch. Additional
patches will be made for other resource types.

This patch also removes Edit Image Custom Properties screen as new
widget provides the same functionality. To avoid regressions owner
property is added to Image Detail screen.

********************** TESTING **************************
You can test this code with Glance patches by following
the instructions at the bottom of this etherpad:
Go to: https://etherpad.openstack.org/p/j3-glance-patches
*********************************************************

[1] Approved Glance Juno Spec:
https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst

[2] Glance PTL Juno Feature Overview:
https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s

Implements: blueprint tagging
DocImpact

Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com>
Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com>
Co-Authored-By: Travis Tripp <travis.tripp@hp.com>
Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com>

Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
Justin Pomeroy
21d0fb59c3 Add API filtering to paged tables
This adds the ability to filter paged tables (admin instances,
admin images, and project instances) based on supported API
query attributes.

Change-Id: I53cae922e3d349e2f01e8d0d688ddf04d65d84e4
Implements: blueprint table-filtering-by-api-query
2014-08-08 09:17:42 -05:00
Cindy Lu
2428d78a15 add Previous link to Admin > Images table
The Glance API supports a sort direction which we can use to paginate back

The Prev href tag contains a marker id of the first item in the table.
When clicked, a GET API call is made, passing in this marker and the sort_dir='asc'
This will return the previous page's data.  Then we have to re-sort the data because
it is ordered backwards.  We use the default sort_key='created_by' for this.

Once the patch #1252649 is restored, we can add the same behavior to Project > Images.

If we are able to get the consistency across the APIs to include the sort_dir, then we can
bring Prev to the other project tables as well.  There are some blueprints to enhance
API capabilities in this area.

Change-Id: I3e7c6a2db595838dbdff595dc8f0fdda288b6bcf
Partial-Bug: #1263142
Partial-Bug: #1282987
Partially-implements: blueprint pagination-add-prev-link
2014-06-27 18:29:02 -07: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
Jenkins
ca4e457da0 Merge "List all tenant images/snapshots on admin images view" 2014-02-25 12:21:17 +00:00
Leandro I. Costantino
1a596a51d6 List all tenant images/snapshots on admin images view
Admin's Images panel shows only instance snapshots of the project
selected on Projects tab .
Add the appropiate filter is_public: None to the list request.

Change-Id: I4963515d8dbdc89512258c30e3fad309f9720436
Closes-Bug: #1283258
2014-02-24 08:20:55 -03:00
Zhenguo Niu
3d25f1d595 Move volume snapshots table to volumes panel
Now that instance snapshots are just images, the images & snapshots
page only has images and volume snapshots. This is an odd combination.
I think we should now move volume snapshots to the volumes panel,
since a volume snapshot is tied to a volume.

Closes-Bug: #1190843
Change-Id: I3e12cec8b859a30db9f131e9889a92277e064086
2014-02-18 10:24:18 +08: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
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
lawrancejing
d33f294ba9 Remove unused LOG
In some files, we import logging and define
LOG, but we never used it later, so i remove
those unused LOG and make horizon code clean.

Fixed: bug #1231761

Change-Id: I1ebf0098c647e7522f5f1a93cfece7a52bdc05c1
2013-09-28 23:57:13 -07:00
simon
afaa72185c PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
2013-09-17 20:48:09 +09:00
Tatiana Mazur
953d1b9793 Enable H302 check
This patch replaces some method imports with module imports and
makes H302 test enabled.

Fixes bug 1188531

Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
2013-08-22 17:39:09 +04:00
Kieran Spear
242c8df495 Enable H201: do not write "except:"
Fixes all occurrences of this. We have a custom exception handler
in Horizon anyway that only catches ClientException in most of these
cases, but this commit lets us gate on the other cases.

Change-Id: Iea3dc13817f3e5b775b2024424bf3a906da5584b
Closes-Bug: #1211657
2013-08-13 17:21:32 +10:00
Tatiana Mazur
3087c3486b Enable H304 check
This patch replaces relative imports with full paths and
makes H304 test enabled.

Fixes bug 1188535

Change-Id: I47254cf9a790727102f7993d0fd107da514983df
2013-07-16 18:49:56 +04:00
Matthias Runge
cea720e793 Sort imports alphabetically
This patch also re-organizes imports to import one per line.

Change-Id: Ia958e3a30a48d4308d08d51df243c1272425c316
Fixes: bug 1188529
Fixes: bug 1188537
2013-06-14 12:05:55 +02:00
Kieran Spear
c822a9f16e Fix images/snapshots table pagination
For project images, disable pagination entirely as it's not compatible
with client-side filtering (at least without moving to asynch table
loading). This can be revisited when we move to glance v2, which
apparently supports filtering by owner.

For snapshots and admin images, fix pagination by making sure the
iterator returned by glanceclient isn't exhausted completely when
returning a page of images. Do this by slicing just the number of
images we require (+ 1 to check if there will be another page after
this one).

Fixes bug #1083034.

Change-Id: I692f57dec6dca16cf8909f5b234aadb002702fc8
2013-02-20 11:03:33 +11:00
Jenkins
d4f8195aca Merge "Added "create image" capabiltiy to the admin dashboard." 2013-01-29 21:07:41 +00:00
Cody A.W. Somerville
10bc52a235 Added "create image" capabiltiy to the admin dashboard.
Change-Id: I6fdffe9fd96df36b07b04e3f9c8d204ab8fd50b1
Fixes: bug #1088736
2013-01-22 10:53:49 -05:00
Akihiro MOTOKI
12faaa5c30 Ensure to use api.<category>.<method>
In the current code both api.<method> and api.<category>.<method> are used.
Using api.<method> directly makes it difficult to identify which module
defined a method and forces developers to use unique method names among
projects. This commit removes api.<method> style method calls.

Change-Id: Iaefa1061f99b7865e02541df87c112a6b2868ec0
2013-01-22 20:37:12 +09:00