mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-10 01:28:16 -06:00
Addressed PR comments.
This commit is contained in:
parent
3df04efecc
commit
270bd53301
@ -135,12 +135,12 @@ class ConditionSet:
|
|||||||
def __init__(self, ruleset):
|
def __init__(self, ruleset):
|
||||||
if type(ruleset) is not dict:
|
if type(ruleset) is not dict:
|
||||||
raise ValueError(_("Ruleset must be a dictionary, not {ruleset}.").format(ruleset=type(ruleset)))
|
raise ValueError(_("Ruleset must be a dictionary, not {ruleset}.").format(ruleset=type(ruleset)))
|
||||||
|
print(len(ruleset))
|
||||||
if len(ruleset) == 1:
|
if len(ruleset) == 1:
|
||||||
self.logic = (list(ruleset.keys())[0]).lower()
|
self.logic = (list(ruleset.keys())[0]).lower()
|
||||||
if self.logic not in (AND, OR):
|
if self.logic not in (AND, OR):
|
||||||
raise ValueError(
|
raise ValueError(_(
|
||||||
f"Invalid logic type: {self.logic} (must be '{AND}' or '{OR}'). Please check documentation.")
|
f"Invalid logic type: {self.logic} (must be 'AND' or 'OR'). Please check documentation."))
|
||||||
|
|
||||||
# Compile the set of Conditions
|
# Compile the set of Conditions
|
||||||
self.conditions = [
|
self.conditions = [
|
||||||
@ -152,7 +152,7 @@ class ConditionSet:
|
|||||||
self.logic = None
|
self.logic = None
|
||||||
self.conditions = [Condition(**ruleset)]
|
self.conditions = [Condition(**ruleset)]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise ValueError(f"Incorrect key(s) informed. Please check documentation.")
|
raise ValueError(_("Incorrect key(s) informed. Please check documentation."))
|
||||||
|
|
||||||
def eval(self, data):
|
def eval(self, data):
|
||||||
"""
|
"""
|
||||||
|
@ -13,7 +13,6 @@ from dcim.choices import SiteStatusChoices
|
|||||||
from dcim.models import Site
|
from dcim.models import Site
|
||||||
from extras.choices import EventRuleActionChoices, ObjectChangeActionChoices
|
from extras.choices import EventRuleActionChoices, ObjectChangeActionChoices
|
||||||
from extras.events import enqueue_object, flush_events, serialize_for_event
|
from extras.events import enqueue_object, flush_events, serialize_for_event
|
||||||
from extras.forms import SavedFilterForm, EventRuleForm
|
|
||||||
from extras.models import EventRule, Tag, Webhook
|
from extras.models import EventRule, Tag, Webhook
|
||||||
from extras.webhooks import generate_signature, send_webhook
|
from extras.webhooks import generate_signature, send_webhook
|
||||||
from utilities.testing import APITestCase
|
from utilities.testing import APITestCase
|
||||||
|
Loading…
Reference in New Issue
Block a user