storage: Do not show an eject button on /boot partitions

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2019-03-28 17:55:57 +05:30 committed by Sunil Mohan Adapa
parent f7f3b2d8a3
commit 6c28884995
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 15 additions and 5 deletions

View File

@ -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:

View File

@ -88,7 +88,7 @@
<div>{{ disk.used_str }} / {{ disk.size_str }}</div>
</td>
<td>
{% if not disk.is_root_device %}
{% if disk.is_removable %}
<form class="form" method="post"
action="{% url 'storage:eject' disk.dev_kname|urlencode:'' %}">
{% csrf_token %}