From a1aa51353c3ce9c9f0d76c1743226805767b2093 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 20 Jun 2019 19:44:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=9D=83=E9=99=90=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E3=80=81=E4=BD=9C=E4=B8=9A=E5=92=8C=E6=AF=95=E8=AE=BE?= =?UTF-8?q?=E7=9A=84=E7=A7=81=E6=9C=89=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 6 +++--- app/views/courses/top_banner.json.jbuilder | 4 ++-- app/views/graduation_tasks/index.json.jbuilder | 4 ++-- app/views/graduation_topics/_topics.json.jbuilder | 4 ++-- app/views/homework_commons/index.json.jbuilder | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 65f8f5ff9..2c37285fa 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -274,7 +274,7 @@ class CoursesController < ApplicationController end end - @is_admin = current_user.creator_of_course? @course + @is_admin = @user_course_identity < Course::PROFESSOR @applications= CourseMessage.unhandled_join_course_requests_by_course(@course) @@ -897,8 +897,8 @@ class CoursesController < ApplicationController def top_banner @user = current_user - @is_teacher = @user.teacher_of_course?(@course) - @is_student = @course.course_members.where(user_id: @user.id, role: 4, is_active: 1).present? + @is_teacher = @user_course_identity < Course::STUDENT + @is_student = @user_course_identity == Course::STUDENT @course.increment!(:visits) end diff --git a/app/views/courses/top_banner.json.jbuilder b/app/views/courses/top_banner.json.jbuilder index ddf860709..c0a1ff956 100644 --- a/app/views/courses/top_banner.json.jbuilder +++ b/app/views/courses/top_banner.json.jbuilder @@ -11,7 +11,7 @@ json.course_end @course.is_end json.deadline course_end_date @course.end_date json.educoder_teacher @user.is_teacher? #json.is_student @is_student -json.is_admin @user.creator_of_course?(@course) +json.is_admin @user_course_identity < Course::PROFESSOR json.is_public @course.is_public == 1 json.code_halt @course.invite_code_halt == 1 json.invite_code @course.invite_code_halt == 0 ? @course.generate_invite_code : "" @@ -20,7 +20,7 @@ json.switch_to_teacher switch_teacher_role(@is_student, @course, @user) json.switch_to_assistant switch_assistant_role(@is_student, @course, @user) #json.join_course !@user.member_of_course?(@course) #json.copy_course !@user.member_of_course?(@course) && @user.is_teacher? -json.course_identity @user.course_identity(@course) +json.course_identity @user_course_identity if @course.is_end == 0 json.days_remaining (@course.end_date.to_date - Time.now.to_date).to_i end diff --git a/app/views/graduation_tasks/index.json.jbuilder b/app/views/graduation_tasks/index.json.jbuilder index 157bde672..80780b209 100644 --- a/app/views/graduation_tasks/index.json.jbuilder +++ b/app/views/graduation_tasks/index.json.jbuilder @@ -7,10 +7,10 @@ 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 + # task_private = @identity > Course::STUDENT && !task.is_public json.task_id task.id json.name task.name - json.private_icon task_private + json.private_icon !task.is_public json.task_status task.status #6.12 -hs json.status task_curr_status(task, @course)[:status] json.status_time task_curr_status(task, @course)[:time] diff --git a/app/views/graduation_topics/_topics.json.jbuilder b/app/views/graduation_topics/_topics.json.jbuilder index 7a37b666b..271531f85 100644 --- a/app/views/graduation_topics/_topics.json.jbuilder +++ b/app/views/graduation_topics/_topics.json.jbuilder @@ -1,6 +1,6 @@ json.array! topics do |topic| - task_private = course_identity > Course::STUDENT && !topic.is_public - json.private_icon task_private + # task_private = course_identity > Course::STUDENT && !topic.is_public + json.private_icon !topic.is_public json.(topic, :id, :name, :status) json.author topic.teacher.full_name json.user_topic_status topic.user_status(current_user) diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index 18e601871..c9074cc2b 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -12,10 +12,10 @@ json.category_id @category.try(:id) json.category_name @category.try(:name) json.homeworks @homework_commons.each do |homework| - homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public + # homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public json.homework_id homework.id json.name homework.name - json.private_icon homework_private + json.private_icon !homework.is_public json.status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:status] json.status_time homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time] json.time_status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time_status]