mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
14132 model changes
This commit is contained in:
parent
498ac5e44f
commit
1cc8a82921
@ -280,3 +280,18 @@ class DashboardWidgetColorChoices(ChoiceSet):
|
|||||||
(BLACK, _('Black')),
|
(BLACK, _('Black')),
|
||||||
(WHITE, _('White')),
|
(WHITE, _('White')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Event Rules
|
||||||
|
#
|
||||||
|
|
||||||
|
class EventRuleTypeChoices(ChoiceSet):
|
||||||
|
|
||||||
|
WEBHOOK = 'webhook'
|
||||||
|
SCRIPT = 'script'
|
||||||
|
|
||||||
|
CHOICES = (
|
||||||
|
(WEBHOOK, _('Webhook'), 'webhook'),
|
||||||
|
(SCRIPT, _('Script'), 'script'),
|
||||||
|
)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
EVENT_CREATE = 'create'
|
EVENT_CREATE = 'create'
|
||||||
EVENT_UPDATE = 'update'
|
EVENT_UPDATE = 'update'
|
||||||
@ -133,3 +136,10 @@ DEFAULT_DASHBOARD = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
EVENT_TYPE_MODELS = Q(
|
||||||
|
app_label='extras',
|
||||||
|
model__in=(
|
||||||
|
'webhook',
|
||||||
|
'script',
|
||||||
|
))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Generated by Django 4.2.5 on 2023-10-30 21:57
|
# Generated by Django 4.2.5 on 2023-10-31 14:37
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
import extras.utils
|
import extras.utils
|
||||||
import taggit.managers
|
import taggit.managers
|
||||||
import utilities.json
|
import utilities.json
|
||||||
@ -31,6 +32,8 @@ class Migration(migrations.Migration):
|
|||||||
('type_job_end', models.BooleanField(default=False)),
|
('type_job_end', models.BooleanField(default=False)),
|
||||||
('enabled', models.BooleanField(default=True)),
|
('enabled', models.BooleanField(default=True)),
|
||||||
('conditions', models.JSONField(blank=True, null=True)),
|
('conditions', models.JSONField(blank=True, null=True)),
|
||||||
|
('event_type', models.CharField(default='webhook', max_length=30)),
|
||||||
|
('object_id', models.PositiveBigIntegerField(blank=True, null=True)),
|
||||||
(
|
(
|
||||||
'content_types',
|
'content_types',
|
||||||
models.ManyToManyField(
|
models.ManyToManyField(
|
||||||
@ -39,6 +42,15 @@ class Migration(migrations.Migration):
|
|||||||
to='contenttypes.contenttype',
|
to='contenttypes.contenttype',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
'object_type',
|
||||||
|
models.ForeignKey(
|
||||||
|
limit_choices_to=models.Q(('app_label', 'extras'), ('model__in', ('webhook', 'script'))),
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name='eventrule_actions',
|
||||||
|
to='contenttypes.contenttype',
|
||||||
|
),
|
||||||
|
),
|
||||||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
@ -93,6 +93,28 @@ class EventRule(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLogged
|
|||||||
help_text=_("A set of conditions which determine whether the event will be generated.")
|
help_text=_("A set of conditions which determine whether the event will be generated.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
event_type = models.CharField(
|
||||||
|
max_length=30,
|
||||||
|
choices=EventRuleTypeChoices,
|
||||||
|
default=EventRuleTypeChoices.WEBHOOK,
|
||||||
|
verbose_name=_('event type')
|
||||||
|
)
|
||||||
|
# Action to take
|
||||||
|
object_type = models.ForeignKey(
|
||||||
|
to=ContentType,
|
||||||
|
related_name='eventrule_actions',
|
||||||
|
limit_choices_to=EVENT_TYPE_MODELS,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
object_id = models.PositiveBigIntegerField(
|
||||||
|
blank=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
object = GenericForeignKey(
|
||||||
|
ct_field='object_type',
|
||||||
|
fk_field='object_id',
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
verbose_name = _('eventrule')
|
verbose_name = _('eventrule')
|
||||||
|
Loading…
Reference in New Issue
Block a user