Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total_objs_to_delete and remove the table when deleting all objects. #833

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/831.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolved issue with tests failing in Nautobot 2.3.11.
17 changes: 11 additions & 6 deletions nautobot_golden_config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nautobot-golden-config"
version = "2.2.0"
version = "2.2.1a0"
jeffkala marked this conversation as resolved.
Show resolved Hide resolved
description = "An app for configuration on nautobot"
authors = ["Network to Code, LLC <[email protected]>"]
license = "Apache-2.0"
Expand Down