2019-05-20 11:39:53 +00:00
|
|
|
# coding: utf-8
|
|
|
|
#
|
2021-01-03 21:27:03 +00:00
|
|
|
from django.db.models import TextChoices
|
2019-05-20 11:39:53 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
|
2021-07-27 08:06:00 +00:00
|
|
|
class AppCategory(TextChoices):
|
2021-01-03 21:27:03 +00:00
|
|
|
db = 'db', _('Database')
|
|
|
|
remote_app = 'remote_app', _('Remote app')
|
|
|
|
cloud = 'cloud', 'Cloud'
|
2019-12-19 07:28:17 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
@classmethod
|
|
|
|
def get_label(cls, category):
|
|
|
|
return dict(cls.choices).get(category, '')
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
|
2021-07-27 08:06:00 +00:00
|
|
|
class AppType(TextChoices):
|
2021-01-03 21:27:03 +00:00
|
|
|
# db category
|
|
|
|
mysql = 'mysql', 'MySQL'
|
|
|
|
oracle = 'oracle', 'Oracle'
|
|
|
|
pgsql = 'postgresql', 'PostgreSQL'
|
|
|
|
mariadb = 'mariadb', 'MariaDB'
|
2019-05-20 11:39:53 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
# remote-app category
|
|
|
|
chrome = 'chrome', 'Chrome'
|
|
|
|
mysql_workbench = 'mysql_workbench', 'MySQL Workbench'
|
|
|
|
vmware_client = 'vmware_client', 'vSphere Client'
|
|
|
|
custom = 'custom', _('Custom')
|
2019-05-20 11:39:53 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
# cloud category
|
|
|
|
k8s = 'k8s', 'Kubernetes'
|
2019-12-10 07:16:16 +00:00
|
|
|
|
2021-07-27 08:06:00 +00:00
|
|
|
@classmethod
|
|
|
|
def category_types_mapper(cls):
|
|
|
|
return {
|
|
|
|
AppCategory.db: [cls.mysql, cls.oracle, cls.pgsql, cls.mariadb],
|
|
|
|
AppCategory.remote_app: [cls.chrome, cls.mysql_workbench, cls.vmware_client, cls.custom],
|
|
|
|
AppCategory.cloud: [cls.k8s]
|
|
|
|
}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def type_category_mapper(cls):
|
|
|
|
mapper = {}
|
|
|
|
for category, tps in cls.category_types_mapper().items():
|
|
|
|
for tp in tps:
|
|
|
|
mapper[tp] = category
|
|
|
|
return mapper
|
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
@classmethod
|
|
|
|
def get_label(cls, tp):
|
|
|
|
return dict(cls.choices).get(tp, '')
|
2019-12-19 07:28:17 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
@classmethod
|
|
|
|
def db_types(cls):
|
2021-07-27 08:06:00 +00:00
|
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.db]]
|
2019-12-19 07:28:17 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
@classmethod
|
|
|
|
def remote_app_types(cls):
|
2021-07-27 08:06:00 +00:00
|
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.remote_app]]
|
2019-12-19 07:28:17 +00:00
|
|
|
|
2021-01-03 21:27:03 +00:00
|
|
|
@classmethod
|
|
|
|
def cloud_types(cls):
|
2021-07-27 08:06:00 +00:00
|
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.cloud]]
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-19 07:28:17 +00:00
|
|
|
|