Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4060,6 +4060,7 @@ class InventoryItemRoleListView(generic.ObjectListView):
@register_model_view(InventoryItemRole)
class InventoryItemRoleView(GetRelatedModelsMixin, generic.ObjectView):
queryset = InventoryItemRole.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.InventoryItemRolePanel(),
Expand Down Expand Up @@ -4308,6 +4309,7 @@ class CableListView(generic.ObjectListView):
@register_model_view(Cable)
class CableView(generic.ObjectView):
queryset = Cable.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.CablePanel(),
Expand Down Expand Up @@ -4458,6 +4460,7 @@ class VirtualChassisListView(generic.ObjectListView):
@register_model_view(VirtualChassis)
class VirtualChassisView(generic.ObjectView):
queryset = VirtualChassis.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.VirtualChassisPanel(),
Expand Down Expand Up @@ -4883,6 +4886,7 @@ class VirtualDeviceContextListView(generic.ObjectListView):
@register_model_view(VirtualDeviceContext)
class VirtualDeviceContextView(GetRelatedModelsMixin, generic.ObjectView):
queryset = VirtualDeviceContext.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.VirtualDeviceContextPanel(),
Expand Down Expand Up @@ -4968,6 +4972,7 @@ class MACAddressListView(generic.ObjectListView):
@register_model_view(MACAddress)
class MACAddressView(generic.ObjectView):
queryset = MACAddress.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.MACAddressPanel(),
Expand Down
14 changes: 14 additions & 0 deletions netbox/extras/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CustomFieldListView(generic.ObjectListView):
@register_model_view(CustomField)
class CustomFieldView(generic.ObjectView):
queryset = CustomField.objects.select_related('choice_set')
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.CustomFieldPanel(),
Expand Down Expand Up @@ -148,6 +149,7 @@ class CustomFieldChoiceSetListView(generic.ObjectListView):
@register_model_view(CustomFieldChoiceSet)
class CustomFieldChoiceSetView(generic.ObjectView):
queryset = CustomFieldChoiceSet.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.CustomFieldChoiceSetPanel(),
Expand Down Expand Up @@ -231,6 +233,7 @@ class CustomLinkListView(generic.ObjectListView):
@register_model_view(CustomLink)
class CustomLinkView(generic.ObjectView):
queryset = CustomLink.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.CustomLinkPanel(),
Expand Down Expand Up @@ -298,6 +301,7 @@ class ExportTemplateListView(generic.ObjectListView):
@register_model_view(ExportTemplate)
class ExportTemplateView(generic.ObjectView):
queryset = ExportTemplate.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ExportTemplatePanel(),
Expand Down Expand Up @@ -372,6 +376,7 @@ class SavedFilterListView(SharedObjectViewMixin, generic.ObjectListView):
@register_model_view(SavedFilter)
class SavedFilterView(SharedObjectViewMixin, generic.ObjectView):
queryset = SavedFilter.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.SavedFilterPanel(),
Expand Down Expand Up @@ -443,6 +448,7 @@ class TableConfigListView(SharedObjectViewMixin, generic.ObjectListView):
@register_model_view(TableConfig)
class TableConfigView(SharedObjectViewMixin, generic.ObjectView):
queryset = TableConfig.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.TableConfigPanel(),
Expand Down Expand Up @@ -545,6 +551,7 @@ class NotificationGroupListView(generic.ObjectListView):
@register_model_view(NotificationGroup)
class NotificationGroupView(generic.ObjectView):
queryset = NotificationGroup.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.NotificationGroupPanel(),
Expand Down Expand Up @@ -738,6 +745,7 @@ class WebhookListView(generic.ObjectListView):
@register_model_view(Webhook)
class WebhookView(generic.ObjectView):
queryset = Webhook.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.WebhookPanel(),
Expand Down Expand Up @@ -807,6 +815,7 @@ class EventRuleListView(generic.ObjectListView):
@register_model_view(EventRule)
class EventRuleView(generic.ObjectView):
queryset = EventRule.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.EventRulePanel(),
Expand Down Expand Up @@ -878,6 +887,7 @@ class TagListView(generic.ObjectListView):
@register_model_view(Tag)
class TagView(generic.ObjectView):
queryset = Tag.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.TagPanel(),
Expand Down Expand Up @@ -969,6 +979,7 @@ class ConfigContextProfileListView(generic.ObjectListView):
@register_model_view(ConfigContextProfile)
class ConfigContextProfileView(generic.ObjectView):
queryset = ConfigContextProfile.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ConfigContextProfilePanel(),
Expand Down Expand Up @@ -1043,6 +1054,7 @@ class ConfigContextListView(generic.ObjectListView):
@register_model_view(ConfigContext)
class ConfigContextView(generic.ObjectView):
queryset = ConfigContext.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ConfigContextPanel(),
Expand Down Expand Up @@ -1172,6 +1184,7 @@ class ConfigTemplateListView(generic.ObjectListView):
@register_model_view(ConfigTemplate)
class ConfigTemplateView(generic.ObjectView):
queryset = ConfigTemplate.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ConfigTemplatePanel(),
Expand Down Expand Up @@ -1302,6 +1315,7 @@ class ImageAttachmentListView(generic.ObjectListView):
@register_model_view(ImageAttachment)
class ImageAttachmentView(generic.ObjectView):
queryset = ImageAttachment.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ImageAttachmentPanel(),
Expand Down
5 changes: 5 additions & 0 deletions netbox/ipam/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class VRFListView(generic.ObjectListView):
@register_model_view(VRF)
class VRFView(GetRelatedModelsMixin, generic.ObjectView):
queryset = VRF.objects.all()
template_name = 'generic/object.html'
layout = layout.Layout(
layout.Row(
layout.Column(
Expand Down Expand Up @@ -172,6 +173,7 @@ class RouteTargetListView(generic.ObjectListView):
@register_model_view(RouteTarget)
class RouteTargetView(generic.ObjectView):
queryset = RouteTarget.objects.all()
template_name = 'generic/object.html'
layout = layout.Layout(
layout.Row(
layout.Column(
Expand Down Expand Up @@ -1332,6 +1334,7 @@ class VLANTranslationPolicyListView(generic.ObjectListView):
@register_model_view(VLANTranslationPolicy)
class VLANTranslationPolicyView(generic.ObjectView):
queryset = VLANTranslationPolicy.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.VLANTranslationPolicyPanel(),
Expand Down Expand Up @@ -1414,6 +1417,7 @@ class VLANTranslationRuleListView(generic.ObjectListView):
@register_model_view(VLANTranslationRule)
class VLANTranslationRuleView(generic.ObjectView):
queryset = VLANTranslationRule.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.VLANTranslationRulePanel(),
Expand Down Expand Up @@ -1753,6 +1757,7 @@ class ServiceTemplateListView(generic.ObjectListView):
@register_model_view(ServiceTemplate)
class ServiceTemplateView(generic.ObjectView):
queryset = ServiceTemplate.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ServiceTemplatePanel(),
Expand Down
30 changes: 5 additions & 25 deletions netbox/netbox/views/generic/feature_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from tenancy.models import ContactAssignment
from tenancy.tables import ContactAssignmentTable
from utilities.permissions import get_permission_for_model
from utilities.views import ConditionalLoginRequiredMixin, GetReturnURLMixin, ViewTab
from utilities.views import ConditionalLoginRequiredMixin, GetReturnURLMixin, ViewTab, get_default_template

from .base import BaseMultiObjectView
from .object_views import ObjectChildrenView
Expand Down Expand Up @@ -72,15 +72,10 @@ def get(self, request, model, **kwargs):
)
objectchanges_table.configure(request)

# Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
# fall back to using base.html.
if self.base_template is None:
self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"

return render(request, 'extras/object_changelog.html', {
'object': obj,
'table': objectchanges_table,
'base_template': self.base_template,
'base_template': self.base_template or get_default_template(model),
'tab': self.tab,
})

Expand All @@ -107,15 +102,10 @@ def get(self, request, model, **kwargs):
object_id=obj.pk,
)

# Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
# fall back to using base.html.
if self.base_template is None:
self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"

return render(request, 'extras/object_imageattachments.html', {
'object': obj,
'image_attachments': image_attachments,
'base_template': self.base_template,
'base_template': self.base_template or get_default_template(model),
'tab': self.tab,
})

Expand Down Expand Up @@ -167,16 +157,11 @@ def get(self, request, model, **kwargs):
else:
form = None

# Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
# fall back to using base.html.
if self.base_template is None:
self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"

return render(request, 'extras/object_journal.html', {
'object': obj,
'form': form,
'table': journalentry_table,
'base_template': self.base_template,
'base_template': self.base_template or get_default_template(model),
'tab': self.tab,
})

Expand Down Expand Up @@ -222,15 +207,10 @@ def get(self, request, model, **kwargs):
jobs_table = JobTable(data=jobs, orderable=False)
jobs_table.configure(request)

# Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
# fall back to using base.html.
if self.base_template is None:
self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"

return render(request, 'core/object_jobs.html', {
'object': obj,
'table': jobs_table,
'base_template': self.base_template,
'base_template': self.base_template or get_default_template(model),
'tab': self.tab,
})

Expand Down
4 changes: 2 additions & 2 deletions netbox/netbox/views/generic/object_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from utilities.querydict import normalize_querydict, prepare_cloned_fields
from utilities.request import safe_for_redirect
from utilities.tables import get_table_configs
from utilities.views import GetReturnURLMixin, get_action_url
from utilities.views import GetReturnURLMixin, get_action_url, get_default_template

from .base import BaseObjectView
from .mixins import ActionsMixin, TableMixin
Expand Down Expand Up @@ -163,7 +163,7 @@ def get(self, request, *args, **kwargs):
'object': instance,
'model': self.child_model,
'child_model': self.child_model,
'base_template': f'{instance._meta.app_label}/{instance._meta.model_name}.html',
'base_template': get_default_template(instance),
'table': table,
'table_config': f'{table.name}_config',
'table_configs': get_table_configs(table, request.user),
Expand Down
1 change: 0 additions & 1 deletion netbox/templates/dcim/cable.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/inventoryitemrole.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/macaddress.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/moduletypeprofile.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/racktype.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/virtualchassis.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/dcim/virtualdevicecontext.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/configcontext.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/configcontextprofile.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/configtemplate.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/customfield.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/customfieldchoiceset.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/customlink.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/eventrule.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/exporttemplate.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/imageattachment.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/notificationgroup.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/savedfilter.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/tableconfig.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/tag.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/extras/webhook.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/ipam/routetarget.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/ipam/servicetemplate.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/ipam/vlantranslationpolicy.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/ipam/vlantranslationrule.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/ipam/vrf.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/tenancy/contact.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/tenancy/contactrole.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/ikepolicy.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/ikeproposal.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/ipsecpolicy.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/ipsecprofile.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/ipsecproposal.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/l2vpn.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/l2vpntermination.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/vpn/tunneltermination.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/wireless/wirelesslan.html

This file was deleted.

1 change: 0 additions & 1 deletion netbox/templates/wireless/wirelesslink.html

This file was deleted.

2 changes: 2 additions & 0 deletions netbox/tenancy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class ContactRoleListView(generic.ObjectListView):
@register_model_view(ContactRole)
class ContactRoleView(GetRelatedModelsMixin, generic.ObjectView):
queryset = ContactRole.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
OrganizationalObjectPanel(),
Expand Down Expand Up @@ -402,6 +403,7 @@ class ContactListView(generic.ObjectListView):
@register_model_view(Contact)
class ContactView(generic.ObjectView):
queryset = Contact.objects.all()
template_name = 'generic/object.html'
layout = layout.SimpleLayout(
left_panels=[
panels.ContactPanel(),
Expand Down
Loading
Loading