Skip to content

Commit

Permalink
Fix ruff check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mika.busch committed Feb 10, 2025
1 parent a77978e commit 572ce91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netbox/utilities/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def humanize_speed(speed):
else:
return '{} Kbps'.format(speed)


def _humanize_megabytes(mb, divisor=1000):
"""
Express a number of megabytes in the most suitable unit (e.g. gigabytes, terabytes, etc.).
Expand All @@ -104,6 +105,7 @@ def _humanize_megabytes(mb, divisor=1000):
return f"{mb / GB_SIZE:.2f} GB"
return f"{mb} MB"


@register.filter()
def humanize_disk_megabytes(mb):
"""
Expand All @@ -112,6 +114,7 @@ def humanize_disk_megabytes(mb):
"""
return _humanize_megabytes(mb, DISK_BASE_UNIT)


@register.filter()
def humanize_ram_megabytes(mb):
"""
Expand Down
1 change: 1 addition & 0 deletions netbox/virtualization/migrations/0040_convert_disk_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.db.models import F, Sum
from netbox.settings import DISK_BASE_UNIT


def convert_disk_size(apps, schema_editor):
VirtualMachine = apps.get_model('virtualization', 'VirtualMachine')
VirtualMachine.objects.filter(disk__isnull=False).update(disk=F('disk') * DISK_BASE_UNIT)
Expand Down

0 comments on commit 572ce91

Please sign in to comment.