mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-22 23:46:44 -06:00
Correctly filter BookmarksWidget object_types choices
This commit is contained in:
parent
d575737f92
commit
bfd10ebfe9
@ -32,13 +32,20 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
def get_content_type_labels():
|
||||
def get_object_type_choices():
|
||||
return [
|
||||
(content_type_identifier(ct), content_type_name(ct))
|
||||
for ct in ContentType.objects.public().order_by('app_label', 'model')
|
||||
]
|
||||
|
||||
|
||||
def get_bookmarks_object_type_choices():
|
||||
return [
|
||||
(content_type_identifier(ct), content_type_name(ct))
|
||||
for ct in ContentType.objects.with_feature('bookmarks').order_by('app_label', 'model')
|
||||
]
|
||||
|
||||
|
||||
def get_models_from_content_types(content_types):
|
||||
"""
|
||||
Return a list of models corresponding to the given content types, identified by natural key.
|
||||
@ -158,7 +165,7 @@ class ObjectCountsWidget(DashboardWidget):
|
||||
|
||||
class ConfigForm(WidgetConfigForm):
|
||||
models = forms.MultipleChoiceField(
|
||||
choices=get_content_type_labels
|
||||
choices=get_object_type_choices
|
||||
)
|
||||
filters = forms.JSONField(
|
||||
required=False,
|
||||
@ -207,7 +214,7 @@ class ObjectListWidget(DashboardWidget):
|
||||
|
||||
class ConfigForm(WidgetConfigForm):
|
||||
model = forms.ChoiceField(
|
||||
choices=get_content_type_labels
|
||||
choices=get_object_type_choices
|
||||
)
|
||||
page_size = forms.IntegerField(
|
||||
required=False,
|
||||
@ -343,7 +350,7 @@ class BookmarksWidget(DashboardWidget):
|
||||
|
||||
class ConfigForm(WidgetConfigForm):
|
||||
object_types = forms.MultipleChoiceField(
|
||||
choices=get_content_type_labels,
|
||||
choices=get_bookmarks_object_type_choices,
|
||||
required=False
|
||||
)
|
||||
order_by = forms.ChoiceField(
|
||||
|
Loading…
Reference in New Issue
Block a user