mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-22 20:09:54 +00:00
fix: 全局组织,添加标签报错
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user