diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 71846c489..c4083eeec 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -11,6 +11,7 @@ * [#7761](https://github.com/netbox-community/netbox/issues/7761) - Extend cable tracing across bridged interfaces * [#7769](https://github.com/netbox-community/netbox/issues/7769) - Enable assignment of IP addresses to an existing FHRP group * [#7775](https://github.com/netbox-community/netbox/issues/7775) - Enable dynamic config for `CHANGELOG_RETENTION`, `CUSTOM_VALIDATORS`, and `GRAPHQL_ENABLED` +* [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments * [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions ### Bug Fixes @@ -22,6 +23,11 @@ * [#7771](https://github.com/netbox-community/netbox/issues/7771) - Group assignment should be optional when creating contacts via REST API * [#7849](https://github.com/netbox-community/netbox/issues/7849) - Fix exception when creating an FHRPGroup with an invalid IP address +### REST API Changes + +* extras.ImageAttachment + * Added the `last_updated` field + --- ## v3.1-beta1 (2021-11-05) diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index 46d295195..89fd00929 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -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): diff --git a/netbox/extras/migrations/0065_imageattachment_change_logging.py b/netbox/extras/migrations/0065_imageattachment_change_logging.py new file mode 100644 index 000000000..dc623e46c --- /dev/null +++ b/netbox/extras/migrations/0065_imageattachment_change_logging.py @@ -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), + ), + ] diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index 7efe3dd97..47da21e19 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -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):