Commit 1877511a authored by ibuler's avatar ibuler

[Update] 更改组织同事更改节点名称

parent 1c5ce61e
# -*- coding: utf-8 -*-
#
from assets.models import Node
from orgs.utils import set_current_org, current_org
......@@ -5,9 +5,19 @@ from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Organization
from .hands import set_current_org, current_org, Node
@receiver(post_save, sender=Organization)
def on_org_update(sender, instance=None, created=False, **kwargs):
def on_org_create_or_update(sender, instance=None, created=False, **kwargs):
if instance:
old_org = current_org
set_current_org(instance)
node_root = Node.root()
if node_root.value != instance.name:
node_root.value = instance.name
node_root.save()
set_current_org(old_org)
if instance and not created:
instance.expire_cache()
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