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:
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
|
18
app/itam/migrations/0007_device_inventorydate.py
Normal file
18
app/itam/migrations/0007_device_inventorydate.py
Normal 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'),
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
Reference in New Issue
Block a user