+
+
+ {% for value, label in field.choices %}
+ {% if value %}
+
+
{{ value }}
+
{{ label }}
+
+ {% endif %}
+ {% endfor %}
+
+
+
+
+
+ {% endif %}
+ {% if field|widget_type == 'dateinput' %}
+ {% trans "Format: YYYY-MM-DD" %}
+ {% elif field|widget_type == 'checkboxinput' %}
+ {% trans "Specify true or false" %}
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+ {% blocktrans trimmed %}
+ Required fields must be specified for all objects.
+ {% endblocktrans %}
+
+
+
+ {% blocktrans trimmed with example="vrf.rd" %}
+ Related objects may be referenced by any unique attribute. For example, {{ example }} would identify a VRF by its route distinguisher.
+ {% endblocktrans %}
+
{% endif %}
{% endfor %}
-{% endblock form %}
\ No newline at end of file
+{% endblock form %}
+
+{% block buttons %}
+ {% trans "Cancel" %}
+ {% if object.pk %}
+
+ {% else %}
+
+
+
+
+ {% endif %}
+{% endblock buttons %}
\ No newline at end of file
diff --git a/netbox_custom_objects/templates/netbox_custom_objects/inc/branch_warning.html b/netbox_custom_objects/templates/netbox_custom_objects/inc/branch_warning.html
index 98b9e68..ed7d027 100644
--- a/netbox_custom_objects/templates/netbox_custom_objects/inc/branch_warning.html
+++ b/netbox_custom_objects/templates/netbox_custom_objects/inc/branch_warning.html
@@ -6,7 +6,7 @@
{% blocktrans trimmed %}
- This object has fields that reference objects in other apps and you have a branch active. Care must be taken to not reference an object that only exists in another branch.
+ Please switch to the main branch to perform this operation.
{% endblocktrans %}
diff --git a/netbox_custom_objects/views.py b/netbox_custom_objects/views.py
index d3ccc50..a25733b 100644
--- a/netbox_custom_objects/views.py
+++ b/netbox_custom_objects/views.py
@@ -574,20 +574,8 @@ def custom_save(self, commit=True):
return form_class
def get_extra_context(self, request, obj):
-
- # Check if we're in a branch and if there are external object pointers
- has_external_object_pointers = False
- if is_in_branch():
- # Check all fields in the custom object type
- for field in self.object.custom_object_type.fields.all():
- if field.type in [CustomFieldTypeChoices.TYPE_OBJECT, CustomFieldTypeChoices.TYPE_MULTIOBJECT]:
- # Check if the related object type is not from the current app
- if field.related_object_type.app_label != APP_LABEL:
- has_external_object_pointers = True
- break
-
return {
- 'branch_warning': has_external_object_pointers,
+ 'branch_warning': is_in_branch(),
}
@@ -634,6 +622,7 @@ def get_return_url(self, request, obj=None):
@register_model_view(CustomObject, "bulk_edit", path="edit", detail=False)
class CustomObjectBulkEditView(CustomObjectTableMixin, generic.BulkEditView):
+ template_name = "netbox_custom_objects/custom_object_bulk_edit.html"
queryset = None
custom_object_type = None
table = None
@@ -690,6 +679,11 @@ def get_form(self, queryset):
return form
+ def get_extra_context(self, request):
+ return {
+ 'branch_warning': is_in_branch(),
+ }
+
@register_model_view(CustomObject, "bulk_delete", path="delete", detail=False)
class CustomObjectBulkDeleteView(CustomObjectTableMixin, generic.BulkDeleteView):
@@ -706,9 +700,9 @@ def setup(self, request, *args, **kwargs):
def get_queryset(self, request):
if self.queryset:
return self.queryset
- custom_object_type = self.kwargs.pop("custom_object_type", None)
+ self.custom_object_type = self.kwargs.pop("custom_object_type", None)
self.custom_object_type = CustomObjectType.objects.get(
- slug=custom_object_type
+ slug=self.custom_object_type
)
model = self.custom_object_type.get_model_with_serializer()
return model.objects.all()
@@ -716,8 +710,10 @@ def get_queryset(self, request):
@register_model_view(CustomObject, "bulk_import", path="import", detail=False)
class CustomObjectBulkImportView(generic.BulkImportView):
+ template_name = "netbox_custom_objects/custom_object_bulk_import.html"
queryset = None
model_form = None
+ custom_object_type = None
def get(self, request, custom_object_type):
# Necessary because get() in BulkImportView only takes request and no **kwargs
@@ -774,6 +770,11 @@ def get_model_form(self, queryset):
return form
+ def get_extra_context(self, request):
+ return {
+ 'branch_warning': is_in_branch(),
+ }
+
class CustomObjectJournalView(ConditionalLoginRequiredMixin, View):
"""