mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Clean up ObjectImageAttachmentsView
This commit is contained in:
parent
a1ffb31431
commit
bbf8da2f1c
@ -87,14 +87,7 @@ class ObjectChangeLogView(ConditionalLoginRequiredMixin, View):
|
|||||||
|
|
||||||
class ObjectImageAttachmentsView(ConditionalLoginRequiredMixin, View):
|
class ObjectImageAttachmentsView(ConditionalLoginRequiredMixin, View):
|
||||||
"""
|
"""
|
||||||
Render a list of all Job assigned to an object. For example:
|
Render all images attached to the object as linked thumbnails.
|
||||||
|
|
||||||
path(
|
|
||||||
'data-sources/<int:pk>/jobs/',
|
|
||||||
ObjectJobsView.as_view(),
|
|
||||||
name='datasource_jobs',
|
|
||||||
kwargs={'model': DataSource}
|
|
||||||
)
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
base_template: The name of the template to extend. If not provided, "{app}/{model}.html" will be used.
|
base_template: The name of the template to extend. If not provided, "{app}/{model}.html" will be used.
|
||||||
@ -107,12 +100,8 @@ class ObjectImageAttachmentsView(ConditionalLoginRequiredMixin, View):
|
|||||||
weight=6000
|
weight=6000
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_object(self, request, **kwargs):
|
|
||||||
return get_object_or_404(self.model.objects.restrict(request.user, 'view'), **kwargs)
|
|
||||||
|
|
||||||
def get(self, request, model, **kwargs):
|
def get(self, request, model, **kwargs):
|
||||||
self.model = model
|
obj = get_object_or_404(model.objects.restrict(request.user, 'view'), **kwargs)
|
||||||
obj = self.get_object(request, **kwargs)
|
|
||||||
image_attachments = ImageAttachment.objects.filter(
|
image_attachments = ImageAttachment.objects.filter(
|
||||||
object_type=ContentType.objects.get_for_model(obj),
|
object_type=ContentType.objects.get_for_model(obj),
|
||||||
object_id=obj.pk,
|
object_id=obj.pk,
|
||||||
|
Loading…
Reference in New Issue
Block a user