取消收藏等
This commit is contained in:
@@ -37,12 +37,17 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
|
||||
print('list current user: %s' % user)
|
||||
if pk is not None:
|
||||
# 查询导图详细 查看用户是否有权限(创建者)
|
||||
mind = CooperationMind.objects.filter(id=pk, creator_user_id=user.id).first()
|
||||
if mind is None:
|
||||
# 查询导图详细 查看用户是否有权限
|
||||
sql = """
|
||||
select * from cooperation_mind mind where id=%s and mind.creator_user_id=%s
|
||||
union all select m1.* from cooperation_mind m1 join cooperation_mind_share sh on sh.coop_mind_id = m1.id where m1.id=%s and sh.operator_user_id =%s
|
||||
union all select m1.* from cooperation_mind m1 join cooperation_mind_star st on st.coop_mind_id = m1.id where m1.id=%s and st.operator_user_id =%s
|
||||
""" % (pk, user.id, pk, user.id, pk, user.id)
|
||||
mind = CooperationMind.objects.raw(sql)
|
||||
if len(mind) is None:
|
||||
return build_response(code=CODE_FAILED, msg="无权限")
|
||||
# 序列化
|
||||
serializer = CooperationMindSerializer(mind)
|
||||
serializer = CooperationMindSerializer(mind[0])
|
||||
return build_response(data=serializer.data)
|
||||
|
||||
# 查询列表
|
||||
@@ -237,15 +242,14 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
|
||||
if star is None:
|
||||
star = CooperationMindStar(operator_user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||
star.save()
|
||||
return build_response()
|
||||
return build_response(msg="收藏成功")
|
||||
|
||||
def delete(self, request):
|
||||
"""
|
||||
取消收藏
|
||||
"""
|
||||
print('dlete')
|
||||
post_body = request.POST
|
||||
user = request.user
|
||||
coop_mind_id = post_body.get('coop_mind_id')
|
||||
CooperationMindStar.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).delete()
|
||||
return build_response()
|
||||
return build_response(msg="取消收藏,操作成功")
|
||||
|
||||
Reference in New Issue
Block a user