mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fix graph:type choices under /api/extras/_choices/
This commit is contained in:
parent
830a51d9f5
commit
69a696a8d6
@ -20,6 +20,7 @@ from utilities.api import (
|
||||
ChoiceField, ContentTypeField, get_serializer_for_model, SerializerNotFound, SerializedPKRelatedField,
|
||||
ValidatedModelSerializer,
|
||||
)
|
||||
from utilities.utils import model_names_to_filter_dict
|
||||
from .nested_serializers import *
|
||||
|
||||
|
||||
@ -29,7 +30,7 @@ from .nested_serializers import *
|
||||
|
||||
class GraphSerializer(ValidatedModelSerializer):
|
||||
type = ContentTypeField(
|
||||
queryset=ContentType.objects.all()
|
||||
queryset=ContentType.objects.filter(**model_names_to_filter_dict(GRAPH_MODELS)),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -42,6 +42,14 @@ CUSTOMLINK_MODELS = [
|
||||
'virtualization.virtualmachine',
|
||||
]
|
||||
|
||||
# Models which can have Graphs associated with them
|
||||
GRAPH_MODELS = (
|
||||
'circuits.provider',
|
||||
'dcim.device',
|
||||
'dcim.interface',
|
||||
'dcim.site',
|
||||
)
|
||||
|
||||
# Models which support export templates
|
||||
EXPORTTEMPLATE_MODELS = [
|
||||
'circuits.circuit',
|
||||
|
@ -38,7 +38,7 @@ class Migration(migrations.Migration):
|
||||
model_name='graph',
|
||||
name='type',
|
||||
field=models.ForeignKey(
|
||||
limit_choices_to={'model__in': ['device', 'interface', 'provider', 'site']},
|
||||
limit_choices_to={'model__in': ['provider', 'device', 'interface', 'site']},
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='contenttypes.ContentType'
|
||||
),
|
||||
|
@ -410,9 +410,7 @@ class Graph(models.Model):
|
||||
type = models.ForeignKey(
|
||||
to=ContentType,
|
||||
on_delete=models.CASCADE,
|
||||
limit_choices_to={
|
||||
'model__in': ['device', 'interface', 'provider', 'site']
|
||||
}
|
||||
limit_choices_to=model_names_to_filter_dict(GRAPH_MODELS)
|
||||
)
|
||||
weight = models.PositiveSmallIntegerField(
|
||||
default=1000
|
||||
|
Loading…
Reference in New Issue
Block a user