Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2017-03-17 14:30:44 +08:00
commit 357b7c5aa0
13 changed files with 116 additions and 98 deletions

View File

@ -136,8 +136,14 @@ class AtController < ApplicationController
#Message
def find_message(id)
message = Message.find(id)
at_persons = message.board.messages.map(&:author)
(at_persons || []) + (find_project(message.board.project_id)||[])
if message.board.course_id.nil?
at_persons = message.board.messages.map(&:author)
(at_persons || []) + (find_project(message.board.project_id)||[])
else
type = 'Course'
course_id = message.board.course_id
find_at_users(type, course_id)
end
end
#News

View File

@ -121,7 +121,7 @@ class ForumsController < ApplicationController
order = ""
@order_str = ""
if(params[:reorder_complex])
order = "last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}"
order = "replies_count #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}"
@order_str = "reorder_complex="+params[:reorder_complex]
elsif(params[:reorder_popu])
order = "replies_count #{params[:reorder_popu]}"

View File

@ -318,6 +318,8 @@
len = t.length;
for(var i=0;i<len;i++){
t[i].href = 'javascript:void(0)';
// 火狐浏览器点击弹开空白页
t[i].target = '_self';
}
// 退出按钮可用
var d = document.getElementById("logout_trustie");

View File

@ -1,5 +1,5 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
@ -105,11 +105,18 @@
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml5 mb10" id="reply<%= @topic.id %>">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'course_board_canel_message_replay();', :class => "grey_btn fr c_white mt10 mr5 ml10" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'course_board_submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-left: 50px;" %>
<% end %>
<div nhname='new_message_<%= @topic.id%>' style="display:none;">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<input type="hidden" name="journal_id" value="<%= @topic.id %>"/>
<div nhname='toolbar_container_<%= @topic.id %>' ></div>
<div class="cl"></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @topic.id%>' name="content"></textarea>
<div class="cl"></div>
<span nhname='contentmsg_<%= @topic.id%>' class="fl"></span>
<a id="new_message_submit_btn_<%= @topic.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>

View File

@ -88,7 +88,7 @@
}
}
$(function() {
sd_create_editor_from_data(<%= @topic.id%>,null,"100%", "<%=@topic.class.to_s%>");
sd_create_editor_from_data(<%= @topic.id%>,null,"100%", "<%= @topic.class.to_s %>");
showNormalImage('message_description_<%= @topic.id %>');
});
</script>

View File

@ -1,15 +1,29 @@
<%if @project%>
<% if params[:is_project] %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/act_messages', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id,:is_course=>@is_course,:is_board=>@is_board}) %>");
<% else %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% end %>
<% if @project %>
<% if params[:is_project] %>
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/act_messages',
:locals => { :activity => @topic,
:user_activity_id => @user_activity_id,
:is_course => @is_course,
:is_board => @is_board}) %>");
// ForgeActivity是具体项目的动态UserActivity是社区的动态
// sd_create_editor_from_data(<%#= @user_activity_id %>, "", "100%", "ForgeActivity");
<% else %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply',
:locals => { :activity => @topic,
:user_activity_id => @user_activity_id}) %>");
<%elsif @course%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @contest%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% end %>
<% elsif @course %>
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply',
:locals => { :activity => @topic,
:user_activity_id => @user_activity_id}) %>");
<% elsif @contest %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply',
:locals => { :activity => @topic,
:user_activity_id => @user_activity_id}) %>");
<% elsif @org_subfield %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>
sd_create_editor_from_data(<%= @user_activity_id %>,"","100%", "UserActivity");
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply',
:locals => { :activity => @topic,
:user_activity_id => @user_activity_id}) %>");
<% end %>
sd_create_editor_from_data(<%= @user_activity_id %>, "", "100%", "UserActivity");

View File

@ -1,3 +1,6 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<div class="container-big mt10" id="user_activity_<%= user_activity_id%>">
<div class="pr">
<div class="homepagePostPortrait">

View File

@ -1,3 +1,6 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<% all_replies = Message.where("root_id = #{activity.id}").reorder("created_on desc") %>
<% count = all_replies.count %>
<% no_children_comments = get_no_children_comments all_replies %>

View File

@ -52,7 +52,7 @@
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">班级</span></div>
<div class="cl"></div>
</li>
<li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : (h item.description.html_safe) %></li>
<li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %></li>
<li class="f12 fontGrey2">
<% user = User.find(item.tea_id)%>
<span class="mr30">教师:<%= user.realname %></span>

View File

