From 00cedbd589bd6add97d9acde7531541f3aa5e693 Mon Sep 17 00:00:00 2001 From: rizlas Date: Tue, 11 Jan 2022 14:09:46 +0100 Subject: [PATCH] Minor fixes --- netbox_interface_sync/comparison.py | 4 ++++ netbox_interface_sync/views.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/netbox_interface_sync/comparison.py b/netbox_interface_sync/comparison.py index 41d420c..ec0ce61 100644 --- a/netbox_interface_sync/comparison.py +++ b/netbox_interface_sync/comparison.py @@ -146,6 +146,10 @@ class PowerPortComparison(ParentTypedComparison): and (self.allocated_draw == other.allocated_draw) ) + def __hash__(self): + # Ignore some fields when hashing; ignore interface name case and whitespaces + return hash((self.name.lower().replace(" ", ""), self.type)) + @dataclass(frozen=True) class PowerOutletComparison(ParentTypedComparison): diff --git a/netbox_interface_sync/views.py b/netbox_interface_sync/views.py index 59ff5aa..6c0b03a 100644 --- a/netbox_interface_sync/views.py +++ b/netbox_interface_sync/views.py @@ -317,7 +317,7 @@ class PowerOutletComparisonView(LoginRequiredMixin, PermissionRequiredMixin, Vie except ValueError: pass else: - message.append("Dependecy detected, sync power ports first!") + messages.error(request, "Dependecy detected, sync power ports first!") if created > 0: message.append(f"created {created} power outlet") @@ -450,7 +450,7 @@ class FrontPortComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View) except ValueError: pass else: - message.append("Dependecy detected, sync rear ports first!") + messages.error(request, "Dependecy detected, sync power ports first!") if created > 0: message.append(f"created {created} front ports")