From c524409e4af2ecd851b4a348b9898d2929ab56ee Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 14 Jul 2016 17:15:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9B=E5=85=A5=E6=9F=90?= =?UTF-8?q?=E4=B8=AA=E7=8F=AD=E7=BA=A7=E6=8A=A5=E9=94=99=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 060f43614..88c8ba144 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -57,14 +57,21 @@ module Mobile expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] can_setting = false - member = instance.members.where("user_id=#{current_user.id} and course_id=#{instance.id}")[0] + + if instance[:course] + course = instance[:course] + else + course = instance + end + + member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] roleName = member.roles[0].name if member if roleName && (roleName == "TeachingAsistant" || roleName == "Teacher" ) can_setting = true end - if instance.tea_id == current_user.id + if course.tea_id == current_user.id can_setting = true end can_setting