ep signals bug

This commit is contained in:
曹前明 2022-07-07 10:36:28 +08:00
parent fe12351f72
commit 3f0d73416b
2 changed files with 9 additions and 7 deletions

View File

@ -93,6 +93,8 @@ class ChannelAuthoritySerializer(serializers.Serializer):
class EmployeeSerializer(EmployeeBaseSerializer):
belong_dept_ = DeptSimpleSerializer(source='belong_dept', read_only=True)
belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True)
post_name = serializers.CharField(source='post.name', read_only=True)
class Meta:
model = Employee

View File

@ -9,13 +9,13 @@ def updateEmployee(sender, instance, created, **kwargs):
# if created:
if not instance.is_superuser:
ep, ep_created = Employee.objects.get_or_create(user=instance,
defaults={
"user": instance,
"name": instance.name,
"phone": instance.phone,
"belong_dept": instance.belong_dept,
"post": instance.post
})
defaults={
"user": instance,
"name": instance.name,
"phone": instance.phone,
"belong_dept": instance.belong_dept,
"post": instance.post
})
if not ep_created:
ep.belong_dept = instance.belong_dept
ep.post = instance.post