mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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:
parent
f7f3b2d8a3
commit
6c28884995
@ -77,7 +77,7 @@ def get_disks():
|
|||||||
combined_list.append(disk_from_df)
|
combined_list.append(disk_from_df)
|
||||||
|
|
||||||
for disk in combined_list:
|
for disk in combined_list:
|
||||||
disk['is_root_device'] = is_root_device(disk)
|
disk['is_removable'] = is_removable_device(disk)
|
||||||
|
|
||||||
return combined_list
|
return combined_list
|
||||||
|
|
||||||
@ -162,16 +162,26 @@ def get_disk_info(mount_point):
|
|||||||
def get_root_device(disks):
|
def get_root_device(disks):
|
||||||
"""Return the root partition's device from list of partitions."""
|
"""Return the root partition's device from list of partitions."""
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
if is_root_device(disk):
|
if is_root_partition(disk):
|
||||||
return disk['dev_kname']
|
return disk['dev_kname']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def is_root_device(disk):
|
def is_removable_device(disk):
|
||||||
"""Return whether a given disk is a root device or not."""
|
"""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'
|
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):
|
def is_expandable(device):
|
||||||
"""Return the list of partitions that can be expanded."""
|
"""Return the list of partitions that can be expanded."""
|
||||||
if not device:
|
if not device:
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
<div>{{ disk.used_str }} / {{ disk.size_str }}</div>
|
<div>{{ disk.used_str }} / {{ disk.size_str }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not disk.is_root_device %}
|
{% if disk.is_removable %}
|
||||||
<form class="form" method="post"
|
<form class="form" method="post"
|
||||||
action="{% url 'storage:eject' disk.dev_kname|urlencode:'' %}">
|
action="{% url 'storage:eject' disk.dev_kname|urlencode:'' %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user