Misc cleanup

This commit is contained in:
Jeremy Stretch 2023-11-27 10:37:47 -05:00
parent bf11f1db0d
commit f860345914
5 changed files with 89 additions and 98 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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:

View File

@ -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):
"""

View File

@ -4,91 +4,95 @@
{% load i18n %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Webhook" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Enabled" %}</th>
<td>{% checkmark object.enabled %}</td>
</tr>
</table>
</div>
</div>
<div class="card">
<h5 class="card-header">
{% trans "Events" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Create" %}</th>
<td>{% checkmark object.type_create %}</td>
</tr>
<tr>
<th scope="row">{% trans "Update" %}</th>
<td>{% checkmark object.type_update %}</td>
</tr>
<tr>
<th scope="row">{% trans "Delete" %}</th>
<td>{% checkmark object.type_delete %}</td>
</tr>
<tr>
<th scope="row">{% trans "Job start" %}</th>
<td>{% checkmark object.type_job_start %}</td>
</tr>
<tr>
<th scope="row">{% trans "Job end" %}</th>
<td>{% checkmark object.type_job_end %}</td>
</tr>
</table>
</div>
</div>
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Assigned Models" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
{% for ct in object.content_types.all %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Event Rule" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<td>{{ ct }}</td>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
{% endfor %}
</table>
<tr>
<th scope="row">{% trans "Enabled" %}</th>
<td>{% checkmark object.enabled %}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="card">
<h5 class="card-header">
{% trans "Conditions" %}
</h5>
<div class="card-body">
{% if object.conditions %}
<pre>{{ object.conditions|json }}</pre>
{% else %}
<p class="text-muted">{% trans "None" %}</p>
{% endif %}
<div class="card">
<h5 class="card-header">
{% trans "Events" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Create" %}</th>
<td>{% checkmark object.type_create %}</td>
</tr>
<tr>
<th scope="row">{% trans "Update" %}</th>
<td>{% checkmark object.type_update %}</td>
</tr>
<tr>
<th scope="row">{% trans "Delete" %}</th>
<td>{% checkmark object.type_delete %}</td>
</tr>
<tr>
<th scope="row">{% trans "Job start" %}</th>
<td>{% checkmark object.type_job_start %}</td>
</tr>
<tr>
<th scope="row">{% trans "Job end" %}</th>
<td>{% checkmark object.type_job_end %}</td>
</tr>
</table>
</div>
</div>
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Object Types" %}
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
{% for ct in object.content_types.all %}
<tr>
<td>{{ ct }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="card">
<h5 class="card-header">
{% trans "Conditions" %}
</h5>
<div class="card-body">
{% if object.conditions %}
<pre>{{ object.conditions|json }}</pre>
{% else %}
<p class="text-muted">{% trans "None" %}</p>
{% endif %}
</div>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
{% plugin_right_page object %}
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row">
<div class="row">
<div class="col col-md-12">
{% plugin_full_width_page object %}
{% plugin_full_width_page object %}
</div>
</div>
</div>
{% endblock %}