From f86034591421ef0392a15656fcf4c3df99ea534d Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Nov 2023 10:37:47 -0500 Subject: [PATCH] Misc cleanup --- netbox/extras/migrations/0101_eventrule.py | 10 +- netbox/extras/models/models.py | 5 +- netbox/extras/scripts_worker.py | 2 +- netbox/extras/utils.py | 8 - netbox/templates/extras/eventrule.html | 162 +++++++++++---------- 5 files changed, 89 insertions(+), 98 deletions(-) diff --git a/netbox/extras/migrations/0101_eventrule.py b/netbox/extras/migrations/0101_eventrule.py index 544ac8570..64e03dda0 100644 --- a/netbox/extras/migrations/0101_eventrule.py +++ b/netbox/extras/migrations/0101_eventrule.py @@ -1,12 +1,10 @@ -# Generated by Django 4.2.5 on 2023-10-31 14:37 - +import django.db.models.deletion +import taggit.managers from django.contrib.contenttypes.models import ContentType from django.db import migrations, models -import django.db.models.deletion -from extras.choices import * -import extras.utils -import taggit.managers + import utilities.json +from extras.choices import * def move_webhooks(apps, schema_editor): diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index a6a459bcb..a4251c62a 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -170,10 +170,7 @@ class EventRule(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLogged if not self.conditions: return True - if ConditionSet(self.conditions).eval(data): - return True - - return False + return ConditionSet(self.conditions).eval(data) class Webhook(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLoggedModel): diff --git a/netbox/extras/scripts_worker.py b/netbox/extras/scripts_worker.py index f2674fe20..1e70a0f8a 100644 --- a/netbox/extras/scripts_worker.py +++ b/netbox/extras/scripts_worker.py @@ -20,7 +20,7 @@ def process_script(event_rule, data, username, **kwargs): return script_choice = None - if event_rule.action_parameters and 'script_choice' in event_rule_action_parameters: + if event_rule.action_parameters and 'script_choice' in event_rule.action_parameters: script_choice = event_rule.action_parameters['script_choice'] if script_choice: diff --git a/netbox/extras/utils.py b/netbox/extras/utils.py index 5ab8fb41c..c6b2de188 100644 --- a/netbox/extras/utils.py +++ b/netbox/extras/utils.py @@ -1,15 +1,7 @@ -import logging -from django.db.models import Q -from django.utils.deconstruct import deconstructible from taggit.managers import _TaggableManager -from extras.conditions import ConditionSet -from extras.choices import EventRuleActionChoices -from netbox.config import get_config from netbox.registry import registry -logger = logging.getLogger('netbox.extras.utils') - def is_taggable(obj): """ diff --git a/netbox/templates/extras/eventrule.html b/netbox/templates/extras/eventrule.html index 375c30dbc..86c330121 100644 --- a/netbox/templates/extras/eventrule.html +++ b/netbox/templates/extras/eventrule.html @@ -4,91 +4,95 @@ {% load i18n %} {% block content %} -
-
-
-
- {% trans "Webhook" %} -
-
- - - - - - - - - -
{% trans "Name" %}{{ object.name }}
{% trans "Enabled" %}{% checkmark object.enabled %}
-
-
-
-
- {% trans "Events" %} -
-
- - - - - - - - - - - - - - - - - - - - - -
{% trans "Create" %}{% checkmark object.type_create %}
{% trans "Update" %}{% checkmark object.type_update %}
{% trans "Delete" %}{% checkmark object.type_delete %}
{% trans "Job start" %}{% checkmark object.type_job_start %}
{% trans "Job end" %}{% checkmark object.type_job_end %}
-
-
- {% plugin_left_page object %} -
-
-
-
- {% trans "Assigned Models" %} -
-
- - {% for ct in object.content_types.all %} +
+
+
+
+ {% trans "Event Rule" %} +
+
+
- + + - {% endfor %} -
{{ ct }}{% trans "Name" %}{{ object.name }}
+ + {% trans "Enabled" %} + {% checkmark object.enabled %} + + + {% trans "Description" %} + {{ object.description|placeholder }} + + +
-
-
-
- {% trans "Conditions" %} -
-
- {% if object.conditions %} -
{{ object.conditions|json }}
- {% else %} -

{% trans "None" %}

- {% endif %} +
+
+ {% trans "Events" %} +
+
+ + + + + + + + + + + + + + + + + + + + + +
{% trans "Create" %}{% checkmark object.type_create %}
{% trans "Update" %}{% checkmark object.type_update %}
{% trans "Delete" %}{% checkmark object.type_delete %}
{% trans "Job start" %}{% checkmark object.type_job_start %}
{% trans "Job end" %}{% checkmark object.type_job_end %}
+
+ {% plugin_left_page object %} +
+
+
+
+ {% trans "Object Types" %} +
+
+ + {% for ct in object.content_types.all %} + + + + {% endfor %} +
{{ ct }}
+
+
+
+
+ {% trans "Conditions" %} +
+
+ {% if object.conditions %} +
{{ object.conditions|json }}
+ {% else %} +

{% trans "None" %}

+ {% endif %} +
+
+ {% include 'inc/panels/custom_fields.html' %} + {% include 'inc/panels/tags.html' %} + {% plugin_right_page object %}
- {% include 'inc/panels/custom_fields.html' %} - {% include 'inc/panels/tags.html' %} - {% plugin_right_page object %}
-
-
+
- {% plugin_full_width_page object %} + {% plugin_full_width_page object %}
-
+
{% endblock %}