From d75882030eab932b72d4502f58ca1c3cff604ecd Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Sat, 14 Mar 2020 00:17:18 +0800 Subject: [PATCH] FIX api bug --- app/controllers/application_controller.rb | 2 +- app/controllers/concerns/laboratory_helper.rb | 2 +- app/controllers/users_controller.rb | 35 +++++-------------- app/views/users/get_user_info.json.jbuilder | 17 --------- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4462eac4a..d689742c7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base include RenderExpand include RenderHelper include ControllerRescueHandler - # include LaboratoryHelper + include LaboratoryHelper include GitHelper include LoggerHelper include LoginHelper diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index e03273d68..fea1565ff 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -29,4 +29,4 @@ module LaboratoryHelper laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)) @_default_yun_session = "#{laboratory.try(:identifier).split('.').first}_user_id" end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 544a49c8c..a2fb9e8bc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -29,25 +29,6 @@ class UsersController < ApplicationController @user = current_user # TODO 等消息上线再打开注释 #@tidding_count = unviewed_tiddings(current_user) if current_user.present? - @course = - if params[:course_id] - Course.find params[:course_id] - elsif params[:board_id] - Board.find(params[:board_id]).course - elsif params[:graduation_topic_id] - GraduationTopic.find(params[:graduation_topic_id]).course - elsif params[:graduation_group_id] - GraduationGroup.find(params[:graduation_group_id]).course - elsif params[:graduation_work_id] - GraduationWork.find(params[:graduation_work_id]).course - elsif params[:graduation_task_id] - GraduationTask.find(params[:graduation_task_id]).course - elsif params[:poll_id] - Poll.find(params[:poll_id]).course - elsif params[:attachment_id] - Attachment.find(params[:attachment_id]).course - end - @course_identity = current_user.course_identity(@course) if @course rescue Exception => e uid_logger_error(e.message) missing_template @@ -72,14 +53,14 @@ class UsersController < ApplicationController # Redo: 消息总数缓存 def get_navigation_info - @old_domain = edu_setting('old_edu_host') - @user = current_user - # 新消息数 - @new_message = @user.tidings.where("created_at > '#{@user.click_time}'").count > 0 || @user.private_messages.where("created_at > '#{@user.click_time}'").count > 0 - - @user_url = "/users/#{@user.login}" - @career = Career.where(status: true).order("created_at asc").pluck(:id, :name) - @auth = User.current.ec_school.present? ? "#{@old_domain}/ecs/department?school_id=#{User.current.ec_school}" : nil + # @old_domain = edu_setting('old_edu_host') + # @user = current_user + # # 新消息数 + # @new_message = @user.tidings.where("created_at > '#{@user.click_time}'").count > 0 || @user.private_messages.where("created_at > '#{@user.click_time}'").count > 0 + # + # @user_url = "/users/#{@user.login}" + # @career = Career.where(status: true).order("created_at asc").pluck(:id, :name) + # @auth = User.current.ec_school.present? ? "#{@old_domain}/ecs/department?school_id=#{User.current.ec_school}" : nil end # 用户回复功能 diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index eeb66f6eb..a270297bd 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -13,20 +13,3 @@ json.phone @user.phone json.email @user.mail json.profile_completed @user.profile_completed? json.professional_certification @user.professional_certification -json.main_site current_laboratory.main_site? -json.is_shixun_marker current_user.is_shixun_marker? || current_user.admin_or_business? -if @course - json.course_identity @course_identity - json.course_name @course.name - json.course_public @course.is_public - json.course_excellent @course.excellent - if params[:group_info] - json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT - end - json.first_category_url module_url(@course.none_hidden_course_modules.first, @course) - json.course_is_end @course.is_end -end - -if params[:school] - json.user_school @user.school_name -end