mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
688 B
25 lines
688 B
12 months ago
|
from django.db.models.signals import post_save
|
||
|
from django.dispatch import receiver
|
||
|
|
||
|
from common.decorators import on_transaction_commit
|
||
|
from ..models import AppProvider, VirtualApp
|
||
|
|
||
|
|
||
|
@receiver(post_save, sender=AppProvider)
|
||
|
@on_transaction_commit
|
||
|
def on_virtual_host_create(sender, instance, created=False, **kwargs):
|
||
|
if not created:
|
||
|
return
|
||
|
apps = VirtualApp.objects.all()
|
||
|
instance.apps.set(apps)
|
||
|
|
||
|
|
||
|
@receiver(post_save, sender=VirtualApp)
|
||
|
def on_virtual_app_create(sender, instance, created=False, **kwargs):
|
||
|
if not created:
|
||
|
return
|
||
|
providers = AppProvider.objects.all()
|
||
|
if len(providers) == 0:
|
||
|
return
|
||
|
instance.providers.set(providers)
|