feat(device): Record inventory date and show as part of details

inventory date is added when an inventory is processed

!8 #2
This commit is contained in:
2024-05-20 20:46:44 +09:30
parent 6b5acc0d57
commit fb041f77eb
4 changed files with 43 additions and 7 deletions

View File

@ -226,13 +226,6 @@ class Collect(views.APIView):
device_software.save()
if not device_software.installed: # Only update install date if blank
device_software.installed = timezone.now()
device_software.save()
if device and operating_system and operating_system_version and device_operating_system:
# Remove software no longer installed
@ -241,6 +234,10 @@ class Collect(views.APIView):
software = software,
).delete()
device.inventorydate = timezone.now()
device.save()
status = Http.Status.OK

View File

@ -1,6 +1,7 @@
from django import forms
from django.db.models import Q
from app import settings
from itam.models.device import Device
@ -17,3 +18,14 @@ class DeviceForm(forms.ModelForm):
'uuid',
'device_type',
]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['_lastinventory'] = forms.DateTimeField(
label="Last Inventory Date",
input_formats=settings.DATETIME_FORMAT,
initial=kwargs['instance'].inventorydate,
disabled=True
)

View File

@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-05-20 09:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('itam', '0006_alter_devicesoftware_options_and_more'),
]
operations = [
migrations.AddField(
model_name='device',
name='inventorydate',
field=models.DateTimeField(blank=True, null=True, verbose_name='Last Inventory Date'),
),
]

View File

@ -76,10 +76,19 @@ class Device(DeviceCommonFieldsName):
)
inventorydate = models.DateTimeField(
verbose_name = 'Last Inventory Date',
null = True,
blank = True
)
def __str__(self):
return self.name
def get_configuration(self, id):
softwares = DeviceSoftware.objects.filter(device=id)