@ -521,13 +521,6 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id"
add_index "contest_messages", ["user_id"], :name => "index_contest_messages_on_user_id"
create_table "contest_notifications", :force => true do |t|
t.text "title"
t.text "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "contestant_for_contests", :force => true do |t|
t.integer "student_id"
t.integer "contest_id"
@ -595,37 +588,6 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "contestant_works", ["user_id"], :name => "index_contestant_works_on_user_id"
add_index "contestant_works", ["work_id"], :name => "index_contestant_works_on_work_id"
create_table "contesting_projects", :force => true do |t|
t.integer "project_id"
t.string "contest_id"
t.integer "user_id"
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "reward"
end
create_table "contesting_softapplications", :force => true do |t|
t.integer "softapplication_id"
t.integer "contest_id"
t.integer "user_id"
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "reward"
end
create_table "contestnotifications", :force => true do |t|
t.integer "contest_id"
t.string "title"
t.string "summary"
t.text "description"
t.integer "author_id"
t.integer "notificationcomments_count"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "contests", :force => true do |t|
t.integer "user_id"
t.string "name"
@ -858,21 +820,6 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "delayed_jobs_20161218", :id => false, :force => true do |t|
t.integer "id", :default => 0, :null => false
t.integer "priority", :default => 0, :null => false
t.integer "attempts", :default => 0, :null => false
t.text "handler", :null => false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -1143,8 +1090,8 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "homework_type", :default => 1
t.string "late_penalty"
t.integer "course_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "teacher_priority", :default => 1
t.integer "anonymous_comment", :default => 0
t.integer "quotes", :default => 0
@ -1152,8 +1099,6 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.datetime "simi_time"
t.integer "score_open", :default => 1
t.integer "anonymous_appeal", :default => 0
t.integer "homework_bank_id"
t.boolean "is_update", :default => false
end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
@ -1456,23 +1401,6 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "memos", ["root_id"], :name => "index_memos_on_root_id"
create_table "mess", :id => false, :force => true do |t|
t.string "课程名"
t.integer "课程ID", :default => 0, :null => false
t.string "教师姓", :default => "", :null => false
t.string "教师名", :limit => 30, :default => "", :null => false
t.string "主贴名", :default => "", :null => false
t.integer "主贴或回帖ID", :default => 0, :null => false
t.integer "回帖对应主贴ID"
t.integer "帖子点赞数"
t.integer "主贴回复数", :default => 0, :null => false
t.text "主贴或回帖内容"
t.datetime "发帖时间", :null => false
t.integer "发帖或回帖用户ID", :default => 0, :null => false
t.string "发帖或回帖用户姓", :default => "", :null => false
t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false
end
create_table "message_alls", :force => true do |t|
t.integer "user_id"
t.integer "message_id"

View File

@ -3,3 +3,4 @@ require 'trustie/utils/image'
require 'trustie/gitlab/api'
require 'trustie/grack/grack'
require 'trustie/at/at'
require 'trustie/sms/sms'

41
lib/trustie/sms/sms.rb Normal file
View File

@ -0,0 +1,41 @@
#coding=utf-8
require 'net/http'
require 'uri'
module Trustie
module Sms
def self.send(opt={})
Rails.logger.info "#{opt[:mobile]} - #{opt[:code]}"
begin
o = sendYunpian(opt[:mobile], opt[:code])
if o["code"] != 0
Rails.logger.error "发送短信出错: #{o['msg']}"
end
return o["code"] == 0
rescue => e
Rails.logger.error "发送短信出错: #{e}"
return false
end
end
def self.sendYunpian(mobile, code)
#修改为您的apikey.可在官网http://www.yunpian.com)登录后用户中心首页看到
apikey = '2affbf2ff83f9810512622ec83bccd4f'
#指定模板发送接口HTTP地址
send_tpl_sms_uri = URI.parse('https://sms.yunpian.com/v2/sms/tpl_single_send.json')
params = {}
params['apikey'] = apikey
params['mobile'] = mobile
#指定模板发送
#设置模板ID如使用1号模板:【#company#】您的验证码是#code#
#设置对应的模板变量值
params['tpl_id'] = 1733594
params['tpl_value'] = URI::escape('#code#')+'='+URI::escape(code)
response = Net::HTTP.post_form(send_tpl_sms_uri,params)
ActiveSupport::JSON.decode(response.body)
end
end
end

13
spec/utils/sms_spec.rb Normal file
View File

@ -0,0 +1,13 @@
#coding=utf-8
require 'rails_helper'
describe "短信发送" do
it "可以成功发送,当参数正确时" do
status = Trustie::Sms.send(mobile: "15388083362", code: '1234')
expect(status).to be true
end
end