取消收藏等
This commit is contained in:
@@ -37,12 +37,17 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
|
|
||||||
print('list current user: %s' % user)
|
print('list current user: %s' % user)
|
||||||
if pk is not None:
|
if pk is not None:
|
||||||
# 查询导图详细 查看用户是否有权限(创建者)
|
# 查询导图详细 查看用户是否有权限
|
||||||
mind = CooperationMind.objects.filter(id=pk, creator_user_id=user.id).first()
|
sql = """
|
||||||
if mind is None:
|
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="无权限")
|
return build_response(code=CODE_FAILED, msg="无权限")
|
||||||
# 序列化
|
# 序列化
|
||||||
serializer = CooperationMindSerializer(mind)
|
serializer = CooperationMindSerializer(mind[0])
|
||||||
return build_response(data=serializer.data)
|
return build_response(data=serializer.data)
|
||||||
|
|
||||||
# 查询列表
|
# 查询列表
|
||||||
@@ -237,15 +242,14 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
if star is None:
|
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 = CooperationMindStar(operator_user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||||
star.save()
|
star.save()
|
||||||
return build_response()
|
return build_response(msg="收藏成功")
|
||||||
|
|
||||||
def delete(self, request):
|
def delete(self, request):
|
||||||
"""
|
"""
|
||||||
取消收藏
|
取消收藏
|
||||||
"""
|
"""
|
||||||
print('dlete')
|
|
||||||
post_body = request.POST
|
post_body = request.POST
|
||||||
user = request.user
|
user = request.user
|
||||||
coop_mind_id = post_body.get('coop_mind_id')
|
coop_mind_id = post_body.get('coop_mind_id')
|
||||||
CooperationMindStar.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).delete()
|
CooperationMindStar.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).delete()
|
||||||
return build_response()
|
return build_response(msg="取消收藏,操作成功")
|
||||||
|
|||||||
@@ -152,7 +152,7 @@
|
|||||||
const container = $('#pagination_div')
|
const container = $('#pagination_div')
|
||||||
/**计算页数*/
|
/**计算页数*/
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
container.empty()
|
container.html(`<p class="text-center">无数据</p>`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-2
@@ -35,6 +35,7 @@
|
|||||||
this.jm = null
|
this.jm = null
|
||||||
this.coop_mind_id = null
|
this.coop_mind_id = null
|
||||||
this.coop_mind_log_id = null
|
this.coop_mind_log_id = null
|
||||||
|
/**是否通过分享链接访问*/
|
||||||
this.from_share = null
|
this.from_share = null
|
||||||
}
|
}
|
||||||
// prototype
|
// prototype
|
||||||
@@ -144,8 +145,6 @@
|
|||||||
/**收藏或者取消收藏*/
|
/**收藏或者取消收藏*/
|
||||||
star: function () {
|
star: function () {
|
||||||
const coop_mind_id = this.coop_mind_id
|
const coop_mind_id = this.coop_mind_id
|
||||||
console.log(`this.from_share:${this.from_share}`)
|
|
||||||
|
|
||||||
// ajax start
|
// ajax start
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
@@ -159,8 +158,27 @@
|
|||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
// ajax end
|
// ajax end
|
||||||
|
},
|
||||||
|
/**取消收藏*/
|
||||||
|
un_star: function () {
|
||||||
|
const coop_mind_id = this.coop_mind_id
|
||||||
|
// ajax start
|
||||||
|
$.ajax({
|
||||||
|
type: "delete",
|
||||||
|
url: "star",
|
||||||
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
|
data: {'coop_mind_id': coop_mind_id},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (resp) {
|
||||||
|
common_alert(resp.msg)
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
// ajax end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***/
|
||||||
$(function () {
|
$(function () {
|
||||||
const xxObj = new fetch()
|
const xxObj = new fetch()
|
||||||
xxObj.loadMind()
|
xxObj.loadMind()
|
||||||
@@ -173,6 +191,7 @@
|
|||||||
<div style="position: absolute;top: 0px;z-index: 1000;cursor: pointer;" onclick="xxObj.collapse_all()"><span data-feather="folder-minus"></span><span class="un_selected">折叠</span></div>
|
<div style="position: absolute;top: 0px;z-index: 1000;cursor: pointer;" onclick="xxObj.collapse_all()"><span data-feather="folder-minus"></span><span class="un_selected">折叠</span></div>
|
||||||
<div style="position: absolute;top: 0px;left:80px;z-index: 1000;cursor: pointer;" onclick="xxObj.expand_all()"><span data-feather="folder-plus"></span><span class="un_selected">展开</span></div>
|
<div style="position: absolute;top: 0px;left:80px;z-index: 1000;cursor: pointer;" onclick="xxObj.expand_all()"><span data-feather="folder-plus"></span><span class="un_selected">展开</span></div>
|
||||||
<div style="position: absolute;top: 0px;left:160px;z-index: 1000;cursor: pointer;" onclick="xxObj.star()"><span data-feather="star"></span><span class="un_selected">收藏</span></div>
|
<div style="position: absolute;top: 0px;left:160px;z-index: 1000;cursor: pointer;" onclick="xxObj.star()"><span data-feather="star"></span><span class="un_selected">收藏</span></div>
|
||||||
|
<div style="position: absolute;top: 0px;left:240px;z-index: 1000;cursor: pointer;" onclick="xxObj.un_star()"><span data-feather="arrow-up-circle"></span><span class="un_selected">取消收藏</span></div>
|
||||||
<h3 id="h1" style="text-align: center;max-height: 40px;"></h3>
|
<h3 id="h1" style="text-align: center;max-height: 40px;"></h3>
|
||||||
<div id="jsmind_container"></div>
|
<div id="jsmind_container"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user