From b6774aa74953653f15e42fbba5eb45658babeccb Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:07:11 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=9B=B4=E6=96=B0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=90=8D=E5=AD=97=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1=E9=AA=8C=20(#12399)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/settings/serializers/basic.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/settings/serializers/basic.py b/apps/settings/serializers/basic.py index ad1c2f8e3..4e253c602 100644 --- a/apps/settings/serializers/basic.py +++ b/apps/settings/serializers/basic.py @@ -1,6 +1,8 @@ from django.utils.translation import gettext_lazy as _ from rest_framework import serializers +from orgs.models import Organization + class BasicSettingSerializer(serializers.Serializer): PREFIX_TITLE = _('Basic') @@ -34,3 +36,10 @@ class BasicSettingSerializer(serializers.Serializer): if not s: return 'http://127.0.0.1' return s.strip('/') + + @staticmethod + def validate_GLOBAL_ORG_DISPLAY_NAME(s): + org_names = Organization.objects.values_list('name', flat=True) + if s in org_names: + raise serializers.ValidationError(_('Organization name already exists')) + return s