[UPDT] HORILLA_AUTOMATIONS: Updated apps.py to skip start_automation when executing some django manage commands

This commit is contained in:
Horilla
2025-08-26 17:16:41 +05:30
parent 5b33ffccf5
commit 2462c8456e
2 changed files with 24 additions and 7 deletions

View File

@@ -40,10 +40,15 @@ class HorillaAutomationConfig(AppConfig):
model_choices[:] = list(set(model_choices)) # Update in-place
# Only start automation when running the server
if (
len(sys.argv) >= 2
and sys.argv[1] == "runserver"
and os.environ.get("RUN_MAIN") == "true"
if not any(
cmd in sys.argv
for cmd in [
"makemigrations",
"migrate",
"compilemessages",
"flush",
"shell",
]
):
from horilla_automations.signals import start_automation

View File

@@ -65,7 +65,19 @@ def refresh_automations(request):
"""
Method to refresh automation signals
"""
REFRESH_METHODS["clear_connection"]()
REFRESH_METHODS["start_connection"]()
messages.success(request, "Automations refreshed")
refreshed = False
if REFRESH_METHODS.get("clear_connection"):
REFRESH_METHODS["clear_connection"]()
refreshed = True
if REFRESH_METHODS.get("start_connection"):
REFRESH_METHODS["start_connection"]()
refreshed = True
if refreshed:
messages.success(request, "Automations refreshed successfully.")
else:
messages.error(request, "Automation method not available to refresh.")
return HorillaFormView.HttpResponse()