Browse Source

perf: 优化 custom info

pull/10169/head
ibuler 2 years ago
parent
commit
907fcd7555
  1. 6
      apps/assets/const/custom.py
  2. 11
      apps/assets/migrations/0112_auto_20230404_1631.py

6
apps/assets/const/custom.py

@ -4,7 +4,11 @@ from .base import BaseType
class CustomTypes(BaseType): class CustomTypes(BaseType):
@classmethod @classmethod
def get_choices(cls): def get_choices(cls):
types = cls.get_custom_platforms().values_list('type', flat=True).distinct() try:
platforms = list(cls.get_custom_platforms())
except Exception:
return []
types = [p.type for p in platforms]
return [(t, t) for t in types] return [(t, t) for t in types]
@classmethod @classmethod

11
apps/assets/migrations/0112_auto_20230404_1631.py

@ -32,14 +32,13 @@ class Migration(migrations.Migration):
name='custom_info', name='custom_info',
field=models.JSONField(default=dict, verbose_name='Custom info'), field=models.JSONField(default=dict, verbose_name='Custom info'),
), ),
migrations.RenameField( migrations.AddField(
model_name='asset',
old_name='info',
new_name='gathered_info',
),
migrations.AlterField(
model_name='asset', model_name='asset',
name='gathered_info', name='gathered_info',
field=models.JSONField(blank=True, default=dict, verbose_name='Gathered info'), field=models.JSONField(blank=True, default=dict, verbose_name='Gathered info'),
), ),
migrations.RemoveField(
model_name='asset',
name='info',
),
] ]

Loading…
Cancel
Save