diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 26effd12e..fca143623 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -408,18 +408,16 @@ class ShixunsController < ApplicationController @shixun.update_attributes(shixun_params) @shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_schools.delete_all - if params[:scope_partment].present? && params[:user_scope].to_i == 1 + logger.info("##########scope_partment:###{params[:scope_partment]}") + # scope_partment: 高校的名称 + if params[:scope_partment].present? arr = [] ids = School.where(:name => params[:scope_partment]).pluck(:id).uniq ids.each do |id| arr << { :school_id => id, :shixun_id => @shixun.id } end ShixunSchool.create!(arr) - use_scope = 1 - else - use_scope = 0 end - @shixun.update_attributes!(:use_scope => use_scope) # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 if current_user.admin? || current_user.business? @shixun.shixun_service_configs.destroy_all diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index bc5b0a607..396c0900e 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -222,7 +222,7 @@ class SubjectsController < ApplicationController @subject.update_attributes(status: 1) ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0) begin - status = Trustie::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') + status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') rescue => e uid_logger_error("发送验证码出错: #{e}") end diff --git a/app/controllers/users/private_message_details_controller.rb b/app/controllers/users/private_message_details_controller.rb index 486d23d7f..8e7b31212 100644 --- a/app/controllers/users/private_message_details_controller.rb +++ b/app/controllers/users/private_message_details_controller.rb @@ -3,11 +3,13 @@ class Users::PrivateMessageDetailsController < Users::BaseController after_action :update_message_status, only: [:show] + helper_method :target_user + def show messages = observed_user.private_messages.without_deleted.where(target: target_user) @count = messages.count - @messages = messages.order(send_time: :asc).includes(sender: :user_extension) + @messages = paginate messages.order(send_time: :desc).includes(sender: :user_extension) end private diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index c14850a4c..81ac1eb33 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -58,7 +58,7 @@ class DiscussesService praise_count: 0, position: params[:position], challenge_id: params[:challenge_id], hidden: !current_user.admin? ) # 发送手机通知 - Trustie::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员') + Educoder::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员') rescue Exception => e raise(e.message) end diff --git a/app/services/search_shixun_service.rb b/app/services/search_shixun_service.rb deleted file mode 100644 index 2e77e82d8..000000000 --- a/app/services/search_shixun_service.rb +++ /dev/null @@ -1,96 +0,0 @@ -class SearchShixunService < ApplicationService - include ElasticsearchAble - - attr_reader :user, :params - - def initialize(user, params) - @user = user - @params = params - end - - def call - Shixun.search(keyword, - fields: search_fields, - where: where_clauses, - order: order_clauses, - includes: includes_clauses, - page: page, - per_page: per_page) - end - - private - - def tag_filter_shixun_ids - return [] if params[:tag_level].to_i == 0 || params[:tag_id].blank? - - case params[:tag_level].to_i - when 1 then - Repertoire.find(params[:tag_id]).tag_repertoires.joins(:shixun_tag_repertoires) - .pluck('shixun_tag_repertoires.shixun_id') - when 2 then - SubRepertoire.find(params[:tag_id]).tag_repertoires.joins(:shixun_tag_repertoires) - .pluck('shixun_tag_repertoires.shixun_id') - when 3 then - TagRepertoire.find(params[:tag_id]).shixun_tag_repertoires.pluck(:shixun_id) - else - [] - end - end - - def user_filter_shixun_ids - return [] if params[:order_by] != 'mine' - - user.shixun_members.pluck(:shixun_id) + user.myshixuns.pluck(:shixun_id) - end - - def keyword - params[:keyword].to_s.strip.presence || '*' - end - - def search_fields - %w(name^10 author_name challenge_names description challenge_tag_names) - end - - def where_clauses - hash = {} - - ids = user_filter_shixun_ids + tag_filter_shixun_ids - hash[:id] = ids if ids.present? - - if params[:order_by] == 'mine' - hash[:status] = { not: -1 } - else - hash.merge!(hidden: false, status: 2) - end - - unless params[:status].to_i.zero? - params[:status] = [0, 1] if params[:status].to_i == 1 - hash[:status] = params[:status] - end - - hash[:trainee] = params[:diff].to_i unless params[:diff].to_i.zero? - - hash - end - - def includes_clauses - [] - end - - def order_clauses - hash = { _score: :desc } - publish_order = { type: 'number', order: :desc, script: 'doc["status"].value=="2" ? 1 : 0' } - - sort = params[:sort].to_s.strip == 'asc' ? 'asc' : 'desc' - clauses = - case params[:order_by].presence - when 'new' then { _script: publish_order, created_at: sort } - when 'hot' then { _script: publish_order, myshixuns_count: sort } - when 'mine' then { created_at: sort } - else { _script: publish_order, publish_time: sort } - end - hash.merge!(clauses) - - hash - end -end \ No newline at end of file diff --git a/app/services/users/update_account_service.rb b/app/services/users/update_account_service.rb index d603cec8c..b160b47cd 100644 --- a/app/services/users/update_account_service.rb +++ b/app/services/users/update_account_service.rb @@ -51,6 +51,8 @@ class Users::UpdateAccountService < ApplicationService if first_full_reward RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500) + + sms_notify_admin(user.lastname) if user.user_extension.teacher? end user @@ -65,4 +67,10 @@ class Users::UpdateAccountService < ApplicationService def user_extension_attributes params.slice(*%i[location location_city identity student_id technical_title school_id department_id]) end + + def sms_notify_admin name + Educoder::Sms.send(mobile:'18175896138', send_type:'teacher_register', name: name, user_name:'管理员') + rescue => ex + Util.logger_error(ex) + end end \ No newline at end of file diff --git a/app/views/users/private_message_details/show.json.jbuilder b/app/views/users/private_message_details/show.json.jbuilder index 065767fb4..17d1a5e38 100644 --- a/app/views/users/private_message_details/show.json.jbuilder +++ b/app/views/users/private_message_details/show.json.jbuilder @@ -1,9 +1,13 @@ json.count @count +json.target do + json.partial! 'users/user_simple', user: target_user +end json.messages do json.array! @messages.each do |message| json.extract! message, :id, :user_id, :receiver_id, :sender_id, :content json.send_time message.display_send_time + json.send_day message.send_time.strftime('%Y-%m-%d') json.sender do json.partial! 'users/user_simple', user: message.sender end diff --git a/lib/educoder/sms.rb b/lib/educoder/sms.rb index 7fa1c0edb..63287301d 100644 --- a/lib/educoder/sms.rb +++ b/lib/educoder/sms.rb @@ -21,7 +21,7 @@ module Educoder def self.notify_admin(opt) opt[:name] = '管理员' - opt[:mobile] = ENV['NOTIFY_ADMIN_PHONE'] || EduSetting.get('notify_admin_phone') || '17680641960' + opt[:mobile] = ENV['NOTIFY_ADMIN_PHONE'] || EduSetting.get('notify_admin_phone') || '18711085785' send(opt) end @@ -40,6 +40,8 @@ module Educoder elsif send_type == 'competition_start' params['text'] = "【Edu实训】亲爱的#{user_name},你参与的#{name}将于#{result}开始,请及时参赛" Rails.logger.info "#{params['text']}" + elsif send_type == "teacher_register" + params['text'] = "【Edu实训】亲爱的#{user_name},有新的老师#{name}注册啦,请尽快处理" elsif send_type == 'subject_authorization' || send_type == 'shixun_authorization' params['text'] = "【Edu实训】亲爱的#{user_name},您提交的#{name}#{send_type=='subject_authorization'?'实训路径':'实训'}发布申请#{result},请登录平台查看详情" Rails.logger.info "#{params['text']}" diff --git a/public/react/public/css/edu-all.css b/public/react/public/css/edu-all.css index 6bc9d30fc..9f129eabc 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -3416,3 +3416,7 @@ a.singlepublishtwo{ .shaiContent li.shaiItem:hover i.iconfont{ color: #4CACFF!important } + +.detail_for_paragraph p{ + white-space: pre-wrap; +} \ No newline at end of file diff --git a/public/react/src/App.css b/public/react/src/App.css index 9d06bfc94..6f63551c6 100644 --- a/public/react/src/App.css +++ b/public/react/src/App.css @@ -52,6 +52,6 @@ html, body { color: #f5222d; } /* md多空格 */ -.markdown-body { - white-space: pre; +.markdown-body p { + white-space: pre-wrap; } \ No newline at end of file diff --git a/public/react/src/common/TextUtil.js b/public/react/src/common/TextUtil.js index bb0b3f145..2dab5c4aa 100644 --- a/public/react/src/common/TextUtil.js +++ b/public/react/src/common/TextUtil.js @@ -9,7 +9,7 @@ export function markdownToHTML(oldContent, selector) { window.$('#md_div').html('') // markdown to html if (selector && oldContent && oldContent.startsWith('') // .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`)); $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?6`)); + .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?7`)); $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?6`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?7`)); // index.html有加载 $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?6`)); + .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?7`)); // $('head').append($('') diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 33649a220..fa879a9e5 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -3712,3 +3712,7 @@ a.singlepublishtwo{ .shaiContent li.shaiItem:hover i.iconfont{ color: #4CACFF!important } + +.detail_for_paragraph p{ + white-space: pre-wrap; +} \ No newline at end of file