From 113c6d6c88838e68ec299417df59aedfedb35524 Mon Sep 17 00:00:00 2001 From: guohelu <19503896967@163.com> Date: Tue, 10 Dec 2024 10:29:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96=E9=97=AE=E9=A2=98=20#7626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/contrib/template_market/admin.py | 6 ++-- .../migrations/0001_initial.py | 7 ++-- gcloud/contrib/template_market/models.py | 2 +- gcloud/contrib/template_market/serializers.py | 33 +------------------ 4 files changed, 7 insertions(+), 41 deletions(-) diff --git a/gcloud/contrib/template_market/admin.py b/gcloud/contrib/template_market/admin.py index b2d3c729a..7a89f6a28 100644 --- a/gcloud/contrib/template_market/admin.py +++ b/gcloud/contrib/template_market/admin.py @@ -18,6 +18,6 @@ @admin.register(models.TemplateSharedRecord) class TemplateMarketAdmin(admin.ModelAdmin): - list_display = ["project_id", "template_id", "creator", "create_at", "extra_info"] - list_filter = ["project_id", "template_id", "creator", "create_at"] - search_fields = ["project_id", "creator"] + list_display = ["project_id", "template_id", "scene_instance_id", "creator", "create_at", "extra_info"] + list_filter = ["project_id", "creator", "create_at"] + search_fields = ["project_id", "template_id", "scene_instance_id", "creator"] diff --git a/gcloud/contrib/template_market/migrations/0001_initial.py b/gcloud/contrib/template_market/migrations/0001_initial.py index c9e5d1f27..e9fb9abbe 100644 --- a/gcloud/contrib/template_market/migrations/0001_initial.py +++ b/gcloud/contrib/template_market/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.15 on 2024-12-09 12:51 +# Generated by Django 3.2.15 on 2024-12-10 02:27 from django.db import migrations, models @@ -16,10 +16,7 @@ class Migration(migrations.Migration): ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("project_id", models.IntegerField(default=-1, help_text="项目 ID", verbose_name="项目 ID")), ("template_id", models.IntegerField(help_text="模版 ID", verbose_name="模版 ID")), - ( - "scene_instance_id", - models.CharField(db_index=True, help_text="场景实例 ID", max_length=32, verbose_name="场景实例 ID"), - ), + ("scene_instance_id", models.IntegerField(db_index=True, help_text="场景实例 ID", verbose_name="场景实例 ID")), ("creator", models.CharField(default="", max_length=32, verbose_name="创建者")), ("create_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")), ("extra_info", models.JSONField(blank=True, null=True, verbose_name="额外信息")), diff --git a/gcloud/contrib/template_market/models.py b/gcloud/contrib/template_market/models.py index 26c708585..9ca074161 100644 --- a/gcloud/contrib/template_market/models.py +++ b/gcloud/contrib/template_market/models.py @@ -19,7 +19,7 @@ class TemplateSharedRecord(models.Model): project_id = models.IntegerField(_("项目 ID"), default=-1, help_text="项目 ID") template_id = models.IntegerField(_("模版 ID"), help_text="模版 ID") - scene_instance_id = models.CharField(_("场景实例 ID"), max_length=32, db_index=True, help_text="场景实例 ID") + scene_instance_id = models.IntegerField(_("场景实例 ID"), db_index=True, help_text="场景实例 ID") creator = models.CharField(_("创建者"), max_length=32, default="") create_at = models.DateTimeField(_("创建时间"), auto_now_add=True) extra_info = models.JSONField(_("额外信息"), blank=True, null=True) diff --git a/gcloud/contrib/template_market/serializers.py b/gcloud/contrib/template_market/serializers.py index ab9bef6c2..9e5658815 100644 --- a/gcloud/contrib/template_market/serializers.py +++ b/gcloud/contrib/template_market/serializers.py @@ -14,21 +14,15 @@ from rest_framework import serializers from gcloud.constants import DATETIME_FORMAT -from gcloud.contrib.template_market.models import TemplateSharedRecord -from gcloud.tasktmpl3.models import TaskTemplate -class TemplatePreviewSerializer(serializers.ModelSerializer): +class TemplatePreviewSerializer(serializers.Serializer): name = serializers.CharField(read_only=True, help_text="模板名称") pipeline_tree = serializers.SerializerMethodField(read_only=True, help_text="pipeline_tree") def get_pipeline_tree(self, obj): return json.dumps(obj.pipeline_tree) - class Meta: - model = TaskTemplate - fields = ["name", "pipeline_tree"] - class TemplateSharedRecordSerializer(serializers.Serializer): template_id = serializers.CharField(required=True, help_text="模板id") @@ -42,28 +36,3 @@ class TemplateSharedRecordSerializer(serializers.Serializer): creator = serializers.CharField(required=False, max_length=32, help_text="创建者") create_at = serializers.DateTimeField(required=False, help_text="创建时间", format=DATETIME_FORMAT) extra_info = serializers.JSONField(required=False, allow_null=True, help_text="额外信息") - - def create(self, validated_data): - instance = TemplateSharedRecord.objects.create( - project_id=validated_data["project_id"], - template_id=validated_data["template_id"], - creator=validated_data.get("creator", ""), - extra_info=validated_data.get("extra_info"), - ) - return instance - - class Meta: - model = TemplateSharedRecord - fields = [ - "project_id", - "template_id", - "creator", - "create_at", - "extra_info", - "name", - "code", - "category", - "risk_level", - "labels", - "usage_content", - ]