star function

This commit is contained in:
chenyang
2022-07-23 08:46:47 +08:00
parent 690dcd2418
commit 08038cefd7
7 changed files with 43 additions and 27 deletions
+8
View File
@@ -17,6 +17,14 @@ def to_share(request):
return render(request, "html/dashboard.html", param)
def to_star(request):
"""
收藏页面
"""
param = {"page": "star"}
return render(request, "html/dashboard.html", param)
def to_detail(request):
"""
详情页面
+11 -2
View File
@@ -50,7 +50,10 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
elif 'share' == src_page:
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'))
self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1).values('id', 'coop_mind_name', "client_uuid", "data_format")
self.queryset = CooperationMind.objects.annotate(share_col=Exists(share), ).filter(share_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
elif 'star' == src_page:
star = CooperationMindStar.objects.filter(coop_mind_id=OuterRef('id'))
self.queryset = CooperationMind.objects.annotate(star_col=Exists(star), ).filter(star_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
else:
# 不返回数据
self.queryset = CooperationMind.objects.filter(creator_user_id=-100).values('id', 'coop_mind_name', "client_uuid", "data_format")
@@ -116,6 +119,9 @@ class JsMindLogView(APIView):
class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
"""
思维导图分享view
"""
serializer_class = CooperationMindShareSerializer
filter_backends = [DjangoFilterBackend]
filter_class = CooperationMindShareFilter
@@ -142,7 +148,7 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
serializer = CooperationMindSerializer(mind)
return build_response(data=serializer.data)
elif coop_mind_id is not None:
# 查询分享信息
# 获得分享链接
share = CooperationMindShare.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).first()
if share is None:
return build_response(code=CODE_FAILED, msg='分享不存在')
@@ -204,7 +210,10 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
def post(self, request):
user = request.user
post_body = request.POST
# 思维导图id
coop_mind_id = post_body.get('coop_mind_id')
# 操作类型
op_type = post_body.get('op_type')
if coop_mind_id is None:
return build_response(CODE_FAILED, msg="参数错误")