This commit is contained in:
IGNY8 VPS (Salman)
2025-12-14 22:21:17 +00:00
parent 9150b60c2d
commit f637f700eb
11 changed files with 1565 additions and 58 deletions

View File

@@ -2,6 +2,7 @@
Admin registration for Automation models
"""
from django.contrib import admin
from django.contrib import messages
from unfold.admin import ModelAdmin
from igny8_core.admin.base import AccountAdminMixin
from .models import AutomationConfig, AutomationRun
@@ -12,6 +13,19 @@ class AutomationConfigAdmin(AccountAdminMixin, ModelAdmin):
list_display = ('site', 'is_enabled', 'frequency', 'scheduled_time', 'within_stage_delay', 'between_stage_delay', 'last_run_at')
list_filter = ('is_enabled', 'frequency')
search_fields = ('site__domain',)
actions = ['bulk_enable', 'bulk_disable']
def bulk_enable(self, request, queryset):
"""Enable selected automation configs"""
updated = queryset.update(is_enabled=True)
self.message_user(request, f'{updated} automation config(s) enabled.', messages.SUCCESS)
bulk_enable.short_description = 'Enable selected automations'
def bulk_disable(self, request, queryset):
"""Disable selected automation configs"""
updated = queryset.update(is_enabled=False)
self.message_user(request, f'{updated} automation config(s) disabled.', messages.SUCCESS)
bulk_disable.short_description = 'Disable selected automations'
@admin.register(AutomationRun)