From 092ececc96b12f491b1c9f5d1025a7bf2d63e8e5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 09:26:26 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=AF=95=E8=AE=BE?= =?UTF-8?q?=E9=80=89=E9=A2=98=E6=9D=83=E9=99=90=E4=B8=8D=E5=A4=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commons_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index 1f6dce053..fa5e14dc1 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -44,8 +44,8 @@ class CommonsController < ApplicationController def validate_power code = case params[:object_type].strip - when 'message' - if current_user.course_identity(@object.board.course) >= 5 && @object.author != current_user + when 'message', 'journals_for_message' + if current_user.course_identity(@object.board.course) >= Course::STUDENT && @object.author != current_user 403 else 200 From 036037df2246bff68671d2efb6400bdccad6f1d2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 09:31:49 +0800 Subject: [PATCH 02/47] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commons_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index fa5e14dc1..a23d4dba7 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -44,12 +44,18 @@ class CommonsController < ApplicationController def validate_power code = case params[:object_type].strip - when 'message', 'journals_for_message' + when 'message' if current_user.course_identity(@object.board.course) >= Course::STUDENT && @object.author != current_user 403 else 200 end + when 'journals_for_message' + if current_user.course_identity(@object.jour.course) >= Course::STUDENT && @object.user != current_user + 403 + else + 200 + end else current_user.admin? ? 200 : 403 end From 37737fe7866d8aa83624ca058536cbeb274b7370 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 11 Jul 2019 09:48:24 +0800 Subject: [PATCH 03/47] =?UTF-8?q?FIX=20=E5=A4=84=E7=90=86=E7=82=B9?= =?UTF-8?q?=E8=B5=9E=E6=95=B0=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 5 ++++- app/models/message.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index f684b27f3..0c61e2b69 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -87,7 +87,10 @@ class MessagesController < ApplicationController end def show - @message = Message.includes(:attachments, :message_detail, :children, :author => :user_extension, :board => [{course: :board_course_modules}]).find_by_id params[:id] + @message = Message.includes(:attachments, :message_detail, + :children, :author => :user_extension, + :board => [{course: :board_course_modules}]) + .find_by_id params[:id] return normal_status(-2, "ID为#{params[:id]}的帖子不存在") if @message.nil? @attachment_size = @message.attachments.size diff --git a/app/models/message.rb b/app/models/message.rb index 6b41cdd95..7588ddc2a 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -73,7 +73,7 @@ class Message < ApplicationRecord # 包含二级回复的总点赞数 def total_praises_count - descendants.sum(:praises_count) + praises_count + descendants.sum(:praises_count) end # 包含二级回复数的总回复数 From 79d1e96e36e8d25bcf996da5853989614834b479 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 09:57:52 +0800 Subject: [PATCH 04/47] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index b8a5ec53c..56fe8fc35 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -44,7 +44,7 @@ class ShixunsController < ApplicationController ## 搜索关键字 匹配关卡名, 用户名, 实训名 和 空格多搜索 if params[:keyword].present? keyword = params[:keyword].strip - @shixuns = @shixuns.joins(:users, challenges: :challenge_tags). + @shixuns = @shixuns.joins(:user, challenges: :challenge_tags). where("challenge_tags.name like '%#{keyword}%' or challenges.subject like '%#{keyword}%' or concat(lastname, firstname) like '%#{keyword}%' From 3a0e19b48bfdea0deddcdfd46ad85430ab579396 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 10:18:50 +0800 Subject: [PATCH 05/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 56fe8fc35..20ff348a6 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -45,10 +45,11 @@ class ShixunsController < ApplicationController if params[:keyword].present? keyword = params[:keyword].strip @shixuns = @shixuns.joins(:user, challenges: :challenge_tags). - where("challenge_tags.name like '%#{keyword}%' - or challenges.subject like '%#{keyword}%' - or concat(lastname, firstname) like '%#{keyword}%' - or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct + where("challenge_tags.name like :keyword + or challenges.subject like :keyword + or concat(lastname, firstname) like :keyword + or shixuns.name like :name", + keyword: "%#{keyword}%", name: "%#{keyword.split(" ").join("%")}%").distinct end ## 筛选 状态 @@ -66,17 +67,17 @@ class ShixunsController < ApplicationController bsort = params[:sort] || 'desc' case params[:order_by] || 'publish_time' when 'new' - @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.created_at #{bsort}") + @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.created_at #{bsort}") when 'hot' - @shixuns = @shixuns.order("shixuns.status = 2 desc, myshixuns_count #{bsort}") + @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.myshixuns_count #{bsort}") when 'mine' - @shixuns = @shixuns.order("shixuns.created_at #{bsort}") + @shixuns = @shixuns.reorder("shixuns.created_at #{bsort}") else - @shixuns = @shixuns.order("shixuns.status = 2 desc, publish_time #{bsort}") + @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") end - - @total_count = @shixuns.count + # 用id计数会快10MS左右。 + @total_count = @shixuns.count("shixuns.id") ## 分页参数 page = params[:page] || 1 From aaa0513ad5fa6fa6ee59d458a1087a6aea54ae08 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 10:38:05 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 20ff348a6..714351561 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -67,16 +67,16 @@ class ShixunsController < ApplicationController bsort = params[:sort] || 'desc' case params[:order_by] || 'publish_time' when 'new' - @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.created_at #{bsort}") + @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.created_at #{bsort}") when 'hot' - @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.myshixuns_count #{bsort}") + @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.myshixuns_count #{bsort}") when 'mine' - @shixuns = @shixuns.reorder("shixuns.created_at #{bsort}") + @shixuns = @shixuns.order("shixuns.created_at #{bsort}") else - @shixuns = @shixuns.reorder("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") + @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") end - # 用id计数会快10MS左右。 + # 用id计数会快10+MS左右,随着数据的增加,性能会提升一些。 @total_count = @shixuns.count("shixuns.id") ## 分页参数 From c9d4714ef8fb0e42ff6fd41d17e1cadc96dd1cad Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 10:45:30 +0800 Subject: [PATCH 07/47] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/models/shixun.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 714351561..c237da5e2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -76,7 +76,7 @@ class ShixunsController < ApplicationController @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") end - # 用id计数会快10+MS左右,随着数据的增加,性能会提升一些。 + # 用id计数会快10+MS左右,对于搜索的内容随着数据的增加,性能会提升一些。 @total_count = @shixuns.count("shixuns.id") ## 分页参数 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index cb305efaf..afad10397 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -52,7 +52,7 @@ class Shixun < ApplicationRecord end } - scope :visible, -> { where("status != -1") } + scope :visible, -> { where.not(status: -1) } scope :published, lambda{ where(status: 2) } scope :unhidden, lambda{ where(hidden: 0, status: 2) } scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) } From 795d4ecf71f25ffa990f94285f29d36f0cd234ab Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 10:49:03 +0800 Subject: [PATCH 08/47] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=92=8C=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 6 ++++-- app/helpers/graduation_tasks_helper.rb | 2 +- app/models/graduation_work.rb | 2 +- app/views/graduation_tasks/index.json.jbuilder | 8 ++++---- app/views/graduation_tasks/tasks_list.json.jbuilder | 5 +++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index c3b73ad20..910299fd0 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -37,7 +37,7 @@ class GraduationTasksController < ApplicationController @all_count = @course.graduation_tasks.size @published_count = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").size @task_count = @tasks.size - @tasks = @tasks.reorder("#{default_order}").page(page).per(15).includes(:graduation_works, course: [course_members: :teacher_course_groups]) + @tasks = @tasks.reorder("#{default_order}").page(page).per(15).includes(:graduation_works) end # 任务问答 @@ -72,7 +72,7 @@ class GraduationTasksController < ApplicationController @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension]) @all_work_count = @work_list.count - @teachers = @course.teachers.where.not(user_id: current_user.id) + @teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user) # 教师评阅搜索 0: 未评, 1 已评 unless params[:teacher_comment].blank? graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id) @@ -123,6 +123,8 @@ class GraduationTasksController < ApplicationController @work_count = @work_list.count @work_excel = @work_list @work_list = @work_list.page(page).per(limit) + @students = @course.students + @assign_power = @user_course_identity < Course::STUDENT && @task.cross_comment && @task.comment_status == 2 if params[:format] == "xlsx" complete_works = @work_excel.where("work_status > 0").size diff --git a/app/helpers/graduation_tasks_helper.rb b/app/helpers/graduation_tasks_helper.rb index b9039544d..2bc059a55 100644 --- a/app/helpers/graduation_tasks_helper.rb +++ b/app/helpers/graduation_tasks_helper.rb @@ -67,7 +67,7 @@ module GraduationTasksHelper # 作品数统计:type: 1 已提交 0 未提交 def grduationwork_count task, type works = task.graduation_works - type == 1 ? works.where("work_status !=?", 0).size : works.where("work_status =?", 0).size + type == 1 ? works.select{|work| work.work_status != 0}.size : works.select{|work| work.work_status == 0}.size end # 普通/分组 作业作品状态数组 diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index 093e409a9..235bfcac6 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -68,7 +68,7 @@ class GraduationWork < ApplicationRecord # 作品是否能够分配指导老师 def assign_power?(course_identity) - course_identity < Course::STUDENT && self.graduation_task.cross_comment.present? && self.graduation_task.comment_status == 2 + course_identity < Course::STUDENT && graduation_task.cross_comment && graduation_task.comment_status == 2 end # 老师评阅分 diff --git a/app/views/graduation_tasks/index.json.jbuilder b/app/views/graduation_tasks/index.json.jbuilder index 7fcececd9..a6540555d 100644 --- a/app/views/graduation_tasks/index.json.jbuilder +++ b/app/views/graduation_tasks/index.json.jbuilder @@ -1,10 +1,6 @@ json.course_identity @identity json.course_public @course.is_public == 1 json.is_end @course.is_end -json.all_count @all_count -json.published_count @published_count -json.unpublished_count @all_count - @published_count -json.task_count @task_count json.tasks @tasks.each do |task| # task_private = @identity > Course::STUDENT && !task.is_public @@ -29,3 +25,7 @@ json.tasks @tasks.each do |task| end end +json.all_count @all_count +json.published_count @published_count +json.unpublished_count @all_count - @published_count +json.task_count @task_count diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index 7588b6b6e..ac5aa050e 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -34,6 +34,7 @@ if @task.published? || @user_course_identity < Course::STUDENT json.work_count @work_count json.all_work_count @all_work_count end + # 学生数据 json.work_lists do json.array! @work_list do |work| @@ -41,7 +42,7 @@ if @task.published? || @user_course_identity < Course::STUDENT json.user_id work.user.id json.name work.user.real_name json.student_id work.user.student_id - json.class_grouping_name work.class_grouping_name + json.class_grouping_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name) json.ultimate_score work.ultimate_score if @task.have_grouping? json.grouping_name work.grouping_name @@ -58,7 +59,7 @@ if @task.published? || @user_course_identity < Course::STUDENT end json.late_penalty work.late_penalty if @task.allow_late json.final_score work_final_score work, @current_user, @user_course_identity - json.assign work.assign_power?(@user_course_identity) + json.assign @assign_power json.view_work @view_work || @current_user.id == work.user_id end end From ef5da1ea0ee164dd20559583be61b2982e5f8971 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 11:07:36 +0800 Subject: [PATCH 09/47] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 910299fd0..cadac75be 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -112,7 +112,7 @@ class GraduationTasksController < ApplicationController # 排序 rorder = params[:order].blank? ? "updated_at" : params[:order] b_order = params[:b_order].blank? ? "desc" : params[:b_order] - if rorder == "created_at" || rorder == "work_score" + if rorder == "updated_at" || rorder == "work_score" @work_list = @work_list.order("graduation_works.#{rorder} #{b_order}") elsif rorder == "student_id" @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") From 32ecb2ed6dd47cbfe1a1404326d157b7c6f3f6fc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 11:19:48 +0800 Subject: [PATCH 10/47] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index cadac75be..9b62f7dbd 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -110,9 +110,9 @@ class GraduationTasksController < ApplicationController end # 排序 - rorder = params[:order].blank? ? "updated_at" : params[:order] + rorder = params[:order].blank? ? "update_time" : params[:order] b_order = params[:b_order].blank? ? "desc" : params[:b_order] - if rorder == "updated_at" || rorder == "work_score" + if rorder == "update_time" || rorder == "work_score" @work_list = @work_list.order("graduation_works.#{rorder} #{b_order}") elsif rorder == "student_id" @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") From f8ba7399df12316a009789b2e735f51e1f6f7fb0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 11:23:54 +0800 Subject: [PATCH 11/47] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=9A=84'=E6=9C=80=E7=83=AD'tab=E7=9A=84?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 22 ++++++++++++---------- app/models/subject.rb | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index bb7059af6..34f9c2f5a 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -22,17 +22,17 @@ class SubjectsController < ApplicationController # 最热排序 if reorder == "myshixun_count" if select - @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, - subjects.shixuns_count, COUNT(myshixuns.id) AS myshixun_member_count FROM myshixuns, stage_shixuns, subjects - WHERE myshixuns.shixun_id = stage_shixuns.shixun_id AND stage_shixuns.subject_id = subjects.id - AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' - AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, + subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns + on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where + subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' + AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") else - @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, - subjects.shixuns_count, COUNT(myshixuns.id) AS myshixun_member_count FROM myshixuns, stage_shixuns, subjects - WHERE myshixuns.shixun_id = stage_shixuns.shixun_id AND stage_shixuns.subject_id = subjects.id - AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' - GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, + subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns + on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where + `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' + GROUP BY subjects.id ORDER BY myshixun_member_count DESC") end else # 我的路径 @@ -68,6 +68,8 @@ class SubjectsController < ApplicationController @subjects = @subjects.page(page).per(limit).includes(:shixuns) else @subjects = @subjects[offset, limit] + subject_ids = @subjects.pluck(:id) + @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns) end end diff --git a/app/models/subject.rb b/app/models/subject.rb index ced610377..66ac41c40 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -31,7 +31,7 @@ class Subject < ApplicationRecord # 挑战过路径的成员数 def member_count - shixuns.sum(:myshixuns_count) + shixuns.pluck(:myshixuns_count).sum end def all_score From 4032174a104544866ecbadb757bccd8b25cec70a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 11:26:23 +0800 Subject: [PATCH 12/47] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 34f9c2f5a..20b28121f 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -65,11 +65,11 @@ class SubjectsController < ApplicationController @total_count = @subjects.size if reorder != "myshixun_count" - @subjects = @subjects.page(page).per(limit).includes(:shixuns) + @subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire) else @subjects = @subjects[offset, limit] subject_ids = @subjects.pluck(:id) - @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns) + @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, :repertoire) end end From bd41f2904fdbe7198af52251c0995252b3821a4f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 14:28:27 +0800 Subject: [PATCH 13/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 9 ++++++--- app/models/challenge.rb | 2 ++ app/models/discuss.rb | 1 + app/views/discusses/_discuss.json.jbuilder | 3 ++- ...0190711062033_modify_challenge_id_for_discusses.rb | 11 +++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20190711062033_modify_challenge_id_for_discusses.rb diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index db3047e74..f5de277b4 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -9,15 +9,18 @@ class DiscussesController < ApplicationController # 总数,分页使用 if current_user.admin? @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count - @discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, - :root_id => nil).includes(:user, :praise_treads).offset(offset) + disscusses = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, + :root_id => nil).joins(challenge: :games) + .where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") else disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and (hidden = :hidden or user_id = :user_id)", {dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id}) + .joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") @disscuss_count = disscusses.count - @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) end + @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) + @manger = @container.has_manager?(current_user) @current_user = current_user end diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 7afb919a0..4d136a718 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -16,6 +16,8 @@ class Challenge < ApplicationRecord # 参考答案 has_many :challenge_answers, :dependent => :destroy has_many :exercise_bank_shixun_challenges, :dependent => :destroy + # 回复 + has_many :discusses, :dependent => :destroy # acts_as_attachable diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 737a89ec1..00e3209c0 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -9,6 +9,7 @@ class Discuss < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy has_one :praise_tread_cache, as: :object, dependent: :destroy + belongs_to :challenge after_create :send_tiding scope :children, -> (discuss_id){ where(parent_id: discuss_id).includes(:user).reorder(created_at: :asc) } diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index 992466559..ee9484131 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -9,7 +9,8 @@ json.shixun_id discuss.dis_id json.hidden discuss.hidden json.manage current_user.manager_of_shixun?(container) json.reward discuss.reward -json.game_url discuss.game_url(container, current_user) +#json.game_url discuss.game_url(container, current_user) +json.game_url "/tasks/#{discuss.identifier}" if @manger # 主贴和回复有一些不同点 if discuss.parent_id json.can_delete discuss.can_deleted?(current_user) diff --git a/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb b/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb new file mode 100644 index 000000000..86052375b --- /dev/null +++ b/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb @@ -0,0 +1,11 @@ +class ModifyChallengeIdForDiscusses < ActiveRecord::Migration[5.2] + def change + discusses = Discuss.where(challenge_id: nil) + discusses.each do |dis| + challenge_id = Shixun.find(dis.dis_id).challenges.first.id + dis.update_column(:challenge_id, challenge_id) + end + add_index :discusses, :challenge_id + + end +end From 5af5fdc9138239fe31f39ca21bd12d5e3a603d62 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 14:31:03 +0800 Subject: [PATCH 14/47] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index f5de277b4..c09e9e285 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -17,7 +17,7 @@ class DiscussesController < ApplicationController (hidden = :hidden or user_id = :user_id)", {dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id}) .joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") - @disscuss_count = disscusses.count + @disscuss_count = disscusses.count("discusses.id") end @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) @manger = @container.has_manager?(current_user) From fc40905fdf7638380b7b2c3ef6fe3be770d67f65 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 14:33:06 +0800 Subject: [PATCH 15/47] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index c09e9e285..f100ac233 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -14,7 +14,7 @@ class DiscussesController < ApplicationController .where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") else disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and - (hidden = :hidden or user_id = :user_id)", + (discusses.hidden = :hidden or discusses.user_id = :user_id)", {dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id}) .joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") @disscuss_count = disscusses.count("discusses.id") From 97e02718a79c3dd7b4e83b6c455cc78d978c5135 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 15:02:57 +0800 Subject: [PATCH 16/47] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 20b28121f..4fa818099 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -25,7 +25,7 @@ class SubjectsController < ApplicationController @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' + 'subjects'.'hidden' = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") else @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, From c88ef3126f8f62954437a4e1ac7fb517847509eb Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 11 Jul 2019 15:09:22 +0800 Subject: [PATCH 17/47] =?UTF-8?q?git=20500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/gits_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index 1965f61ba..910864812 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -32,7 +32,7 @@ class GitsController < ApplicationController system_user = User.find_by_login(input_username) || User.find_by_mail(input_username) || User.find_by_phone(input_username) # 如果用户名密码错误 - if !system_user.check_password?(input_password) + if system_user && !system_user.check_password?(input_password) uid_logger_error("git start: password is wrong") result = false else From 541383ad0c1fef43b6dc05ad9ac992fb71627050 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 15:33:54 +0800 Subject: [PATCH 18/47] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 4fa818099..522fffa63 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -25,8 +25,8 @@ class SubjectsController < ApplicationController @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - 'subjects'.'hidden' = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' - AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' + AND 'subjects'.'repertoire_id' = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") else @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns From a22805900d83776c6f651121077e6189ee771050 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 15:36:42 +0800 Subject: [PATCH 19/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 12 ++++++++---- app/views/discusses/_discuss.json.jbuilder | 2 +- app/views/discusses/index.json.jbuilder | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index f100ac233..c34b76a8a 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -10,17 +10,21 @@ class DiscussesController < ApplicationController if current_user.admin? @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count disscusses = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, - :root_id => nil).joins(challenge: :games) - .where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") + :root_id => nil) else disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and (discusses.hidden = :hidden or discusses.user_id = :user_id)", {dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id}) - .joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier") @disscuss_count = disscusses.count("discusses.id") end - @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) @manger = @container.has_manager?(current_user) + if @manger + @discusses = disscusses.limit(LIMIT).joins("left join games on discusses.challenge_id = games.challenge_id and discusses.user_id = games.user_id") + .select("discusses.*, games.identifier").includes(:user, :praise_treads).offset(offset) + logger.info("------#{@discusses.to_sql}") + else + @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) + end @current_user = current_user end diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index ee9484131..7da0b7e1f 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -10,7 +10,7 @@ json.hidden discuss.hidden json.manage current_user.manager_of_shixun?(container) json.reward discuss.reward #json.game_url discuss.game_url(container, current_user) -json.game_url "/tasks/#{discuss.identifier}" if @manger +json.game_url "/tasks/#{discuss.identifier}" if @manger && !children # 主贴和回复有一些不同点 if discuss.parent_id json.can_delete discuss.can_deleted?(current_user) diff --git a/app/views/discusses/index.json.jbuilder b/app/views/discusses/index.json.jbuilder index 1b7a95eb3..7ddfb31fb 100644 --- a/app/views/discusses/index.json.jbuilder +++ b/app/views/discusses/index.json.jbuilder @@ -1,8 +1,8 @@ json.disscuss_count @disscuss_count json.all @current_user.admin? json.comments @discusses do |discuss| - json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user } + json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user, children: false} json.children discuss.child_discuss(current_user) do |c_d| - json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user } + json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user, children: true } end end From 1bfde5b562d615fa3fbe73638f4ef573ad270a93 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 15:36:45 +0800 Subject: [PATCH 20/47] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 522fffa63..46f3b4850 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -25,13 +25,13 @@ class SubjectsController < ApplicationController @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' - AND 'subjects'.'repertoire_id' = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' + AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") else @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where - `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' + subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' GROUP BY subjects.id ORDER BY myshixun_member_count DESC") end else From c3ef1d85a495ee6eebc4544df5e949a7ff1c59ab Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 15:39:43 +0800 Subject: [PATCH 21/47] 1 --- app/controllers/discusses_controller.rb | 5 ++--- app/views/discusses/_discuss.json.jbuilder | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index c34b76a8a..c5cb6814d 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -20,10 +20,9 @@ class DiscussesController < ApplicationController @manger = @container.has_manager?(current_user) if @manger @discusses = disscusses.limit(LIMIT).joins("left join games on discusses.challenge_id = games.challenge_id and discusses.user_id = games.user_id") - .select("discusses.*, games.identifier").includes(:user, :praise_treads).offset(offset) - logger.info("------#{@discusses.to_sql}") + .select("discusses.*, games.identifier").includes(:praise_treads).offset(offset) else - @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) + @discusses = disscusses.limit(LIMIT).includes(:praise_treads).offset(offset) end @current_user = current_user diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index 7da0b7e1f..3cd42439f 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -9,8 +9,8 @@ json.shixun_id discuss.dis_id json.hidden discuss.hidden json.manage current_user.manager_of_shixun?(container) json.reward discuss.reward -#json.game_url discuss.game_url(container, current_user) -json.game_url "/tasks/#{discuss.identifier}" if @manger && !children +json.game_url discuss.game_url(container, current_user) +#json.game_url "/tasks/#{discuss.identifier}" if @manger && !children # 主贴和回复有一些不同点 if discuss.parent_id json.can_delete discuss.can_deleted?(current_user) From 462929292732ec745aa12f14aaa590f366c028b3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 15:40:44 +0800 Subject: [PATCH 22/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/discusses/_discuss.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index 3cd42439f..7da0b7e1f 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -9,8 +9,8 @@ json.shixun_id discuss.dis_id json.hidden discuss.hidden json.manage current_user.manager_of_shixun?(container) json.reward discuss.reward -json.game_url discuss.game_url(container, current_user) -#json.game_url "/tasks/#{discuss.identifier}" if @manger && !children +#json.game_url discuss.game_url(container, current_user) +json.game_url "/tasks/#{discuss.identifier}" if @manger && !children # 主贴和回复有一些不同点 if discuss.parent_id json.can_delete discuss.can_deleted?(current_user) From 10143e40c384a27e2074b6cb1a171b413f6da390 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 15:42:23 +0800 Subject: [PATCH 23/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/discusses/_discuss.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index 7da0b7e1f..400798150 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -7,7 +7,7 @@ json.time time_from_now(discuss.created_at) json.position discuss.position json.shixun_id discuss.dis_id json.hidden discuss.hidden -json.manage current_user.manager_of_shixun?(container) +json.manage @manger json.reward discuss.reward #json.game_url discuss.game_url(container, current_user) json.game_url "/tasks/#{discuss.identifier}" if @manger && !children From c87f58bc73954c3a0c7cadfc1dc13b602bf02be2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 15:57:11 +0800 Subject: [PATCH 24/47] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=9B=9E=E5=A4=8D'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index c5cb6814d..3b987be51 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -20,9 +20,9 @@ class DiscussesController < ApplicationController @manger = @container.has_manager?(current_user) if @manger @discusses = disscusses.limit(LIMIT).joins("left join games on discusses.challenge_id = games.challenge_id and discusses.user_id = games.user_id") - .select("discusses.*, games.identifier").includes(:praise_treads).offset(offset) + .select("discusses.*, games.identifier").includes(:user, :praise_treads).offset(offset) else - @discusses = disscusses.limit(LIMIT).includes(:praise_treads).offset(offset) + @discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset) end @current_user = current_user From 5c680a9a93825653495ee7931a9e27df4def9463 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 16:05:30 +0800 Subject: [PATCH 25/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c237da5e2..e4d18316e 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -129,7 +129,7 @@ class ShixunsController < ApplicationController select m.user_id, u.login, u.lastname, m.updated_at, (select sum(cost_time) from games g where g.myshixun_id = m.id) as time, (select sum(final_score) from games g where g.myshixun_id = m.id) as score - from (myshixuns m join users u on m.user_id = u.id) where m.shixun_id = #{@shixun.id} and m.status = 1 + from (users u left join myshixuns m on m.user_id = u.id) where m.shixun_id = #{@shixun.id} and m.status = 1 order by score desc, time asc limit 10 " @myshixuns = Myshixun.find_by_sql(sql) From 35bbc0fe7bbd164a4bae643d165a397395bfb21c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 16:07:00 +0800 Subject: [PATCH 26/47] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 9b62f7dbd..fd6a1d859 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -55,6 +55,8 @@ class GraduationTasksController < ApplicationController page = params[:page] || 1 limit = params[:limit] || 20 @work = @task.graduation_works.where(user_id: current_user.id) + @students = @course.students + @assign_power = @user_course_identity < Course::STUDENT && @task.cross_comment && @task.comment_status == 2 #end_time @task.allow_late ? @task.late_time : @task.end_time # 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品 if @task.published? && (@user_course_identity < Course::STUDENT || @@ -123,8 +125,6 @@ class GraduationTasksController < ApplicationController @work_count = @work_list.count @work_excel = @work_list @work_list = @work_list.page(page).per(limit) - @students = @course.students - @assign_power = @user_course_identity < Course::STUDENT && @task.cross_comment && @task.comment_status == 2 if params[:format] == "xlsx" complete_works = @work_excel.where("work_status > 0").size From 05a7b9cdfce7471da3d8a931d188f5ccafbbf310 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 11 Jul 2019 16:21:30 +0800 Subject: [PATCH 27/47] =?UTF-8?q?=E9=82=AE=E7=AE=B1=E4=B8=8D=E6=9A=B4?= =?UTF-8?q?=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_commit.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/_commit.json.jbuilder b/app/views/shixuns/_commit.json.jbuilder index b752affb6..f6587c261 100644 --- a/app/views/shixuns/_commit.json.jbuilder +++ b/app/views/shixuns/_commit.json.jbuilder @@ -16,7 +16,7 @@ json.commits commits do |commit| json.login nil json.image_url "avatars/User/b" json.name commit["author_name"] - json.email commit["author_email"] + # json.email commit["author_email"] end end end From 14aadb37b5a75e620d64760fc1640e312f55f6fd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 16:22:10 +0800 Subject: [PATCH 28/47] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/graduation_tasks/tasks_list.json.jbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index ac5aa050e..8ee2f78af 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -26,6 +26,9 @@ if @task.published? || @user_course_identity < Course::STUDENT # 是否具有分组 json.have_grouping @task.have_grouping? + # 是否关联项目 + json.have_project @task.have_grouping? && @task.base_on_project + if @user_course_identity == Course::STUDENT json.commit_count grduationwork_count @task, 1 json.uncommit_count grduationwork_count @task, 0 From aa4dbf0f06ce1904adf0d9f25c35f3b4feddfa34 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 11 Jul 2019 16:31:18 +0800 Subject: [PATCH 29/47] account manange not check profile complete --- app/controllers/users/base_account_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/users/base_account_controller.rb b/app/controllers/users/base_account_controller.rb index b693eaab5..29de52b26 100644 --- a/app/controllers/users/base_account_controller.rb +++ b/app/controllers/users/base_account_controller.rb @@ -4,4 +4,12 @@ class Users::BaseAccountController < Users::BaseController def observed_user @_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id])) end + + private + + def require_login + return if User.current.logged? + + tip_exception(401, "..") + end end From a50cbc9e0bd4274208dbb0674c437ef913ef404d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 11 Jul 2019 16:35:34 +0800 Subject: [PATCH 30/47] fix --- app/controllers/users/accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/accounts_controller.rb b/app/controllers/users/accounts_controller.rb index e88ff4564..dff5115e1 100644 --- a/app/controllers/users/accounts_controller.rb +++ b/app/controllers/users/accounts_controller.rb @@ -1,4 +1,4 @@ -class Users::AccountsController < Users::BaseController +class Users::AccountsController < Users::BaseAccountController before_action :private_user_resources! def show From 2f5f0cef16da9201934e34513dd9fd51310ea7ab Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 16:36:10 +0800 Subject: [PATCH 31/47] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 6ffc7f0ce..929af8f47 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -710,10 +710,10 @@ class GamesController < ApplicationController resubmit_identifier = @game.resubmit_identifier # 如果没有超时并且正在评测中 # 判断评测中的状态有两种:1、如果之前没有通关的,只需判断status为1即可;如果通过关,则判断game的resubmit_identifier是否更新 - uid_logger("################game_status: #{@game.status}") - uid_logger("################params[:resubmit]: #{params[:resubmit]}") - uid_logger("################resubmit_identifier: #{resubmit_identifier}") - uid_logger("################time_out: #{params[:time_out]}") + # uid_logger("################game_status: #{@game.status}") + # uid_logger("################params[:resubmit]: #{params[:resubmit]}") + # uid_logger("################resubmit_identifier: #{resubmit_identifier}") + # uid_logger("################time_out: #{params[:time_out]}") if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier))) # 代码评测的信息 From e929ec427ed780a8ba7ea32839c45dd75b6e22f8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 01:03:44 +0800 Subject: [PATCH 32/47] =?UTF-8?q?job=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_member.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course_member.rb b/app/models/course_member.rb index 52c13dbbf..65849e5de 100644 --- a/app/models/course_member.rb +++ b/app/models/course_member.rb @@ -148,7 +148,7 @@ class CourseMember < ApplicationRecord if teacher_groups.count > 0 member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id).compact - none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1 + none_group_teachers = teacher_groups.pluck(:course_member_id).compact.size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1 teachers = course.teachers.where("course_members.id not in (#{none_group_teachers}) or course_members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})") else From 2c143af77446adc8c24f28640db3776979f34afb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 13 Jul 2019 10:30:22 +0800 Subject: [PATCH 33/47] =?UTF-8?q?sidekiq=E7=9B=91=E6=8E=A7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8A=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/constraint/admin_constraint.rb | 7 +++++++ config/routes.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/constraint/admin_constraint.rb diff --git a/app/constraint/admin_constraint.rb b/app/constraint/admin_constraint.rb new file mode 100644 index 000000000..3ddf9a11e --- /dev/null +++ b/app/constraint/admin_constraint.rb @@ -0,0 +1,7 @@ +class AdminConstraint + def matches?(request) + return false unless request.session[:user_id] + user = User.find request.session[:user_id] + user && user.admin? + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7e34363d1..d9e10e4cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,8 @@ Rails.application.routes.draw do require 'sidekiq/web' - mount Sidekiq::Web => '/sidekiq' + require 'admin_constraint' + mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new resources :edu_settings scope '/api' do From 9028cc193e49f647c1b22a9e9361933b5c62aabd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Jul 2019 11:07:01 +0800 Subject: [PATCH 34/47] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=89=80=E6=9C=89Markdown=E5=9B=BE=E7=89=87=E7=9A=84=E7=9A=84u?= =?UTF-8?q?rl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...modify_md_attachment_url_for_md_cotents.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb diff --git a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb new file mode 100644 index 000000000..188e017a5 --- /dev/null +++ b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb @@ -0,0 +1,30 @@ +class ModifyMdAttachmentUrlForMdCotents < ActiveRecord::Migration[5.2] + def change + # 更新MarkDown图片的URL + homework_commons = HomeworkCommon.all + homework_commons.find_each do |hc| + hc.update_column(:description, hc.description.gsub("![](/attachments/download", "![](/api/attachments")) if hc.description.present? + end + + challenges = Challenge.all.unscoped + challenges.find_each do |c| + c.update_column(:task_pass, c.task_pass.gsub("![](/attachments/download", "![](/api/attachments")) if c.task_pass.present? + end + + challenge_answers = ChallengeAnswer.all.unscoped + challenge_answers.find_each do |ca| + ca.update_column(:contents, ca.contents.gsub("![](/attachments/download", "![](/api/attachments")) if ca.contents.present? + end + + shixun_infos = ShixunInfo.all + shixun_infos.find_each do |si| + si.update_column(:propaedeutics, si.propaedeutics.gsub("![](/attachments/download", "![](/api/attachments")) if si.propaedeutics.present? + si.update_column(:description, si.description.gsub("![](/attachments/download", "![](/api/attachments")) if si.description.present? + end + + subjects = Subject.all + subjects.find_each do |s| + s.update_column(:description, s.description.gsub("![](/attachments/download", "![](/api/attachments")) if s.description.present? + end + end +end From be855c5920d5fab0bc9591f85871804e1c901872 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 13:50:28 +0800 Subject: [PATCH 35/47] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index d3808a06b..d3d46b28d 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -52,6 +52,8 @@ class AccountsController < ApplicationController container_type: pre == 'p' ? 'Phone' : 'Mail', score: 500 ) + successful_authentication(@user) + session[:user_id] = @user.id end rescue Exception => e uid_logger_error(e.message) From af59295d6ca58b6b7d09a6734b47347578879337 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 14:41:41 +0800 Subject: [PATCH 36/47] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 55 ++++++----------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6c0116fc..c9c2d90e8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -147,20 +147,7 @@ class ApplicationController < ActionController::Base # 前端会捕捉401,弹登录弹框 # 未授权的捕捉407,弹试用申请弹框 def require_login - #6.13 -hs - if User.current.logged? - if !current_user.profile_completed? - info_url = "#{edu_setting('old_edu_host')}/account/user_info" - tip_exception(402, info_url) - # render :json => { status: 402, url: info_url } - elsif current_user.certification != 1 - day_cer = UserDayCertification.where(user_id: current_user.id).last - tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 - end - else - tip_exception(401, "..") - end - + tip_exception(401, "..") unless User.current.logged? end # 异常提醒 @@ -190,33 +177,19 @@ class ApplicationController < ActionController::Base # 系统全局认证 # def check_auth - # old_edu_host = edu_setting('old_edu_host') - # ue = current_user.user_extension - # - # if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? - # info_url = old_edu_host + '/account/user_info' - # render :json => { status: 402, url: info_url } - # elsif current_user.certification != 1 - # day_cer = UserDayCertification.where(user_id: current_user.id).last - # unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 - # account_url = old_edu_host + "/my/account" - # render :json => { status: 402, url: account_url } - # end - # end - true - end - - # 身份资料的认证: - # 如果试用过期则弹框提示认证,先跳入个人资料页面完善资料,资料完成后,弹框提醒用户试用申请 - def check_account - # # todo user_extension - # if User.current.logged? - # ue = current_user.user_extension - # if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? - # info_url = "#{edu_setting('old_edu_host')}/account/user_info" - # render :json => { status: 402, url: info_url } - # end - # end + if User.current.logged? + if !current_user.profile_completed? + info_url = '/account/user_info' + tip_exception(402, info_url) + elsif current_user.certification != 1 + day_cer = UserDayCertification.where(user_id: current_user.id).last + unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 + tip_exception(407, "系统未授权") + end + end + else + tip_exception(401, "..") + end end def start_user_session(user) From 0061eff0f2a9511fd68322918cc77ce5b39bf63e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 14:53:18 +0800 Subject: [PATCH 37/47] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=88=96?= =?UTF-8?q?=E8=80=85=E6=9C=AA=E6=B3=A8=E5=86=8C=E5=85=81=E8=AE=B8=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index e4d18316e..3b3e0478a 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1,6 +1,6 @@ class ShixunsController < ApplicationController before_action :require_login, except: [:download_file, :index, :menus] - before_action :check_auth, except: [:download_file, :index] + before_action :check_auth, except: [:download_file, :index, :menus] before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, :departments, :apply_shixun_mirror, From fbdd7b0a718aa0d808d4ae5849e8b62d7f6398b3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Jul 2019 14:59:23 +0800 Subject: [PATCH 38/47] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/educoder/sms.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/educoder/sms.rb b/lib/educoder/sms.rb index 237b270d5..5ba273aa8 100644 --- a/lib/educoder/sms.rb +++ b/lib/educoder/sms.rb @@ -28,6 +28,8 @@ module Educoder def self.sendYunpian(mobile, code, send_type, name, user_name, result) #修改为您的apikey.可在官网(http://www.yunpian.com)登录后用户中心首页看到 apikey = EduSetting.get('sms_apikey') + Rails.logger.info("#####apikey: #{apikey}") + Rails.logger.info("#####mobile: #{mobile}") #指定模板发送接口HTTP地址 send_tpl_sms_uri = URI.parse('https://sms.yunpian.com/v2/sms/single_send.json') @@ -70,6 +72,7 @@ module Educoder response = http.start { |http| http.request(request) } ActiveSupport::JSON.decode(response.body) rescue =>err + Rails.logger.error("#############sendYunpian_error: #{err.message}") return nil end end From cb0ce291a13ac614530bddc70f6403a8770e3f19 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Jul 2019 15:15:31 +0800 Subject: [PATCH 39/47] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/educoder/sms.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/educoder/sms.rb b/lib/educoder/sms.rb index 5ba273aa8..cadce7465 100644 --- a/lib/educoder/sms.rb +++ b/lib/educoder/sms.rb @@ -28,8 +28,6 @@ module Educoder def self.sendYunpian(mobile, code, send_type, name, user_name, result) #修改为您的apikey.可在官网(http://www.yunpian.com)登录后用户中心首页看到 apikey = EduSetting.get('sms_apikey') - Rails.logger.info("#####apikey: #{apikey}") - Rails.logger.info("#####mobile: #{mobile}") #指定模板发送接口HTTP地址 send_tpl_sms_uri = URI.parse('https://sms.yunpian.com/v2/sms/single_send.json') From d6bf075d49af1b61b04cdb83b58763063e00674a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 15:28:17 +0800 Subject: [PATCH 40/47] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A4=E8=AF=81url?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8F=8A=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c9c2d90e8..b8fe7d723 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -179,7 +179,7 @@ class ApplicationController < ActionController::Base def check_auth if User.current.logged? if !current_user.profile_completed? - info_url = '/account/user_info' + info_url = '/account/profile' tip_exception(402, info_url) elsif current_user.certification != 1 day_cer = UserDayCertification.where(user_id: current_user.id).last From 2dc1255abf32354d13180c6f85d5ddccb7294116 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 13 Jul 2019 15:40:18 +0800 Subject: [PATCH 41/47] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E5=A4=A9=E8=AF=95=E7=94=A8=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 3 +++ app/controllers/application_controller.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index d3d46b28d..e2df181f0 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -109,6 +109,9 @@ class AccountsController < ApplicationController set_autologin_cookie(user) UserAction.create(:action_id => user.try(:id), :action_type => "Login", :user_id => user.try(:id)) + + # 注册完成后有一天的试用申请 + UserDayCertification.create(user_id: user.id, status: 1) end def set_autologin_cookie(user) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6c0116fc..0a76fa624 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -154,7 +154,7 @@ class ApplicationController < ActionController::Base tip_exception(402, info_url) # render :json => { status: 402, url: info_url } elsif current_user.certification != 1 - day_cer = UserDayCertification.where(user_id: current_user.id).last + day_cer = UserDayCertification.find_by(user_id: current_user.id) tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 end else From c48ed86bc76658ac91a1c889a988b8a045723bfc Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 15:48:54 +0800 Subject: [PATCH 42/47] add . --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b8fe7d723..48ea8eb59 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -210,7 +210,7 @@ class ApplicationController < ActionController::Base end if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 - User.current = User.find 49610 + User.current = User.find_by_phone("153880833362") elsif params[:debug] == 'student' User.current = User.find 8686 elsif params[:debug] == 'admin' From 80fa5538663a7f24d9f8ef96bf6aa72835a80e45 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 15:57:02 +0800 Subject: [PATCH 43/47] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3bdd0d1b0..6a85984ca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -211,7 +211,7 @@ class ApplicationController < ActionController::Base end if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 - User.current = User.find_by_phone("153880833362") + User.current = User.find 81403 elsif params[:debug] == 'student' User.current = User.find 8686 elsif params[:debug] == 'admin' From 6bbb8e050e1e0f22456bfb98b8ea88b5ed06c40d Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 16:10:01 +0800 Subject: [PATCH 44/47] =?UTF-8?q?..=E6=B5=8B=E8=AF=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6a85984ca..5336e20c1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -210,13 +210,15 @@ class ApplicationController < ActionController::Base User.current = User.find 12 end - if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 - User.current = User.find 81403 - elsif params[:debug] == 'student' - User.current = User.find 8686 - elsif params[:debug] == 'admin' - User.current = User.find 1 - end + User.current = User.find 81403 + + # if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 + # User.current = User.find 81403 + # elsif params[:debug] == 'student' + # User.current = User.find 8686 + # elsif params[:debug] == 'admin' + # User.current = User.find 1 + # end end # Sets the logged in user From 85b2db7ac104114b11eb7fa13f4eee89e0348c6f Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 13 Jul 2019 16:26:52 +0800 Subject: [PATCH 45/47] =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 18 +++++++++--------- app/controllers/challenges_controller.rb | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5336e20c1..f38541f12 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -210,15 +210,15 @@ class ApplicationController < ActionController::Base User.current = User.find 12 end - User.current = User.find 81403 - - # if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 - # User.current = User.find 81403 - # elsif params[:debug] == 'student' - # User.current = User.find 8686 - # elsif params[:debug] == 'admin' - # User.current = User.find 1 - # end + # User.current = User.find 81403 + + if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 + User.current = User.find 81403 + elsif params[:debug] == 'student' + User.current = User.find 8686 + elsif params[:debug] == 'admin' + User.current = User.find 1 + end end # Sets the logged in user diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 33963a192..36b0e66d3 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,5 +1,6 @@ class ChallengesController < ApplicationController before_action :require_login + before_action :check_auth before_action :find_shixun, only: [:new, :create, :index] skip_before_action :verify_authenticity_token, only: [:create, :update, :create_choose_question, :crud_answer] before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, From 689600314b1ba1db3802c6c0dcf2e493e39f87fb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 15 Jul 2019 08:51:05 +0800 Subject: [PATCH 46/47] =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=B8=8E=E8=AE=A4?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../add_department_applies_controller.rb | 2 +- .../add_school_applies_controller.rb | 2 +- app/controllers/application_controller.rb | 18 ++++++------------ app/controllers/attachments_controller.rb | 2 +- app/controllers/boards_controller.rb | 2 +- app/controllers/challenges_controller.rb | 2 +- app/controllers/commons_controller.rb | 2 +- app/controllers/course_groups_controller.rb | 2 +- app/controllers/course_modules_controller.rb | 2 +- .../course_second_categories_controller.rb | 2 +- app/controllers/courses_controller.rb | 2 +- app/controllers/ecs/base_controller.rb | 2 +- app/controllers/exercise_answers_controller.rb | 2 +- .../exercise_questions_controller.rb | 2 +- app/controllers/exercises_controller.rb | 2 +- app/controllers/files_controller.rb | 2 +- app/controllers/games_controller.rb | 2 +- app/controllers/graduation_tasks_controller.rb | 2 +- .../graduation_topics_controller.rb | 2 +- app/controllers/graduation_works_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 2 +- app/controllers/messages_controller.rb | 2 +- app/controllers/myshixuns_controller.rb | 2 +- app/controllers/poll_questions_controller.rb | 2 +- app/controllers/poll_votes_controller.rb | 2 +- app/controllers/polls_controller.rb | 2 +- app/controllers/praise_tread_controller.rb | 2 +- app/controllers/question_banks_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 2 +- app/controllers/stages_controller.rb | 2 +- app/controllers/student_works_controller.rb | 2 +- app/controllers/subjects_controller.rb | 2 +- .../users/base_account_controller.rb | 2 +- app/controllers/users/interests_controller.rb | 2 +- app/controllers/users/watches_controller.rb | 2 +- app/controllers/zips_controller.rb | 2 +- 36 files changed, 41 insertions(+), 47 deletions(-) diff --git a/app/controllers/add_department_applies_controller.rb b/app/controllers/add_department_applies_controller.rb index ed8067c84..644ebd87e 100644 --- a/app/controllers/add_department_applies_controller.rb +++ b/app/controllers/add_department_applies_controller.rb @@ -1,5 +1,5 @@ class AddDepartmentAppliesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth def create CreateAddDepartmentApplyService.call(current_user, create_params) diff --git a/app/controllers/add_school_applies_controller.rb b/app/controllers/add_school_applies_controller.rb index 9f2376b9e..c868d79c9 100644 --- a/app/controllers/add_school_applies_controller.rb +++ b/app/controllers/add_school_applies_controller.rb @@ -1,5 +1,5 @@ class AddSchoolAppliesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth def create CreateAddSchoolApplyService.call(current_user, create_params) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 91ac1c282..e8cccaee3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -178,18 +178,12 @@ class ApplicationController < ActionController::Base # 系统全局认证 # def check_auth - if User.current.logged? - if !current_user.profile_completed? - info_url = '/account/profile' - tip_exception(402, info_url) - elsif current_user.certification != 1 - day_cer = UserDayCertification.find_by(user_id: current_user.id) - unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 - tip_exception(407, "系统未授权") - end - end - else - tip_exception(401, "..") + if !current_user.profile_completed? + info_url = '/account/profile' + tip_exception(402, info_url) + elsif current_user.certification != 1 + day_cer = UserDayCertification.find_by(user_id: current_user.id) + tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index bf5c11856..c539b0a60 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -2,7 +2,7 @@ # # 文件上传 class AttachmentsController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_file, only: %i[show destroy] include ErrorCommon diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 2e82c36d7..0bcaaa2c0 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -1,5 +1,5 @@ class BoardsController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_course, only: [:create] before_action :set_board, except: [:create] before_action :teacher_allowed diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 33963a192..697585e0c 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,5 +1,5 @@ class ChallengesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_shixun, only: [:new, :create, :index] skip_before_action :verify_authenticity_token, only: [:create, :update, :create_choose_question, :crud_answer] before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index a23d4dba7..0c0fe79af 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -1,7 +1,7 @@ class CommonsController < ApplicationController OBJECT_TYPE = %W[message journals_for_message] - before_action :require_login + before_action :require_login, :check_auth before_action :validate_object_type before_action :find_object before_action :validate_power diff --git a/app/controllers/course_groups_controller.rb b/app/controllers/course_groups_controller.rb index bee3fa09d..0e16d1bac 100644 --- a/app/controllers/course_groups_controller.rb +++ b/app/controllers/course_groups_controller.rb @@ -1,5 +1,5 @@ class CourseGroupsController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :set_group, except: [:create] before_action :find_course, only: [:create] before_action :teacher_or_admin_allowed diff --git a/app/controllers/course_modules_controller.rb b/app/controllers/course_modules_controller.rb index d8d4ea128..4e9f7b908 100644 --- a/app/controllers/course_modules_controller.rb +++ b/app/controllers/course_modules_controller.rb @@ -1,5 +1,5 @@ class CourseModulesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :set_module, except: [:unhidden_modules] before_action :find_course, only: [:unhidden_modules] before_action :teacher_allowed diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb index d0f07f47f..ca544a584 100644 --- a/app/controllers/course_second_categories_controller.rb +++ b/app/controllers/course_second_categories_controller.rb @@ -1,5 +1,5 @@ class CourseSecondCategoriesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :set_category before_action :teacher_allowed diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e6c4ae330..286935c17 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -11,7 +11,7 @@ class CoursesController < ApplicationController render_error(ex.model.errors.full_messages.join(',')) end - before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner] + before_action :require_login, :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner] before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt, :set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers, :top_banner, :left_banner, :add_teacher_popup, :add_teacher, diff --git a/app/controllers/ecs/base_controller.rb b/app/controllers/ecs/base_controller.rb index 9fb99c420..2cded249a 100644 --- a/app/controllers/ecs/base_controller.rb +++ b/app/controllers/ecs/base_controller.rb @@ -1,6 +1,6 @@ class Ecs::BaseController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :check_user_permission! helper_method :current_user, :current_school diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index aa3966d25..27e4aba11 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -1,5 +1,5 @@ class ExerciseAnswersController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :get_exercise_question include ExercisesHelper diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index e33e5e2dc..3d488c7b0 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -1,5 +1,5 @@ class ExerciseQuestionsController < ApplicationController - before_action :require_login #用户需登陆 + before_action :require_login, :check_auth #用户需登陆 before_action :get_exercise,only:[:new,:create] #获取试卷 before_action :get_exercise_question,except: [:new,:create] #获取试卷的问题及试卷 before_action :is_course_teacher #是否为老师 diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 6af48dbd1..862166f00 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1,5 +1,5 @@ class ExercisesController < ApplicationController - before_action :require_login,except: [:index] + before_action :require_login, :check_auth, except: [:index] before_action :find_course,only: [:index,:new,:create,:my_exercises,:public_exercises,:set_public,:destroys, :join_exercise_banks,:publish_modal,:publish,:end_modal,:end_exercise] #需要有课堂id参数的 before_action :get_exercise,except: [:index,:new,:create,:my_exercises,:public_exercises,:set_public,:destroys, diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b75020643..d090ae253 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -1,7 +1,7 @@ class FilesController < ApplicationController include MessagesHelper - before_action :require_login, except: %i[index] + before_action :require_login, :check_auth, except: %i[index] before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project] before_action :find_ids, only: %i[bulk_delete bulk_send bulk_move bulk_public bulk_publish] before_action :file_validate_sort_type, only: :index diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 929af8f47..217f1839a 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -1,5 +1,5 @@ class GamesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_game before_action :find_shixun, only: [:show, :answer, :rep_content, :choose_build, :game_build, :game_status] diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index fd6a1d859..fc9c8df45 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -1,5 +1,5 @@ class GraduationTasksController < ApplicationController - before_action :require_login, except: [:index] + before_action :require_login, :check_auth, except: [:index] before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment] before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment] before_action :user_course_identity diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index 4ad07c77e..754b472c5 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -1,5 +1,5 @@ class GraduationTopicsController < ApplicationController - before_action :require_login, except: [:index] + before_action :require_login, :check_auth, except: [:index] before_action :find_course before_action :teacher_allowed, only: [:new, :create, :update, :edit, :destroys, :set_public, :refuse_student_topic, :accept_student_topic, :export] diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb index 7cf1a3393..a4a59a3f5 100644 --- a/app/controllers/graduation_works_controller.rb +++ b/app/controllers/graduation_works_controller.rb @@ -1,5 +1,5 @@ class GraduationWorksController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_task, only: [:new, :create, :search_member_list, :check_project, :relate_project, :cancel_relate_project] before_action :find_work, only: [:show, :edit, :update, :revise_attachment, :supply_attachments, :comment_list, diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 6f0f10f4d..bbae7ba75 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -3,7 +3,7 @@ class HomeworkCommonsController < ApplicationController include ApplicationHelper include ExportHelper - before_action :require_login, except: [:index, :choose_category] + before_action :require_login, :check_auth, except: [:index, :choose_category] before_action :find_course, only: [:index, :create, :new, :shixuns, :subjects, :create_shixun_homework, :publish_homework, :end_homework, :set_public, :choose_category, :move_to_category, :choose_category, diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 0c61e2b69..5bdc3e053 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -3,7 +3,7 @@ class MessagesController < ApplicationController SORT_TYPE = %w[time hot] - before_action :require_login, only: %i[create update sticky_top bulk_delete create destroy bulk_send bulk_move bulk_public] + before_action :require_login, :check_auth, only: %i[create update sticky_top bulk_delete create destroy bulk_send bulk_move bulk_public] before_action :find_board, only: [:create, :index, :bulk_delete, :bulk_move, :bulk_send, :bulk_public] before_action :find_message, only: [:update, :destroy, :sticky_top, :reply_list, :destroy, :reply] before_action :validate_delete_params, only: %i[bulk_delete bulk_public] diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index f4549d691..276fbef32 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,5 +1,5 @@ class MyshixunsController < ApplicationController - before_action :require_login, :except => [:training_task_status, :code_runinng_message] + before_action :require_login, :check_auth, :except => [:training_task_status, :code_runinng_message] before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message] before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message] skip_before_action :verify_authenticity_token, :only => [:html_content] diff --git a/app/controllers/poll_questions_controller.rb b/app/controllers/poll_questions_controller.rb index 84e21c4e8..6a0b9ea47 100644 --- a/app/controllers/poll_questions_controller.rb +++ b/app/controllers/poll_questions_controller.rb @@ -1,5 +1,5 @@ class PollQuestionsController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :get_poll,only:[:new,:create] before_action :get_poll_question,except: [:new,:create] before_action :is_course_teacher diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index c11248054..b1191d8ea 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -1,6 +1,6 @@ class PollVotesController < ApplicationController #在开始回答和提交问卷的时候,已经做了判断用户的身份权限 - before_action :require_login + before_action :require_login, :check_auth before_action :get_poll_question before_action :check_answer_in_question diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index e2d0ce3cd..70995fbcf 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1,6 +1,6 @@ class PollsController < ApplicationController # before_action :check_poll_status 问卷的发消息和定时任务没有做 - before_action :require_login,except: [:index] + before_action :require_login, :check_auth,except: [:index] before_action :find_course, except: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,:commit_poll, :commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header] before_action :get_poll_and_course, only: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer, diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index bf814db77..459eb4bad 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -1,6 +1,6 @@ class PraiseTreadController < ApplicationController include MessagesHelper - before_action :require_login + before_action :require_login, :check_auth before_action :validate_params, only: [:like, :unlike] before_action :find_object diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 22650f2d3..e30065d09 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -1,5 +1,5 @@ class QuestionBanksController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :params_filter # 题库选用列表 diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 3b3e0478a..2d708bfa8 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1,5 +1,5 @@ class ShixunsController < ApplicationController - before_action :require_login, except: [:download_file, :index, :menus] + before_action :require_login, :check_auth, except: [:download_file, :index, :menus] before_action :check_auth, except: [:download_file, :index, :menus] before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, diff --git a/app/controllers/stages_controller.rb b/app/controllers/stages_controller.rb index 3d0087981..c62832365 100644 --- a/app/controllers/stages_controller.rb +++ b/app/controllers/stages_controller.rb @@ -1,5 +1,5 @@ class StagesController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :find_subject, only: [:create, :index] before_action :find_stage, only: [:update, :destroy, :edit, :up_position, :down_position] before_action :allowed, except: [:index] diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 1c98db56c..9b32358bd 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -2,7 +2,7 @@ class StudentWorksController < ApplicationController include HomeworkCommonsHelper include StudentWorksHelper - before_action :require_login + before_action :require_login, :check_auth before_action :find_homework, only: [:new, :create, :search_member_list, :check_project, :relate_project, :cancel_relate_project] before_action :find_work, only: [:shixun_work_report, :adjust_review_score, :shixun_work, :commit_des, :update_des, diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 46f3b4850..b3e317e4b 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -1,5 +1,5 @@ class SubjectsController < ApplicationController - before_action :require_login, except: [:index] + before_action :require_login, :check_auth, except: [:index] # before_action :check_auth, except: [:index] before_action :find_subject, except: [:index, :create, :append_to_stage] before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, diff --git a/app/controllers/users/base_account_controller.rb b/app/controllers/users/base_account_controller.rb index 29de52b26..5c474517d 100644 --- a/app/controllers/users/base_account_controller.rb +++ b/app/controllers/users/base_account_controller.rb @@ -1,5 +1,5 @@ class Users::BaseAccountController < Users::BaseController - before_action :require_login + before_action :require_login, :check_auth def observed_user @_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id])) diff --git a/app/controllers/users/interests_controller.rb b/app/controllers/users/interests_controller.rb index 93836fd63..bac9c568d 100644 --- a/app/controllers/users/interests_controller.rb +++ b/app/controllers/users/interests_controller.rb @@ -1,6 +1,6 @@ class Users::InterestsController < Users::BaseController skip_before_action :check_observed_user_exists! - before_action :require_login + before_action :require_login, :check_auth def create identity = params[:identity].to_s.strip diff --git a/app/controllers/users/watches_controller.rb b/app/controllers/users/watches_controller.rb index 95a0b38cd..867106c52 100644 --- a/app/controllers/users/watches_controller.rb +++ b/app/controllers/users/watches_controller.rb @@ -1,5 +1,5 @@ class Users::WatchesController < Users::BaseController - before_action :require_login + before_action :require_login, :check_auth def create if observed_logged_user? diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index a4140fe34..10baf2454 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -1,5 +1,5 @@ class ZipsController < ApplicationController - before_action :require_login + before_action :require_login, :check_auth before_action :load_homework, only: [:shixun_report] before_action :get_exercise, only: [:export_exercises] From 394f4eb2fe9d8a621ae0289f95b18ad43d47f39d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 15 Jul 2019 09:01:42 +0800 Subject: [PATCH 47/47] merge --- app/controllers/challenges_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index ac06cdcc0..697585e0c 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,5 +1,4 @@ class ChallengesController < ApplicationController -<<<<<<< HEAD before_action :require_login, :check_auth before_action :find_shixun, only: [:new, :create, :index] skip_before_action :verify_authenticity_token, only: [:create, :update, :create_choose_question, :crud_answer]