Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 流程市场共享模板查看 #7626 #7630

Conversation

guohelu
Copy link
Collaborator

@guohelu guohelu commented Dec 4, 2024

No description provided.

config/default.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
config/urls_custom.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py Outdated Show resolved Hide resolved
env.py Outdated Show resolved Hide resolved
env.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/urls.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/viewsets.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/admin.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/urls.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/apigw/validators/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/apigw/validators/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/admin.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/contrib/template_market/models.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/urls.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/models.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved

def create_shared_record(self, project_id, market_record_id, template_ids, creator):
for template_id in template_ids:
existing_record, created = TemplateSharedRecord.objects.get_or_create(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里要请求多次 db,在 model 操作上跟 update 应该是一套逻辑,建议写到 model manager 里面

def update_shared_record(self, new_template_ids, market_record_id, project_id, creator):
market_record_id = int(market_record_id)

existing_records = TemplateSharedRecord.objects.filter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接从 market 拉取 template_ids 即可

permission_classes = [permissions.IsAuthenticated, TemplatePreviewPermission]

def retrieve(self, request, *args, **kwargs):
request_serializer = TemplateProjectBaseSerializer(data=request.GET)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.query_params

serializer_class = TemplatePreviewSerializer
permission_classes = [permissions.IsAuthenticated, TemplatePreviewPermission]

def retrieve(self, request, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是 retrieve,前端调用的时候传的 id 是什么

return Response({"result": True, "data": serializer.data, "code": err_code.SUCCESS.code})


class SharedTemplateRecordsViewSet(viewsets.ViewSet):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个视图,跟 TemplateSharedRecord 这个 model 看上去关系不大,后面调整一下相关的所有命名。SharedTemplateRecordsViewSet 的理解是对TemplateSharedRecord这个 model 的相关操作视图

from gcloud.contrib.template_market.permission import TemplatePreviewPermission, SharedTemplateRecordPermission


class TemplatePreviewViewSet(viewsets.ViewSet):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个后面改成 APIView,不是对某个资源的 curd

Copy link
Member

@normal-wls normal-wls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于未解决的问题,需要继续优化

@normal-wls normal-wls merged commit d9fc288 into TencentBlueKing:feature_template_market_master Dec 13, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants