Merge pull request #3404 from jumpserver/dev

Dev
pull/3463/head
BaiJiangJie 5 years ago committed by GitHub
commit bf0575b74d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -60,10 +60,6 @@ class AuthBook(AssetUser):
self.version = 1
self.save()
def set_version_and_latest(self):
self.set_version()
self.set_to_latest()
def get_related_assets(self):
return [self.asset]

@ -53,7 +53,7 @@ class AssetUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
if not validated_data.get("name") and validated_data.get("username"):
validated_data["name"] = validated_data["username"]
instance = AssetUserManager.create(**validated_data)
instance.set_version_and_latest()
instance.set_to_latest()
return instance

@ -9,7 +9,7 @@ from django.dispatch import receiver
from common.utils import get_logger, timeit
from common.decorator import on_transaction_commit
from .models import Asset, SystemUser, Node
from .models import Asset, SystemUser, Node, AuthBook
from .tasks import (
update_assets_hardware_info_util,
test_asset_connectivity_util,
@ -189,3 +189,9 @@ def on_asset_nodes_remove(sender, instance=None, action='', model=None,
def on_node_update_or_created(sender, **kwargs):
# 刷新节点
Node.refresh_nodes()
@receiver(post_save, sender=AuthBook)
def on_authbook_created(sender, instance=None, created=True, **kwargs):
if created and instance:
instance.set_version()

@ -242,6 +242,7 @@ class AdHoc(models.Model):
except AttributeError:
hid = str(uuid.uuid4())
history = AdHocRunHistory(id=hid, adhoc=self, task=self.task)
history.save()
time_start = time.time()
date_start = timezone.now()
is_success = False

Loading…
Cancel
Save