From 817902cb20c94ec97b8fa0144d2794a31fc94c4f Mon Sep 17 00:00:00 2001 From: Jamie Murphy Date: Mon, 11 Apr 2022 13:00:06 +0100 Subject: [PATCH] failback if gateway doesnt exist --- netbox_gateways/__init__.py | 2 +- netbox_gateways/template_content.py | 5 ++++- setup.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/netbox_gateways/__init__.py b/netbox_gateways/__init__.py index 338c7d4..620cd11 100644 --- a/netbox_gateways/__init__.py +++ b/netbox_gateways/__init__.py @@ -5,7 +5,7 @@ class NetBoxGatewayConfig(PluginConfig): name = "netbox_gateways" verbose_name = " Netbox Gateway" description = "Manage simple prefix default gateways" - version = "0.2" + version = "0.3" base_url = "nb_gateways" diff --git a/netbox_gateways/template_content.py b/netbox_gateways/template_content.py index 9a940e6..340b195 100644 --- a/netbox_gateways/template_content.py +++ b/netbox_gateways/template_content.py @@ -30,7 +30,10 @@ def x_page(self): prefix = gateways_obj.prefix if not gateways_obj: - gateways_obj = Gateway.objects.get(prefix=prefix) + try: + gateways_obj = Gateway.objects.get(prefix=prefix) + except: + gateways_obj = None return self.render( "netbox_gateways/ip_card.html", diff --git a/setup.py b/setup.py index dc63121..c365493 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="netbox-gateways", - version="0.2", + version="0.3", description="Manage simple prefix default gateways", install_requires=[], packages=find_packages(),