1
0
mirror of https://github.com/jumpserver/jumpserver.git synced 2025-05-08 16:16:40 +00:00
jumpserver/apps/assets/const/category.py
fit2bot 75496cbe91
perf: Account backup failed ()
Co-authored-by: feng <1304903146@qq.com>
2024-06-13 18:20:00 +08:00

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