This commit is contained in:
guange 2016-03-18 16:38:21 +08:00
commit 59923dfb03
11 changed files with 81 additions and 53 deletions

View File

@ -17,7 +17,7 @@ gem 'daemons'
gem 'grape', '~> 0.9.0'
gem 'grape-entity'
gem 'seems_rateable', '~> 1.0.13'
gem "rails", "3.2.13"
gem "rails", "~> 3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem 'coderay', '~> 1.1.0'

View File

@ -8,6 +8,15 @@ class AtController < ApplicationController
users = find_at_users(params[:type], params[:id])
@users = users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
#加上all
if @users.size > 0
allUser = Struct.new(:id, :name).new
allUser.id = @users.map{|u| u.id}.join(",")
allUser.name = "all"
@users.insert(0, allUser)
end
@users
end
private

View File

@ -84,7 +84,9 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal
# fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message,
act_as_at_message(:description, :author_id), :add_issues_count
after_update :be_user_score,:update_activity
after_destroy :down_user_score, :decrease_issues_count
# after_create :be_user_score
@ -165,12 +167,12 @@ class Issue < ActiveRecord::Base
end
# at 功能添加消息提醒
def act_as_at_message
users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end
end
# def act_as_at_message
# users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m
# users && users.flatten.uniq.each do |uid|
# self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
# end
# end
# 创建issue的时候issues_count加1
def add_issues_count

View File

@ -51,7 +51,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes, :add_journals_count
# fq
after_save :act_as_activity,:be_user_score, :act_as_forge_message, :act_as_at_message
after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id)
after_create :update_issue_time
# end
#after_destroy :down_user_score
@ -186,13 +186,6 @@ class Journal < ActiveRecord::Base
end
end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 更新用户分数 -by zjc
def be_user_score
#新建了缺陷留言且留言不为空,不为空白

View File

@ -68,7 +68,9 @@ class JournalsForMessage < ActiveRecord::Base
has_many :at_messages, as: :at_message, dependent: :destroy
validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message,
act_as_at_message(:notes, :user_id), :act_as_user_feedback_message,
:act_as_principal_activity, :act_as_student_score
after_create :reset_counters!
#after_update :update_activity
after_destroy :reset_counters!
@ -253,12 +255,7 @@ class JournalsForMessage < ActiveRecord::Base
end
end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 用户留言消息通知
def act_as_user_feedback_message
# 主留言

View File

@ -81,7 +81,8 @@ class Message < ActiveRecord::Base
after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity,
:act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id)
#before_save :be_user_score
scope :visible, lambda {|*args|
@ -287,13 +288,6 @@ class Message < ActiveRecord::Base
end
end
def act_as_at_message
users = self.content.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end
end
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖

View File

@ -1,6 +1,11 @@
[
<% @users && @users.each_with_index do |person,index| %>
<% if index == 0 %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% else %>
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% end %>
<% end %>
]

View File

@ -1,8 +1,8 @@
I18n.default_locale = 'en'
I18n.backend = Redmine::I18n::Backend.new
require 'redmine'
require 'trustie'
require 'redmine'
# Load the secret token from the Redmine configuration file
secret = Redmine::Configuration['secret_token']

View File

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

23
lib/trustie/at/at.rb Normal file
View File

@ -0,0 +1,23 @@
#coding=utf-8
module Trustie
module At
extend ActiveSupport::Concern
module ClassMethods
def act_as_at_message(content, send_id)
self.send :define_method, :act_as_at_message_func do
users = self[content].scan /<span class="at" data-user-id="(.+?)">/m
users && users.flatten.uniq.each do |uids|
uids.split(",").each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self[send_id])
end
end
end
end
end
end
end
ActiveRecord::Base.send(:include, Trustie::At)

View File

@ -32,30 +32,34 @@ $(function(){
return;
}
$.post(
'/student_work/program_test',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test},
function(data,status){
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
$.ajax({
url: '/student_work/program_test',
type: 'POST',
timeout: 60*1000,
data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
}).done(function(data){
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
}
);
}).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.")
}
});
};
$('#test-program-btn').on('click', test_program);