jumpserver/apps/terminal/signal_handlers.py

25 lines
605 B
Python
Raw Normal View History

2017-12-29 18:29:29 +00:00
# -*- coding: utf-8 -*-
#
2022-11-01 10:40:42 +00:00
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Applet, AppletHost
@receiver(post_save, sender=AppletHost)
def on_applet_host_create(sender, instance, created=False, **kwargs):
2022-11-01 12:37:04 +00:00
if not created:
return
applets = Applet.objects.all()
instance.applets.set(applets)
2022-11-03 08:55:38 +00:00
instance.generate_accounts()
2022-11-01 10:40:42 +00:00
@receiver(post_save, sender=Applet)
def on_applet_create(sender, instance, created=False, **kwargs):
2022-11-01 12:37:04 +00:00
if not created:
return
hosts = AppletHost.objects.all()
instance.hosts.set(hosts)