From f4fe6c96c8e8d6b4f2bb3a54b7ab8b1279e01a1f Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 1 Oct 2021 12:50:51 -0400 Subject: [PATCH] Closes #6708: Add image attachment support for circuits, power panels --- docs/release-notes/version-3.0.md | 1 + netbox/circuits/models.py | 4 ++++ netbox/dcim/models/power.py | 4 ++++ netbox/templates/circuits/circuit.html | 1 + netbox/templates/dcim/powerpanel.html | 3 ++- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 277a37692..5f479b126 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -5,6 +5,7 @@ ### Enhancements * [#6423](https://github.com/netbox-community/netbox/issues/6423) - Cache rendered REST API specifications +* [#6708](https://github.com/netbox-community/netbox/issues/6708) - Add image attachment support for circuits, power panels * [#7387](https://github.com/netbox-community/netbox/issues/7387) - Enable arbitrary ordering of custom scripts ### Bug Fixes diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index 39f38d0b0..bc7dcc219 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -1,3 +1,4 @@ +from django.contrib.contenttypes.fields import GenericRelation from django.core.exceptions import ValidationError from django.db import models from django.urls import reverse @@ -202,6 +203,9 @@ class Circuit(PrimaryModel): comments = models.TextField( blank=True ) + images = GenericRelation( + to='extras.ImageAttachment' + ) # Cache associated CircuitTerminations termination_a = models.ForeignKey( diff --git a/netbox/dcim/models/power.py b/netbox/dcim/models/power.py index f81abd328..0e9520b36 100644 --- a/netbox/dcim/models/power.py +++ b/netbox/dcim/models/power.py @@ -1,3 +1,4 @@ +from django.contrib.contenttypes.fields import GenericRelation from django.core.exceptions import ValidationError from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models @@ -39,6 +40,9 @@ class PowerPanel(PrimaryModel): name = models.CharField( max_length=100 ) + images = GenericRelation( + to='extras.ImageAttachment' + ) objects = RestrictedQuerySet.as_manager() diff --git a/netbox/templates/circuits/circuit.html b/netbox/templates/circuits/circuit.html index e68465c82..b863a8a0e 100644 --- a/netbox/templates/circuits/circuit.html +++ b/netbox/templates/circuits/circuit.html @@ -72,6 +72,7 @@
{% include 'circuits/inc/circuit_termination.html' with termination=object.termination_a side='A' %} {% include 'circuits/inc/circuit_termination.html' with termination=object.termination_z side='Z' %} + {% include 'inc/image_attachments_panel.html' %} {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/powerpanel.html b/netbox/templates/dcim/powerpanel.html index c0bfbcf25..b1367aa1e 100644 --- a/netbox/templates/dcim/powerpanel.html +++ b/netbox/templates/dcim/powerpanel.html @@ -39,11 +39,12 @@ + {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:powerpanel_list' %} {% plugin_left_page object %}
{% include 'inc/custom_fields_panel.html' %} - {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:powerpanel_list' %} + {% include 'inc/image_attachments_panel.html' %} {% plugin_right_page object %}