diff --git a/server/models.py b/server/models.py
index 0b4223c..8408e6d 100644
--- a/server/models.py
+++ b/server/models.py
@@ -132,3 +132,16 @@ class Comment(models.Model): # 定义评论模型
db_table = 'comment_tb'
verbose_name = '评论'
verbose_name_plural = verbose_name
+
+class Liuyan(models.Model): # 定义留言板模型
+ # article = models.ForeignKey(to=Article, on_delete=models.DO_NOTHING, verbose_name='评论文章')
+ liuyan_id = models.IntegerField(verbose_name='留言给谁了')
+ liuyan_content = models.TextField(verbose_name='留言内容')
+ user = models.ForeignKey(MindUser, on_delete=models.CASCADE) #留言人id
+ liuyan_time = models.DateTimeField(auto_now_add=True, verbose_name='留言时间')
+
+ class Meta:
+ db_table = 'liuyan_tb'
+ verbose_name = '留言'
+ verbose_name_plural = verbose_name
+
diff --git a/server/urls.py b/server/urls.py
index e6b174b..629e046 100644
--- a/server/urls.py
+++ b/server/urls.py
@@ -24,11 +24,15 @@ urlpatterns = [
path('ke_cheng',to_kecheng), # 到课程界面
path('2_write',to_write), # 到协同边界页面
path('2_pinglun',to_pinglun), # 评论
+ path('2_admin',to_admin), # 跳转到管理员页面
+
path('2_star', to_star), # 到收藏界面
path('2_recycle', to_recycle), # 回收站
- path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志操作
+ path('2_information', to_information), # 个人信息
+ path('2_liuyan', to_liuyan), # 留言
+ path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志操作
# ---------------------------------------------------
path('create', JsMindView.as_view()), # 创建思维导图
path('list', JsMindView.as_view()), # 查询思维导图
@@ -55,6 +59,8 @@ urlpatterns = [
path('post_kecheng/', post_kecheng, name='post_kecheng'),
path('come_kecheng/',come_kecheng, name='come_kecheng'),
- path('comment_control/',comment_control,name='comment_control') #提交评论处理的路由
+ path('comment_control/',comment_control,name='comment_control'), #提交评论处理的路由
+ path('admin_fun/',admin_fun,name='admin_fun'),
+ path('liuyan_fun/',liuyan_fun,name='liuyan_fun')
]
diff --git a/server/views/jump.py b/server/views/jump.py
index 6d651bd..27d5907 100644
--- a/server/views/jump.py
+++ b/server/views/jump.py
@@ -1,7 +1,7 @@
import json
from django.shortcuts import render
-from server.models import Task,StudentandTercher,Comment
+from server.models import Task,StudentandTercher,Comment,Liuyan
from server_auth.models import MindUser
@@ -29,6 +29,14 @@ def to_pinglun(request):
print(test_date)
return render(request, "html/commont.html", param)
+def to_admin(request):
+ username = request.user
+ # supper = MindUser.objects.filter(username=username).type_t_or_s
+ if username.type_t_or_s == 3:
+ datas = MindUser.objects.filter(type_t_or_s=2)
+ return render(request, "html/admin.html",{"datas":datas})
+ else:
+ return render(request, "html/dashboard.html")
def to_share(request):
"""
分享页面
@@ -115,4 +123,31 @@ def teacher_login(request):
详情页面
"""
param = {'id': request.GET.get('id')}
- return render(request, "html/login.html", param)
\ No newline at end of file
+ return render(request, "html/login.html", param)
+
+def to_information(request):
+ """
+ 个人信息页面
+ """
+ param = {"page": "recycle"}
+ username = request.user
+ datas = MindUser.objects.filter(username=username)
+ xiaozu = MindUser.objects.get(username=username).select_xiaozu
+ kz = MindUser.objects.get(username=username).select_class
+ xiaozu = json.loads(xiaozu)['xiaozu']
+ kc = json.loads(kz)['class']
+ test = zip(kc, xiaozu)
+ it3 = []
+ for it1, it2 in test:
+ it3.append(str(it1) + "课程" + str(it2) + "小组")
+
+ return render(request, "html/informations.html", {"datas":datas,"it3":it3})
+
+def to_liuyan(request):
+ """
+ 留言板页面
+ """
+ # param = {"page": "recycle"}
+ datas = MindUser.objects.all()
+ liuyans = Liuyan.objects.filter(liuyan_id=request.user.id)
+ return render(request, "html/liuyan.html", {"datas":datas,"liuyans":liuyans})
diff --git a/server_auth/lib/auth.py b/server_auth/lib/auth.py
index cc8bd14..f0f359b 100644
--- a/server_auth/lib/auth.py
+++ b/server_auth/lib/auth.py
@@ -13,7 +13,7 @@ from django.shortcuts import render
from server.taskform import TaskForm
from django.utils import timezone
-from server.models import Task,StudentandTercher,MindUser
+from server.models import Task,StudentandTercher,MindUser,Liuyan
from server.serializers import *
import json
@@ -59,6 +59,11 @@ class LoginView(APIView):
# 记住登录状态
login(request, user)
return build_response(msg='学生端登录成功')
+ elif user.is_active and user.type_t_or_s == 3:
+ # 记住登录状态
+ # 记住登录状态
+ login(request, user)
+ return build_response(msg='管理员登录成功')
else:
return build_response(code=CODE_FAILED, msg='登录失败')
else:
@@ -134,10 +139,8 @@ class TeacherView(LoginRequiredJSONMixin,APIView):
def post_task(request):
- if request.method == 'POST':
- if request.user.type_t_or_s == 2:
- return render(request, 'html/error.html')
- else:
+ if request.user.type_t_or_s == 1:
+ if request.method == 'POST':
start_time = timezone.now()
title = request.POST.get("title")
description = request.POST.get("description")
@@ -145,26 +148,29 @@ def post_task(request):
rengwu = Task(title=title, description=description, publish_time=start_time, deadline=end_time,publisher=request.user)
rengwu.save()
return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'})
+ else:
+ return render(request, 'html/post_task.html')
else:
- return render(request, 'html/post_task.html')
+ return render(request, 'html/dashboard.html')
def post_kecheng(request):
- if request.method == 'POST':
- if request.user.type_t_or_s == 2:
- return render(request, 'html/error.html')
- else:
+ if request.user.type_t_or_s == 1:
+ if request.method == 'POST':
add_time = timezone.now()
class_id = request.POST.get("class_id")
class_name = request.POST.get("class_name")
tercher_name = request.POST.get("tercher_name")
class_info = request.POST.get("class_info")
class_status = request.POST.get("class_status")
- rengwu = StudentandTercher(add_time=add_time,class_id=class_id, class_name=class_name,
+ rengwu = StudentandTercher(add_time=add_time, class_id=class_id, class_name=class_name,
tercher_name=tercher_name, class_info=class_info, class_status=class_status)
rengwu.save()
return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'})
+ else:
+ return render(request, 'html/post_kecheng.html')
else:
- return render(request, 'html/post_kecheng.html')
+ return render(request, 'html/dashboard.html')
+
def come_kecheng(request):
if request.method == 'POST':
@@ -206,4 +212,25 @@ def comment_control(request): # 提交评论的处理函数
return JsonResponse(article, safe=False) # JsonResponse返回JSON字符串,自动序列化,如果不是字典类型,则需要添加safe参数为False
+def admin_fun(request): # 提交评论的处理函数
+ if request.method == 'POST':
+ id = request.POST.get('user_id')
+ MindUser.objects.filter(id=id).update(type_t_or_s=1)
+ print(id)
+ return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '修改成功'})
+ else:
+ return http.JsonResponse({'code': CODE_FAILED, 'msg': '修改失败'})
+
+def liuyan_fun(request): # 提交留言的处理函数
+ if request.method == 'POST':
+ username = request.user.username
+ userid = MindUser.objects.get(username=username).id
+ print("-----------------")
+ print(userid)
+ id = request.POST.get('user_id')
+ liuyan = request.POST.get('liuyan_con')
+ Liuyan.objects.create(liuyan_id=id,user_id=userid,liuyan_content=liuyan,liuyan_time=timezone.now())
+ return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '留言成功'})
+ else:
+ return http.JsonResponse({'code': CODE_FAILED, 'msg': '修改失败'})
diff --git a/server_auth/models.py b/server_auth/models.py
index ff539fa..d111f2c 100644
--- a/server_auth/models.py
+++ b/server_auth/models.py
@@ -11,6 +11,7 @@ class MindUser(AbstractUser):
sex_type = (
(1, "老师"),
(2, "学生"),
+ (3, "管理员")
)
type_t_or_s = models.SmallIntegerField(verbose_name="学生身份还是老师身份", choices=sex_type, default="2")
class_id = models.IntegerField(verbose_name='课程ID', null=True, blank=True)
diff --git a/static/html/admin.html b/static/html/admin.html
new file mode 100644
index 0000000..de622c6
--- /dev/null
+++ b/static/html/admin.html
@@ -0,0 +1,658 @@
+
+
+
+
+
+ 协作学习投入智能干预平台(学生端)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ user.id }}
+ {{ page }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ admin管理员界面
+
+
+ 用户名 |
+ 加入时间 |
+ 操作 |
+
+ {% for data in datas %}
+
+
+ | {{data.username}} |
+ {{data.date_joined}} |
+
+ |
+
+
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/static/html/baiban.html b/static/html/baiban.html
index 063e91b..73f77ef 100644
--- a/static/html/baiban.html
+++ b/static/html/baiban.html
@@ -588,9 +588,27 @@
课程发布页面
+
+
+
+
+ 个人信息
+
-
+
+
+ 管理员页面
+
+
+
+
+
+ 留言板
+
+
+
+
回收站
diff --git a/static/html/dashboard.html b/static/html/dashboard.html
index fe0e630..e80dba3 100644
--- a/static/html/dashboard.html
+++ b/static/html/dashboard.html
@@ -647,6 +647,24 @@
课程发布页面
+
+
+
+
+ 个人信息
+
+
+
+
+
+ 管理员页面
+
+
+
+
+
+ 留言板
+
@@ -658,7 +676,6 @@
-
@@ -695,4 +712,24 @@
window.feather.replace();
}
+