← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1490031] [NEW] Refactor status and admin state translation code to improve readability

 

Public bug reported:

In some of the dashboard 'views.py' files, there is code that enables
the detail status and, when applicable, admin state labels to be
translated.  The current coding style of these sections is hard to read.
Any and all sections of code that use this style should be refactored to
enhance the code readability.

Example:

Current hard to read code: 
https://github.com/openstack/horizon/blob/943a57b536a40f44053c0161f708a78e22469ed0/openstack_dashboard/dashboards/project/images/images/views.py#L112

Possible refactor:
status_label_dict = {value.lower(): label for (value, label) in project_tables.ImagesTable.STATUS_DISPLAY_CHOICES}
image.status_label = status_label_dict.get(image.status.lower(), image.status)

** Affects: horizon
     Importance: Undecided
     Assignee: Lucas Palm (lapalm)
         Status: New

** Changed in: horizon
     Assignee: (unassigned) => Lucas Palm (lapalm)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1490031

Title:
  Refactor status and admin state translation code to improve
  readability

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  In some of the dashboard 'views.py' files, there is code that enables
  the detail status and, when applicable, admin state labels to be
  translated.  The current coding style of these sections is hard to
  read.  Any and all sections of code that use this style should be
  refactored to enhance the code readability.

  Example:

  Current hard to read code: 
  https://github.com/openstack/horizon/blob/943a57b536a40f44053c0161f708a78e22469ed0/openstack_dashboard/dashboards/project/images/images/views.py#L112

  Possible refactor:
  status_label_dict = {value.lower(): label for (value, label) in project_tables.ImagesTable.STATUS_DISPLAY_CHOICES}
  image.status_label = status_label_dict.get(image.status.lower(), image.status)

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1490031/+subscriptions


Follow ups