-
Notifications
You must be signed in to change notification settings - Fork 378
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
feat: 流程市场共享模板查看 #7626 #7630
Conversation
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py
Outdated
Show resolved
Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py
Outdated
Show resolved
Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个后面改成 APIView,不是对某个资源的 curd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于未解决的问题,需要继续优化
d9fc288
into
TencentBlueKing:feature_template_market_master
No description provided.