From 91cc0e836a648eca13ba7cdd79660fc4681de7ca Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Mon, 7 Feb 2022 16:48:55 -0800 Subject: [PATCH] Create a mapping of human-readable and internationalized device names. Use this in the image file management UI instead of the internal acronyms. Also remove the hard-coded helptext for device types. (#655) --- python/web/src/device_utils.py | 30 +++++++++++++++++++++++++++++ python/web/src/templates/index.html | 23 +++++++++++++++------- python/web/src/web.py | 4 +++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/python/web/src/device_utils.py b/python/web/src/device_utils.py index 4dd1356c..cf28883f 100644 --- a/python/web/src/device_utils.py +++ b/python/web/src/device_utils.py @@ -2,6 +2,8 @@ Module for RaSCSI device management utility methods """ +from flask_babel import _ + def get_valid_scsi_ids(devices, reserved_ids): """ @@ -48,3 +50,31 @@ def sort_and_format_devices(devices): formatted_devices.sort(key=lambda dic: str(dic["id"])) return formatted_devices + + +def extend_device_names(device_types): + """ + Takes a (list) of (str) device_types with the four letter device acronyms + Returns a (dict) of device_type:device_name mappings of localized device names + """ + mapped_device_types = [] + for device_type in device_types: + if device_type is "SAHD": + device_name = _("SASI Hard Drive") + elif device_type is "SCHD": + device_name = _("SCSI Hard Drive") + elif device_type is "SCRM": + device_name = _("Removable Drive") + elif device_type is "SCMO": + device_name = _("Magneto-Optical Drive") + elif device_type is "SCCD": + device_name = _("CD-ROM Drive") + elif device_type is "SCBR": + device_name = _("X68000 Host Bridge") + elif device_type is "SCDP": + device_name = _("DaynaPORT SCSI/Link") + else: + device_name = _("Unknown Device") + mapped_device_types.append({device_type: device_name}) + + return mapped_device_types diff --git a/python/web/src/templates/index.html b/python/web/src/templates/index.html index 01c9a1dc..47560eef 100644 --- a/python/web/src/templates/index.html +++ b/python/web/src/templates/index.html @@ -156,7 +156,6 @@
  • {{ _("Select a valid SCSI ID and LUN to attach to. Unless you know what you're doing, always use LUN 0.", url="https://en.wikipedia.org/wiki/Logical_unit_number") }}
  • {{ _("If RaSCSI was unable to detect the device type associated with the image, you can choose the type from the dropdown.") }}
  • -
  • {{ _("Types: SAHD = SASI HDD | SCHD = SCSI HDD | SCRM = Removable | SCMO = Magneto-Optical | SCCD = CD-ROM | SCBR = Host Bridge | SCDP = DaynaPORT") }}
  • @@ -250,7 +249,7 @@ - {% for id in scsi_ids %}