update
This commit is contained in:
@@ -19,6 +19,7 @@ urlpatterns = [
|
|||||||
path('list', JsMindView.as_view()), # 查询思维导图
|
path('list', JsMindView.as_view()), # 查询思维导图
|
||||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||||
path('share', JsMindShareView.as_view()), # 分享思维导图
|
path('share', JsMindShareView.as_view()), # 分享思维导图
|
||||||
|
path('4cbcb74630898f41fd0a', JsMindShareView.as_view()), # 通过分享链接查看
|
||||||
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
||||||
|
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
|
|||||||
@@ -32,10 +32,13 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
user = request.user
|
user = request.user
|
||||||
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).first()
|
# 查询导图详细 查看用户是否有权限(创建者)
|
||||||
|
mind = CooperationMind.objects.filter(id=pk, creator_user_id=user.id).first()
|
||||||
# 序列化
|
# 序列化
|
||||||
serializer = CooperationMindSerializer(mind)
|
serializer = CooperationMindSerializer(mind)
|
||||||
return build_response(data=serializer.data)
|
return build_response(data=serializer.data)
|
||||||
|
|
||||||
|
# 查询列表
|
||||||
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||||
# self.queryset = CooperationMind.objects.filter(creator_user_id=user.id).all()
|
# self.queryset = CooperationMind.objects.filter(creator_user_id=user.id).all()
|
||||||
return self.list(request, *args, **kwargs)
|
return self.list(request, *args, **kwargs)
|
||||||
@@ -101,11 +104,26 @@ class JsMindLogView(APIView):
|
|||||||
|
|
||||||
|
|
||||||
class JsMindShareView(LoginRequiredJSONMixin, APIView):
|
class JsMindShareView(LoginRequiredJSONMixin, APIView):
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
"""
|
||||||
|
通过链接即uuid获得分享的导图,默认有uuid就能进入界面查看
|
||||||
|
"""
|
||||||
|
share_uuid_hash = request.GET.get('h')
|
||||||
|
share_uuid = request.GET.get('u')
|
||||||
|
share = CooperationMindShare.objects.filter(share_uuid_hash=share_uuid_hash, share_uuid=share_uuid).first()
|
||||||
|
if share is None:
|
||||||
|
return build_response(code=CODE_FAILED, msg='分享不存在')
|
||||||
|
|
||||||
|
# 查询mind
|
||||||
|
mind = CooperationMind.objects.filter(id=share.coop_mind_id).first()
|
||||||
|
serializer = CooperationMindSerializer(mind)
|
||||||
|
return build_response(data=serializer.data)
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
"""
|
"""
|
||||||
分享脑图功能,只有创建人能分享
|
分享脑图功能,只有创建人能分享
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def post(self, request):
|
|
||||||
post_body = request.POST
|
post_body = request.POST
|
||||||
id = post_body.get('id')
|
id = post_body.get('id')
|
||||||
user = request.user
|
user = request.user
|
||||||
@@ -119,9 +137,10 @@ class JsMindShareView(LoginRequiredJSONMixin, APIView):
|
|||||||
share = CooperationMindShare.objects.filter(coop_mind_id=mind.id, operator_user_id=user.id).first()
|
share = CooperationMindShare.objects.filter(coop_mind_id=mind.id, operator_user_id=user.id).first()
|
||||||
if share is None:
|
if share is None:
|
||||||
uuid_str = str(uuid.uuid4()).replace('-', "")
|
uuid_str = str(uuid.uuid4()).replace('-', "")
|
||||||
share = CooperationMindShare(coop_mind_id=mind.id, coop_mind_name=mind.coop_mind_name, share_uuid=uuid_str, share_uuid_hash=-1, operator_user_id=user.id)
|
share_uuid_hash = -1
|
||||||
|
share = CooperationMindShare(coop_mind_id=mind.id, coop_mind_name=mind.coop_mind_name, share_uuid=uuid_str, share_uuid_hash=share_uuid_hash, operator_user_id=user.id)
|
||||||
share.save()
|
share.save()
|
||||||
return build_response(data=uuid_str)
|
return build_response(data={"u": uuid_str, "h": share_uuid_hash})
|
||||||
|
|
||||||
# 重复分享
|
# 重复分享
|
||||||
return build_response(code=DUPLICATE, data=share.share_uuid)
|
return build_response(code=DUPLICATE, data=share.share_uuid)
|
||||||
|
|||||||
@@ -175,8 +175,9 @@
|
|||||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
data: {'id': mind_id},
|
data: {'id': mind_id},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (resp) {
|
||||||
console.log(data)
|
console.log(resp)
|
||||||
|
console.log(`${window.location.protocol}//${window.location.host}/4cbcb74630898f41fd0a?u=${resp.data.u}&h=${resp.data.h}`)
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user