update
This commit is contained in:
@@ -19,6 +19,7 @@ urlpatterns = [
|
||||
path('list', JsMindView.as_view()), # 查询思维导图
|
||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||
path('share', JsMindShareView.as_view()), # 分享思维导图
|
||||
path('4cbcb74630898f41fd0a', JsMindShareView.as_view()), # 通过分享链接查看
|
||||
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
||||
|
||||
# ---------------------------------------------------
|
||||
|
||||
@@ -32,10 +32,13 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
user = request.user
|
||||
print('list current user: %s' % user)
|
||||
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)
|
||||
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).all()
|
||||
return self.list(request, *args, **kwargs)
|
||||
@@ -101,11 +104,26 @@ class JsMindLogView(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):
|
||||
"""
|
||||
分享脑图功能,只有创建人能分享
|
||||
"""
|
||||
post_body = request.POST
|
||||
id = post_body.get('id')
|
||||
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()
|
||||
if share is None:
|
||||
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()
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user