Unverified Commit 3dfb2d6a authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

Merge pull request #3405 from jumpserver/bugfix

[Update] 修改 AuthBook set_version / set_latest
parents ebbe49fa c25335cf
......@@ -26,5 +26,4 @@ class AuthBookBackend(BaseBackend):
}
obj = AuthBook.objects.create(**kwargs)
obj.set_auth(**auth_info)
obj.set_version_and_latest()
return obj
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment