From 976daaa7261ad73c22ab3b1dc7e9db529909c879 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Fri, 14 Apr 2023 14:45:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DAllTypes=20to=5Ftree?= =?UTF-8?q?=5Fnodes=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/const/base.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/assets/const/base.py b/apps/assets/const/base.py index c90ab7320..99ff06314 100644 --- a/apps/assets/const/base.py +++ b/apps/assets/const/base.py @@ -6,12 +6,27 @@ from .protocol import Protocol class Type: def __init__(self, label, value): + self.name = value self.label = label self.value = value def __str__(self): return self.value + def __add__(self, other): + if isinstance(other, str): + return str(str(self) + other) + raise TypeError("unsupported operand type(s) for +: '{}' and '{}'".format( + type(self), type(other)) + ) + + def __radd__(self, other): + if isinstance(other, str): + return str(other + str(self)) + raise TypeError("unsupported operand type(s) for +(r): '{}' and '{}'".format( + type(self), type(other)) + ) + class BaseType(TextChoices): """ @@ -77,10 +92,7 @@ class BaseType(TextChoices): @classmethod def get_types(cls): - tps = cls._get_choices_to_types() - if not has_valid_xpack_license(): - tps = cls.get_community_types() - return tps + return cls._get_choices_to_types() @classmethod def get_community_types(cls): @@ -88,4 +100,9 @@ class BaseType(TextChoices): @classmethod def get_choices(cls): + if not has_valid_xpack_license(): + return [ + (tp.value, tp.label) + for tp in cls.get_community_types() + ] return cls.choices