mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 04:42:22 -06:00
Closes #7812: Enable change logging for image attachments
This commit is contained in:
@@ -150,7 +150,7 @@ class ImageAttachmentSerializer(ValidatedModelSerializer):
|
||||
model = ImageAttachment
|
||||
fields = [
|
||||
'id', 'url', 'display', 'content_type', 'object_id', 'parent', 'name', 'image', 'image_height',
|
||||
'image_width', 'created',
|
||||
'image_width', 'created', 'last_updated',
|
||||
]
|
||||
|
||||
def validate(self, data):
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0064_configrevision'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='imageattachment',
|
||||
name='last_updated',
|
||||
field=models.DateTimeField(auto_now=True, null=True),
|
||||
),
|
||||
]
|
||||
@@ -317,7 +317,8 @@ class ExportTemplate(ChangeLoggedModel):
|
||||
return response
|
||||
|
||||
|
||||
class ImageAttachment(BigIDModel):
|
||||
@extras_features('webhooks')
|
||||
class ImageAttachment(ChangeLoggedModel):
|
||||
"""
|
||||
An uploaded image which is associated with an object.
|
||||
"""
|
||||
@@ -341,6 +342,7 @@ class ImageAttachment(BigIDModel):
|
||||
max_length=50,
|
||||
blank=True
|
||||
)
|
||||
# ChangeLoggingMixin.created is a DateField
|
||||
created = models.DateTimeField(
|
||||
auto_now_add=True
|
||||
)
|
||||
@@ -390,6 +392,9 @@ class ImageAttachment(BigIDModel):
|
||||
except tuple(expected_exceptions):
|
||||
return None
|
||||
|
||||
def to_objectchange(self, action):
|
||||
return super().to_objectchange(action, related_object=self.parent)
|
||||
|
||||
|
||||
@extras_features('webhooks')
|
||||
class JournalEntry(ChangeLoggedModel):
|
||||
|
||||
Reference in New Issue
Block a user