From 6c28884995e387faaa72a8265279a0445356c049 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 28 Mar 2019 17:55:57 +0530 Subject: [PATCH] storage: Do not show an eject button on /boot partitions Signed-off-by: Joseph Nuthalapati Reviewed-by: Sunil Mohan Adapa --- plinth/modules/storage/__init__.py | 18 ++++++++++++++---- plinth/modules/storage/templates/storage.html | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plinth/modules/storage/__init__.py b/plinth/modules/storage/__init__.py index 7f1d90463..5c0248075 100644 --- a/plinth/modules/storage/__init__.py +++ b/plinth/modules/storage/__init__.py @@ -77,7 +77,7 @@ def get_disks(): combined_list.append(disk_from_df) for disk in combined_list: - disk['is_root_device'] = is_root_device(disk) + disk['is_removable'] = is_removable_device(disk) return combined_list @@ -162,16 +162,26 @@ def get_disk_info(mount_point): def get_root_device(disks): """Return the root partition's device from list of partitions.""" for disk in disks: - if is_root_device(disk): + if is_root_partition(disk): return disk['dev_kname'] return None -def is_root_device(disk): - """Return whether a given disk is a root device or not.""" +def is_removable_device(disk): + """Return whether a given disk is a removable device or not.""" + return not (is_root_partition(disk) or is_boot_partition(disk)) + + +def is_root_partition(disk): + """Returns whether this disk is mounted at /.""" return disk['mountpoint'] == '/' and disk['type'] == 'part' +def is_boot_partition(disk): + """Returns whether this disk is mounted at /boot.""" + return disk['mountpoint'] == '/boot' and disk['type'] == 'part' + + def is_expandable(device): """Return the list of partitions that can be expanded.""" if not device: diff --git a/plinth/modules/storage/templates/storage.html b/plinth/modules/storage/templates/storage.html index 1f7e02485..4c8aba13e 100644 --- a/plinth/modules/storage/templates/storage.html +++ b/plinth/modules/storage/templates/storage.html @@ -88,7 +88,7 @@
{{ disk.used_str }} / {{ disk.size_str }}
- {% if not disk.is_root_device %} + {% if disk.is_removable %}
{% csrf_token %}