Refactor to use utils.get_bootstraped_percent
This commit is contained in:
parent
4ea7ca06e8
commit
33d5cd2719
|
@ -6,6 +6,7 @@ from django.utils.html import format_html
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from . import settings as musician_settings
|
from . import settings as musician_settings
|
||||||
|
from .utils import get_bootstraped_percent
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -240,15 +241,16 @@ class MailService(OrchestraModel):
|
||||||
break
|
break
|
||||||
|
|
||||||
mailbox_details = {
|
mailbox_details = {
|
||||||
'usage': resource_disk['used'],
|
'usage': float(resource_disk['used']),
|
||||||
'total': resource_disk['allocated'],
|
'total': resource_disk['allocated'],
|
||||||
'unit': resource_disk['unit'],
|
'unit': resource_disk['unit'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# get percent and round to be 0, 25, 50 or 100
|
percent = get_bootstraped_percent(
|
||||||
# to set progress bar width using CSS classes (e.g. w-25)
|
mailbox_details['used'],
|
||||||
percent = float(resource_disk['used']) / resource_disk['allocated']
|
mailbox_details['total']
|
||||||
mailbox_details['percent'] = round(percent * 4) * 100 // 4
|
)
|
||||||
|
mailbox_details['percent'] = percent
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
mailbox_details = {}
|
mailbox_details = {}
|
||||||
return mailbox_details
|
return mailbox_details
|
||||||
|
|
Loading…
Reference in New Issue