diff --git a/changes/831.fixed b/changes/831.fixed new file mode 100644 index 00000000..ca92de1c --- /dev/null +++ b/changes/831.fixed @@ -0,0 +1 @@ +Resolved issue with tests failing in Nautobot 2.3.11. diff --git a/nautobot_golden_config/views.py b/nautobot_golden_config/views.py index 024c2044..e094ad66 100644 --- a/nautobot_golden_config/views.py +++ b/nautobot_golden_config/views.py @@ -252,19 +252,20 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.pk_list = None self.report_context = None - self.store_table = None + self.store_table = None # Used to store the table for bulk delete. No longer required in Nautobot 2.3.11 def get_extra_context(self, request, instance=None, **kwargs): """A ConfigCompliance helper function to warn if the Job is not enabled to run.""" context = super().get_extra_context(request, instance) - if self.action == "bulk_destroy": - context["table"] = self.store_table if self.action == "overview": context = {**context, **self.report_context} + # TODO Remove when dropping support for Nautobot < 2.3.11 + if self.action == "bulk_destroy": + context["table"] = self.store_table + context["compliance"] = constant.ENABLE_COMPLIANCE context["backup"] = constant.ENABLE_BACKUP context["intended"] = constant.ENABLE_INTENDED - # TODO: See reference to store_table below for action item add_message([["ComplianceJob", constant.ENABLE_COMPLIANCE]], request) return context @@ -315,10 +316,14 @@ def perform_bulk_destroy(self, request, **kwargs): f"No {self.queryset.model._meta.verbose_name_plural} were selected for deletion.", ) return redirect(self.get_return_url(request)) - # TODO: This does not seem right, it is not clear why data does not just get added to context + + # TODO Remove when dropping support for Nautobot < 2.3.11 self.store_table = table - data.update({"table": table}) + if not request.POST.get("_all"): + data.update({"table": table, "total_objs_to_delete": len(table.rows)}) + else: + data.update({"table": None, "delete_all": True, "total_objs_to_delete": len(table.rows)}) return Response(data) @action(detail=True, methods=["get"]) diff --git a/pyproject.toml b/pyproject.toml index 4384122c..39602ff8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-golden-config" -version = "2.2.0" +version = "2.2.1a0" description = "An app for configuration on nautobot" authors = ["Network to Code, LLC "] license = "Apache-2.0"