14
14
from django .utils .translation import gettext_lazy as _
15
15
from extras .choices import CustomFieldTypeChoices , CustomFieldUIEditableChoices
16
16
from utilities .api import get_serializer_for_model
17
- from utilities .forms .fields import (CSVChoiceField , CSVMultipleChoiceField ,
18
- DynamicChoiceField ,
19
- DynamicMultipleChoiceField , JSONField ,
20
- LaxURLField )
17
+ from utilities .forms .fields import (
18
+ CSVChoiceField ,
19
+ CSVMultipleChoiceField ,
20
+ DynamicChoiceField ,
21
+ DynamicMultipleChoiceField ,
22
+ JSONField ,
23
+ LaxURLField ,
24
+ )
21
25
from utilities .forms .utils import add_blank_choice
22
- from utilities .forms .widgets import (APISelect , APISelectMultiple , DatePicker ,
23
- DateTimePicker )
26
+ from utilities .forms .widgets import (
27
+ APISelect ,
28
+ APISelectMultiple ,
29
+ DatePicker ,
30
+ DateTimePicker ,
31
+ )
24
32
from utilities .templatetags .builtins .filters import linkify , render_markdown
25
33
26
34
from netbox_custom_objects .constants import APP_LABEL
27
35
from netbox_custom_objects .utilities import get_custom_object_type_from_content_type
28
36
37
+
29
38
class FieldType :
30
39
31
40
def get_display_value (self , instance , field_name ):
@@ -335,7 +344,9 @@ def get_model_field(self, field, **kwargs):
335
344
if content_type .app_label == APP_LABEL :
336
345
from netbox_custom_objects .models import CustomObjectType
337
346
338
- custom_object_type_id = get_custom_object_type_from_content_type (content_type )
347
+ custom_object_type_id = get_custom_object_type_from_content_type (
348
+ content_type
349
+ )
339
350
custom_object_type = CustomObjectType .objects .get (pk = custom_object_type_id )
340
351
model = custom_object_type .get_model ()
341
352
else :
@@ -356,11 +367,14 @@ def get_form_field(self, field, for_csv_import=False, **kwargs):
356
367
content_type = ContentType .objects .get (pk = field .related_object_type_id )
357
368
358
369
from utilities .forms .fields import DynamicModelChoiceField
370
+
359
371
if content_type .app_label == APP_LABEL :
360
372
# This is a custom object type
361
373
from netbox_custom_objects .models import CustomObjectType
362
374
363
- custom_object_type_id = get_custom_object_type_from_content_type (content_type )
375
+ custom_object_type_id = get_custom_object_type_from_content_type (
376
+ content_type
377
+ )
364
378
custom_object_type = CustomObjectType .objects .get (pk = custom_object_type_id )
365
379
model = custom_object_type .get_model ()
366
380
field_class = DynamicModelChoiceField
@@ -641,7 +655,9 @@ def get_form_field(self, field, for_csv_import=False, **kwargs):
641
655
# This is a custom object type
642
656
from netbox_custom_objects .models import CustomObjectType
643
657
644
- custom_object_type_id = get_custom_object_type_from_content_type (content_type )
658
+ custom_object_type_id = get_custom_object_type_from_content_type (
659
+ content_type
660
+ )
645
661
custom_object_type = CustomObjectType .objects .get (pk = custom_object_type_id )
646
662
model = custom_object_type .get_model ()
647
663
else :
@@ -701,7 +717,9 @@ def after_model_generation(self, instance, model, field_name):
701
717
if content_type .app_label == APP_LABEL :
702
718
from netbox_custom_objects .models import CustomObjectType
703
719
704
- custom_object_type_id = get_custom_object_type_from_content_type (content_type )
720
+ custom_object_type_id = get_custom_object_type_from_content_type (
721
+ content_type
722
+ )
705
723
custom_object_type = CustomObjectType .objects .get (pk = custom_object_type_id )
706
724
to_model = custom_object_type .get_model ()
707
725
else :
@@ -741,7 +759,9 @@ def create_m2m_table(self, instance, model, field_name):
741
759
if content_type .app_label == APP_LABEL :
742
760
from netbox_custom_objects .models import CustomObjectType
743
761
744
- custom_object_type_id = get_custom_object_type_from_content_type (content_type )
762
+ custom_object_type_id = get_custom_object_type_from_content_type (
763
+ content_type
764
+ )
745
765
custom_object_type = CustomObjectType .objects .get (
746
766
pk = custom_object_type_id
747
767
)
0 commit comments