diff --git a/server/models.py b/server/models.py index 8408e6d..5305b12 100644 --- a/server/models.py +++ b/server/models.py @@ -25,6 +25,7 @@ class CooperationMind(AbstractModel): deleted = models.BooleanField(verbose_name='是否标记为软删除', default=False) class_id = models.IntegerField(verbose_name='脑图所属课程id', null=False, blank=False, default=1) belong_to = models.TextField(verbose_name='所属课程-小组', default=json.dumps({'belong': []})) + comment_type = models.TextField(verbose_name='评论分类', default=json.dumps({'type': []})) class Meta: db_table = 'cooperation_mind' @@ -106,6 +107,7 @@ class StudentandTercher(AbstractModel): add_time = models.DateTimeField(verbose_name='添加时间', auto_now_add=True) class_info = models.CharField(verbose_name='课程信息', max_length=128, null=False, blank=False) class_status = models.CharField(verbose_name='课程状态', max_length=128, null=False, blank=False) + comment_type = models.TextField(verbose_name='评论分类', default=json.dumps({'type': []})) # class Task(AbstractModel): @@ -127,7 +129,8 @@ class Comment(models.Model): # 定义评论模型 comment_time = models.DateTimeField(auto_now_add=True, verbose_name='评论时间') pre_comment = models.ForeignKey('self', on_delete=models.DO_NOTHING, null=True, verbose_name='父评论id') # 父级评论,如果没有父级则为空NULL, "self"表示外键关联自己 - + # comment_type = models.CharField(verbose_name='评论类型', max_length=1024, null=False, blank=False) + # comment_type = models.TextField(verbose_name='评论类型', default=json.dumps({"type": []})) class Meta: db_table = 'comment_tb' verbose_name = '评论' diff --git a/server/urls.py b/server/urls.py index 629e046..0e07665 100644 --- a/server/urls.py +++ b/server/urls.py @@ -17,14 +17,14 @@ urlpatterns = [ path('2_d', to_detail), # 跳转详情界面 path('s_2_d', share_to_detail), # 从分享链接跳转详细界面 path('2_share', to_share), # 到分享界面 - path('2_baiban',to_baiban), # 到协作白板 - path('2_echart',to_echarts), # 到图标界面 - path('chat_room',to_chat_room), # 到聊天室界面 - path('reng_wu',to_rengwu), # 到任务界面 - path('ke_cheng',to_kecheng), # 到课程界面 - path('2_write',to_write), # 到协同边界页面 - path('2_pinglun',to_pinglun), # 评论 - path('2_admin',to_admin), # 跳转到管理员页面 + path('2_baiban', to_baiban), # 到协作白板 + path('2_echart', to_echarts), # 到图标界面 + path('chat_room', to_chat_room), # 到聊天室界面 + path('reng_wu', to_rengwu), # 到任务界面 + 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), # 到收藏界面 @@ -51,16 +51,15 @@ urlpatterns = [ path('logout', LogoutView.as_view()), # 用户登出 # --------------------------------------------------- - path('tercher_upload_somthings',TeacherView.as_view()), # 老师端上传一些文件 # --------------------------------------------------- path('post_task/', post_task, name='post_task'), 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('admin_fun/',admin_fun,name='admin_fun'), - path('liuyan_fun/',liuyan_fun,name='liuyan_fun') + path('come_kecheng/', come_kecheng, name='come_kecheng'), + 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 95fc023..edf18d7 100644 --- a/server/views/jump.py +++ b/server/views/jump.py @@ -1,10 +1,30 @@ import json from django.shortcuts import render -from server.models import Task,StudentandTercher,Comment,Liuyan +from server.models import Task,StudentandTercher,Comment,Liuyan,CooperationMind from server_auth.models import MindUser - +def front_comment(type): + front_datas = [] + if len(type) == 0: + return front_datas + for i in range(len(type)): + front_data = f""" +
""" + front_datas.append(front_data) + return front_datas def to_dashboard(request): """ 主界面 @@ -22,10 +42,14 @@ def to_baiban(request): return render(request, "html/baiban.html", param) def to_pinglun(request): + user = request.user test_date = request.GET.get('id') comment_list = Comment.objects.filter(pinglun_id=test_date) # 从数据库找出该文章的评论数据对象 + comment_type = CooperationMind.objects.get(id=test_date).comment_type # 找出对应的comment_type字段 + front_code = front_comment((json.loads(comment_type))['type']) param = {"path": test_date, - "comment_list": comment_list} + "comment_list": comment_list, + "front_code": front_code} print(test_date) return render(request, "html/commont.html", param) diff --git a/server/views/mind_map.py b/server/views/mind_map.py index f484d59..ed25710 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -131,6 +131,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView): data_format = 'node_tree' test_id = 0 for item1, item2 in zipped_lists: + comment_type = StudentandTercher.objects.get(class_name=item1).comment_type if (CooperationMind.objects.filter(coop_mind_name=str(item1 + "第" + str(item2) + "小组")).exists()): print("==========================================================") continue @@ -142,7 +143,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView): mind = CooperationMind(coop_mind_name=str(item1 + "第" + str(item2) + "小组"), client_uuid='', mind_log_id=-1, creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA, - data_format=data_format,belong_to=json.dumps({'belong':test})) + data_format=data_format,belong_to=json.dumps({'belong':test}),comment_type=comment_type) mind.save() test_id = mind.id return build_response(data=test_id) diff --git a/server_auth/lib/auth.py b/server_auth/lib/auth.py index f0f359b..cdfd446 100644 --- a/server_auth/lib/auth.py +++ b/server_auth/lib/auth.py @@ -162,8 +162,15 @@ def post_kecheng(request): tercher_name = request.POST.get("tercher_name") class_info = request.POST.get("class_info") class_status = request.POST.get("class_status") + comment_type = request.POST.get("comment_type") + print("===============================") + print(comment_type) + evaluations = comment_type.split(',') + print(evaluations) + default = json.dumps({'type': evaluations}) + 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) + tercher_name=tercher_name, class_info=class_info, class_status=class_status, comment_type=default) rengwu.save() return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'}) else: diff --git a/static/html/commont.html b/static/html/commont.html index 59fc5f9..1bbffa4 100644 --- a/static/html/commont.html +++ b/static/html/commont.html @@ -93,58 +93,9 @@
清晰性
- - - - - - - - - - -准确性
- - - - - - - - - - -稳定性
- - - - - - - - - - -可靠性
- - - - - - - - - - -老师名称
课程介绍
课程状态
课程评价标准(之间用逗号(,)隔开)
操作