diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 76d8c7fbc..fae85e2c1 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -254,6 +254,7 @@ class Site(CreatedUpdatedModel, CustomFieldModel): contact_email = models.EmailField(blank=True, verbose_name="Contact E-mail") comments = models.TextField(blank=True) custom_field_values = GenericRelation(CustomFieldValue, content_type_field='obj_type', object_id_field='obj_id') + images = GenericRelation(ImageAttachment) objects = SiteManager() @@ -933,6 +934,7 @@ class Device(CreatedUpdatedModel, CustomFieldModel): blank=True, null=True, verbose_name='Primary IPv6') comments = models.TextField(blank=True) custom_field_values = GenericRelation(CustomFieldValue, content_type_field='obj_type', object_id_field='obj_id') + images = GenericRelation(ImageAttachment) objects = DeviceManager() diff --git a/netbox/dcim/urls.py b/netbox/dcim/urls.py index 9e35a1d85..7e9f680de 100644 --- a/netbox/dcim/urls.py +++ b/netbox/dcim/urls.py @@ -4,7 +4,7 @@ from ipam.views import ServiceEditView from secrets.views import secret_add from extras.views import ImageAttachmentEditView -from .models import Rack +from .models import Device, Rack, Site from . import views @@ -24,6 +24,7 @@ urlpatterns = [ url(r'^sites/(?P[\w-]+)/$', views.site, name='site'), url(r'^sites/(?P[\w-]+)/edit/$', views.SiteEditView.as_view(), name='site_edit'), url(r'^sites/(?P[\w-]+)/delete/$', views.SiteDeleteView.as_view(), name='site_delete'), + url(r'^sites/(?P\d+)/images/add/$', ImageAttachmentEditView.as_view(), name='site_add_image', kwargs={'model': Site}), # Rack groups url(r'^rack-groups/$', views.RackGroupListView.as_view(), name='rackgroup_list'), @@ -120,6 +121,7 @@ urlpatterns = [ url(r'^devices/(?P\d+)/ip-addresses/assign/$', views.ipaddress_assign, name='ipaddress_assign'), url(r'^devices/(?P\d+)/add-secret/$', secret_add, name='device_addsecret'), url(r'^devices/(?P\d+)/services/assign/$', ServiceEditView.as_view(), name='service_assign'), + url(r'^devices/(?P\d+)/images/add/$', ImageAttachmentEditView.as_view(), name='device_add_image', kwargs={'model': Device}), # Console ports url(r'^devices/console-ports/add/$', views.DeviceBulkAddConsolePortView.as_view(), name='device_bulk_add_consoleport'), diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 2df324a69..4e634d243 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -326,6 +326,20 @@ {% endif %} +
+
+ Images +
+ {% include 'inc/image_attachments.html' with images=device.images.all %} + {% if perms.extras.add_imageattachment %} + + {% endif %} +
Related Devices diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 4ef8277e2..22ae617d3 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -201,42 +201,7 @@
Images
- {% if rack.images.all %} - - - - - - - - {% for attachment in rack.images.all %} - - - - - - - {% endfor %} -
NameSizeCreated
- - {{ attachment }} - {{ attachment.image.size|filesizeformat }}{{ attachment.created }} - {% if perms.extras.change_imageattachment %} - - - - {% endif %} - {% if perms.extras.delete_imageattachment %} - - - - {% endif %} -
- {% else %} -
- None -
- {% endif %} + {% include 'inc/image_attachments.html' with images=rack.images.all %} {% if perms.extras.add_imageattachment %} {% endif %}
+
Topology Maps diff --git a/netbox/templates/inc/image_attachments.html b/netbox/templates/inc/image_attachments.html new file mode 100644 index 000000000..0f922f3c6 --- /dev/null +++ b/netbox/templates/inc/image_attachments.html @@ -0,0 +1,36 @@ +{% if images %} + + + + + + + + {% for attachment in images %} + + + + + + + {% endfor %} +
NameSizeCreated
+ + {{ attachment }} + {{ attachment.image.size|filesizeformat }}{{ attachment.created }} + {% if perms.extras.change_imageattachment %} + + + + {% endif %} + {% if perms.extras.delete_imageattachment %} + + + + {% endif %} +
+{% else %} +
+ None +
+{% endif %}