mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-16 23:52:41 +00:00
* perf: 支持自定义类型资产 * perf: 改名前 * perf: 优化支持 choices * perf: 优化自定义资产 * perf: 优化资产的详情 * perf: 修改完成自定义平台和资产 --------- Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
22 lines
636 B
Python
22 lines
636 B
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from common.db.models import ChoicesMixin
|
|
|
|
__all__ = ['Category']
|
|
|
|
|
|
class Category(ChoicesMixin, models.TextChoices):
|
|
HOST = 'host', _('Host')
|
|
DEVICE = 'device', _("Device")
|
|
DATABASE = 'database', _("Database")
|
|
CLOUD = 'cloud', _("Cloud service")
|
|
WEB = 'web', _("Web")
|
|
CUSTOM = 'custom', _("Custom type")
|
|
|
|
@classmethod
|
|
def filter_choices(cls, category):
|
|
_category = getattr(cls, category.upper(), None)
|
|
choices = [(_category.value, _category.label)] if _category else cls.choices
|
|
return choices
|