Skip to content

Commit

Permalink
feat(itam): Add status badge property to device model
Browse files Browse the repository at this point in the history
ref: #345 #346
  • Loading branch information
jon-nfc committed Oct 12, 2024
1 parent 4fe4733 commit db7c679
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions app/itam/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from app.helpers.merge_software import merge_software

from core.classes.icon import Icon
from core.mixin.history_save import SaveHistory

from itam.models.device_common import DeviceCommonFields, DeviceCommonFieldsName
Expand Down Expand Up @@ -208,6 +209,23 @@ def __str__(self):

return self.name



@property
def status_icon(self) -> list([Icon]):

icons: list(Icon) = []

icons += [
Icon(
name = f'device_status_{self.status.lower()}',
style = f'icon-device-status-{self.status.lower()}'
)
]

return icons


@property
def status(self) -> str:
""" Fetch Device status
Expand All @@ -226,21 +244,21 @@ def status(self) -> str:

one = (now() - check_date).days

status: str = 'UNK'

if (now() - check_date).days >= 0 and (now() - check_date).days <= 1:

return 'OK'
status = 'OK'

elif (now() - check_date).days >= 2 and (now() - check_date).days < 3:

return 'WARN'
status = 'WARN'

elif (now() - check_date).days >= 3:

return 'BAD'

else:
status = 'BAD'

return 'UNK'
return status


@property
Expand Down

0 comments on commit db7c679

Please sign in to comment.