diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index aa1e573ed..1c6fd7008 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -217,7 +217,7 @@ module Mobile get "homeworks/:id" do cs = CoursesService.new homeworks = cs.homework_list params,current_user - present :data, homeworks, with: Mobile::Entities::Homework + present :data, homeworks, with: Mobile::Entities::Homework,user: current_user present :status, 0 end @@ -264,7 +264,7 @@ module Mobile post ":course_id/attachments" do cs = CoursesService.new count = cs.course_attachments params - present :data, count, with: Mobile::Entities::Attachment + present :data, count, with: Mobile::Entities::Attachment,user: current_user present :status, 0 end @@ -398,7 +398,7 @@ module Mobile course = Course.find(params[:course_id]) exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") - present :data,exercises,with:Mobile::Entities::Exercise + present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 49cb6bd2b..028ad633d 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -3,6 +3,7 @@ module Mobile class Attachment < Grape::Entity include Redmine::I18n include ActionView::Helpers::NumberHelper + include ApplicationHelper def self.attachment_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) @@ -22,6 +23,7 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + end end end @@ -36,6 +38,12 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index 05066f8a4..ce6a2fb39 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -27,6 +27,14 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 3f1631c96..cea15ece9 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -98,6 +98,13 @@ module Mobile homework_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ea305d967..c72e04e14 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -78,12 +78,7 @@ class WechatsController < ActionController::Base end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| - uw = user_binded?(request[:FromUserName]) - unless uw - sendBind(request) - else - request.reply.text "#{request[:FromUserName]} view #{view}" - end + request.reply.text "#{request[:FromUserName]} view #{view}" end # When user sent the imsage @@ -147,6 +142,14 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + + on :click, with: 'JOIN_PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + on :click, with: 'JOIN_CLASS' do |request, key| uw = user_binded?(request[:FromUserName]) unless uw diff --git a/config/menu.yml.test b/config/menu.yml.test index a43d72816..521ff290a 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - type: "view" - name: "课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + - + type: "click" + name: "我的项目" + key: "PROJECT" - type: "view" - name: "资源" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 2f9af6554..01628c2f4 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -23,7 +23,7 @@
@@ -42,14 +42,14 @@ diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 28fc69cc3..c06c57238 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@