diff --git a/jsmindmulti/settings.py b/jsmindmulti/settings.py index eedec61..106dc11 100644 --- a/jsmindmulti/settings.py +++ b/jsmindmulti/settings.py @@ -154,3 +154,7 @@ AUTH_USER_MODEL = "server_auth.MindUser" AUTHENTICATION_BACKENDS = [ 'server_auth.lib.auth.AuthBackend', ] + +# session 设置 +SESSION_COOKIE_AGE = 60 * 30 # 设置过期时间10分钟,默认为两周 +SESSION_SAVE_EVERY_REQUEST = True diff --git a/server/views/mind_map.py b/server/views/mind_map.py index 728b4cc..8b3a4ff 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -53,8 +53,10 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView): def delete(self, request): # 删除 pk = request.POST.get('id') - res = CooperationMind.objects.filter(id=pk).delete() - return build_response() + user = request.user + res = CooperationMind.objects.filter(id=pk, creator=user.id).delete() + print(res) + return build_response(msg='删除成功') # Create your views here. diff --git a/static/html/dashboard.html b/static/html/dashboard.html index a9eae80..58efbb7 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -35,6 +35,10 @@ } } + function get_uu_id() { + return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16) + } + $(function () { /**界面初始化*/ view_init() @@ -259,12 +263,16 @@ let idx = 0 let row = $(`
`) results.forEach(function (item) { + const uuid = get_uu_id() const content = ` -
+
${item.coop_mind_name}
- ... - 编辑 + +
+ 编辑 + 删除 +
` @@ -286,6 +294,21 @@ async: false }); } + + /**删除导图*/ + function del_mind(mind_id, card_id) { + $.ajax({ + type: "delete", + url: "delete", + headers: {"X-CSRFToken": $.cookie("csrftoken")}, + data: {'id': mind_id}, + dataType: "json", + success: function (data) { + console.log(data) + }, + async: false + }); + } @@ -363,6 +386,22 @@
-->
+ + + + diff --git a/static/html/detail.html b/static/html/detail.html index 1ae0346..a183f5c 100644 --- a/static/html/detail.html +++ b/static/html/detail.html @@ -7,8 +7,8 @@