diff --git a/server/urls.py b/server/urls.py index ce452ac..b379124 100644 --- a/server/urls.py +++ b/server/urls.py @@ -1,6 +1,7 @@ from django.urls import path from server.views.mind_map import * +from server.views.jump import * from server.views.user import * from server.view_test import * from server_auth.lib.auth import * @@ -10,9 +11,9 @@ urlpatterns = [ path('test', test), # # --------------------------------------------------- + path('dashboard', to_dashboard), # path('', to_list), # 跳转列表界面 path('detail', to_detail), # 跳转详情界面 - path('dashboard', to_dashboard), # # --------------------------------------------------- path('create', JsMindView.as_view()), # 创建思维导图 diff --git a/server/views/jump.py b/server/views/jump.py new file mode 100644 index 0000000..5877d95 --- /dev/null +++ b/server/views/jump.py @@ -0,0 +1,23 @@ +from django.shortcuts import render + + +def to_dashboard(request): + """ + 界面 + """ + return render(request, "html/dashboard.html") + + +def to_list(request): + """ + 列表界面 + """ + return render(request, "html/list.html") + + +def to_detail(request): + """ + 详情页面 + """ + param = {'id': request.GET.get('id')} + return render(request, "html/detail.html", param) diff --git a/server/views/mind_map.py b/server/views/mind_map.py index 67538bc..fcbf067 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -1,6 +1,6 @@ from datetime import datetime as dt -from django.shortcuts import render +from django.contrib.auth.decorators import login_required from django_filters.rest_framework import DjangoFilterBackend from rest_framework.generics import * from rest_framework.views import APIView @@ -9,30 +9,6 @@ from server.filters import CooperationMindFilter from server.serializers import * from server.util.mix_util import build_response from server.util.pagination import NewPagination -from django.contrib.auth.decorators import login_required - - -def to_dashboard(request): - """ - 界面 - """ - print(request.user) - return render(request, "html/dashboard.html") - - -def to_list(request): - """ - 列表界面 - """ - return render(request, "html/list.html") - - -def to_detail(request): - """ - 详情页面 - """ - param = {'id': request.GET.get('id')} - return render(request, "html/detail.html", param) class JsMindView(ListAPIView): @@ -58,6 +34,7 @@ class JsMindView(ListAPIView): return build_response(data=serializer.data) return self.list(request, *args, **kwargs) + @login_required(login_url="dashboard") def post(self, request): """ 创建思维导图 @@ -69,6 +46,7 @@ class JsMindView(ListAPIView): mind.save() return build_response(data=mind.id) + @login_required(login_url="dashboard") def delete(self, request): # 删除 pk = request.POST.get('id') @@ -82,6 +60,7 @@ class JsMindLogView(APIView): 日志获取,快照保存 """ + @login_required(login_url="dashboard") def get(self, request): """ 查询日志 @@ -93,6 +72,7 @@ class JsMindLogView(APIView): log_list = CooperationMindLogSerializer(query_set, many=True) return build_response(data=log_list.data) + @login_required(login_url="dashboard") def post(self, request): """ 更新保存快照