Просмотр исходного кода

Fixes #12103: Limit the types of objects available for object count & list widgets

jeremystretch 2 лет назад
Родитель
Сommit
8d6c591535
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 0
      docs/release-notes/version-3.5.md
  2. 4 1
      netbox/extras/dashboard/widgets.py

+ 1 - 0
docs/release-notes/version-3.5.md

@@ -70,6 +70,7 @@ Two new webhook trigger events have been introduced: `job_start` and `job_end`.
 
 
 ### Bug Fixes (From Beta1)
 ### Bug Fixes (From Beta1)
 
 
+* [#12103](https://github.com/netbox-community/netbox/issues/12103) - Limit the types of objects available for object count & list widgets
 * [#12105](https://github.com/netbox-community/netbox/issues/12105) - Prevent data sources from becoming stuck in "syncing" status when an exception is raised
 * [#12105](https://github.com/netbox-community/netbox/issues/12105) - Prevent data sources from becoming stuck in "syncing" status when an exception is raised
 * [#12106](https://github.com/netbox-community/netbox/issues/12106) - Fix exception when saving dashboard widget with minimum width/height
 * [#12106](https://github.com/netbox-community/netbox/issues/12106) - Fix exception when saving dashboard widget with minimum width/height
 * [#12108](https://github.com/netbox-community/netbox/issues/12108) - Limit the draggable area of widgets to their headers
 * [#12108](https://github.com/netbox-community/netbox/issues/12108) - Limit the draggable area of widgets to their headers

+ 4 - 1
netbox/extras/dashboard/widgets.py

@@ -11,6 +11,7 @@ from django.template.loader import render_to_string
 from django.urls import NoReverseMatch, reverse
 from django.urls import NoReverseMatch, reverse
 from django.utils.translation import gettext as _
 from django.utils.translation import gettext as _
 
 
+from extras.utils import FeatureQuery
 from utilities.forms import BootstrapMixin
 from utilities.forms import BootstrapMixin
 from utilities.permissions import get_permission_for_model
 from utilities.permissions import get_permission_for_model
 from utilities.templatetags.builtins.filters import render_markdown
 from utilities.templatetags.builtins.filters import render_markdown
@@ -29,7 +30,9 @@ __all__ = (
 def get_content_type_labels():
 def get_content_type_labels():
     return [
     return [
         (content_type_identifier(ct), content_type_name(ct))
         (content_type_identifier(ct), content_type_name(ct))
-        for ct in ContentType.objects.order_by('app_label', 'model')
+        for ct in ContentType.objects.filter(
+            FeatureQuery('export_templates').get_query()
+        ).order_by('app_label', 'model')
     ]
     ]