Merge pull request #3405 from jumpserver/bugfix

[Update] 修改 AuthBook set_version / set_latest
pull/3404/head
BaiJiangJie 2019-11-01 15:07:31 +08:00 committed by GitHub
commit 3dfb2d6af2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -26,5 +26,4 @@ class AuthBookBackend(BaseBackend):
}
obj = AuthBook.objects.create(**kwargs)
obj.set_auth(**auth_info)
obj.set_version_and_latest()
return obj

View File

@ -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]

View File

@ -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

View File

@ -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()