|
28 | 28 | DateTimePicker, |
29 | 29 | ) |
30 | 30 | from utilities.templatetags.builtins.filters import linkify, render_markdown |
| 31 | +from netbox.tables.columns import BooleanColumn |
31 | 32 |
|
32 | 33 | from netbox_custom_objects.constants import APP_LABEL |
33 | 34 | from netbox_custom_objects.utilities import generate_model |
@@ -65,6 +66,9 @@ def _resolve_model(self, model): |
65 | 66 | class FieldType: |
66 | 67 |
|
67 | 68 | def get_display_value(self, instance, field_name): |
| 69 | + """ |
| 70 | + This value is used as the object title in the Custom Object detail view. |
| 71 | + """ |
68 | 72 | return getattr(instance, field_name) |
69 | 73 |
|
70 | 74 | def get_model_field(self, field, **kwargs): |
@@ -238,6 +242,9 @@ def get_form_field(self, field, **kwargs): |
238 | 242 | widget=forms.Select(choices=choices), |
239 | 243 | ) |
240 | 244 |
|
| 245 | + def get_table_column_field(self, field, **kwargs): |
| 246 | + return BooleanColumn() |
| 247 | + |
241 | 248 |
|
242 | 249 | class DateFieldType(FieldType): |
243 | 250 | def get_model_field(self, field, **kwargs): |
@@ -838,6 +845,10 @@ def get_form_field(self, field, for_csv_import=False, **kwargs): |
838 | 845 | def get_filterform_field(self, field, **kwargs): |
839 | 846 | return None |
840 | 847 |
|
| 848 | + def get_display_value(self, instance, field_name): |
| 849 | + field = getattr(instance, field_name) |
| 850 | + return ", ".join(str(s) for s in field.all()) |
| 851 | + |
841 | 852 | def get_table_column_field(self, field, **kwargs): |
842 | 853 | return tables.ManyToManyColumn(linkify_item=True, orderable=False) |
843 | 854 |
|
|
0 commit comments