fix: 全局组织,添加标签报错

This commit is contained in:
wangruidong
2024-06-17 17:57:03 +08:00
committed by w940853815
parent 44f29e166c
commit 4a520e9e10
7 changed files with 24 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
from django.core.exceptions import ValidationError
from rest_framework.serializers import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -45,7 +45,7 @@ class OrgManager(models.Manager):
for obj in objs:
if org.is_root():
if not obj.org_id:
raise ValidationError('Please save in a org')
raise ValidationError(_('Please save in a org'))
else:
obj.org_id = org.id
return super().bulk_create(objs, batch_size, ignore_conflicts)
@@ -70,7 +70,7 @@ class OrgModelMixin(models.Model):
# raise ...
if org.is_root():
if not self.org_id:
raise ValidationError('Please save in a org')
raise ValidationError(_('Please save in a org'))
else:
self.org_id = org.id
return super().save(*args, **kwargs)
@@ -119,4 +119,3 @@ class OrgModelMixin(models.Model):
class JMSOrgBaseModel(JMSBaseModel, OrgModelMixin):
class Meta:
abstract = True