Merge branch 'develop' into 'develop'

issue详情页面一、二级回复、一级删除局部刷新



See merge request !80
This commit is contained in:
黄井泉 2016-12-23 14:35:51 +08:00
commit 4125c1b44a
38 changed files with 909 additions and 651 deletions

View File

@ -109,9 +109,9 @@ class DocumentsController < ApplicationController
attachments = Attachment.attach_files(@document, params[:attachments])
render_attachment_warning_if_needed(@document)
if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
Mailer.run.attachments_added(attachments[:files])
end
# if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
# # Mailer.run.attachments_added(attachments[:files])
# end
redirect_to document_url(@document)
end

View File

@ -524,7 +524,7 @@ class FilesController < ApplicationController
attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
# 发送邮件
Mailer.run.attachments_added(attachments[:files])
# Mailer.run.attachments_added(attachments[:files])
# 生成动态
attachments[:files].each do |file|
ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
@ -581,9 +581,9 @@ class FilesController < ApplicationController
end
attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.run.attachments_added(attachments[:files])
end
# if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
# # Mailer.run.attachments_added(attachments[:files])
# end
if !attachments.empty? && attachments[:files]
attachments[:files].each do |attachment|
if params[:publish_time]

View File

@ -284,7 +284,7 @@ class HomeworkCommonController < ApplicationController
@statue = 1
# 匿评开启消息邮件通知
send_message_anonymous_comment(@homework, m_status = 2)
Mailer.send_mail_anonymous_comment_open(@homework).deliver
# Mailer.send_mail_anonymous_comment_open(@homework).deliver
else
@statue = 2
@ -326,7 +326,7 @@ class HomeworkCommonController < ApplicationController
# 匿评关闭消息邮件通知
send_message_anonymous_comment(@homework, m_status = 3)
Mailer.send_mail_anonymous_comment_close(@homework).deliver
# Mailer.send_mail_anonymous_comment_close(@homework).deliver
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)

View File

@ -262,6 +262,7 @@ class IssuesController < ApplicationController
retrieve_previous_and_next_issue_ids
render :template => 'issues/show', :layout => @project_base_tag#by young
}
format.js
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf {
@ -586,12 +587,15 @@ class IssuesController < ApplicationController
update_forge_activity(@issue.class,@issue.id)
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@user_activity_id = params[:user_activity_id]
if params[:issue_id]
@issue_id = params[:issue_id]
end
@priorities = IssuePriority.active
respond_to do |format|
format.js
# Issue详情单独处理
if params[:is_issue_show]
format.js{redirect_to issue_path(@issue)}
else
format.js
end
end
end
end
@ -643,7 +647,11 @@ class IssuesController < ApplicationController
update_user_activity(@issue.class,@issue.id)
update_forge_activity(@issue.class,@issue.id)
respond_to do |format|
format.js
if params[:is_issue_show]
format.js{redirect_to issue_path(@issue)}
else
format.js
end
end
end
end
@ -655,23 +663,23 @@ class IssuesController < ApplicationController
# 非动态页面直接刷新,动态页面手动刷新
def delete_journal
@is_project = params[:is_project]
@issue = Issue.find(params[:id])
begin
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id])
forge_acts.destroy_all unless forge_acts.empty?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id])
at_message.destroy_all unless at_message.empty?
Journal.delete(params[:journal_id])
rescue Exception => e
puts e
end
@user_activity_id = params[:user_activity_id]
respond_to do |format|
if @user_activity_id
format.js
else
format.html{ redirect_to issue_url(@issue)}
end
@issue = Issue.find(params[:id])
begin
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id])
forge_acts.destroy_all unless forge_acts.empty?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id])
at_message.destroy_all unless at_message.empty?
Journal.delete(params[:journal_id])
rescue Exception => e
puts e
end
@user_activity_id = params[:user_activity_id]
respond_to do |format|
if @user_activity_id
format.js
else
format.js{ redirect_to issue_url(@issue)}
end
end
end

View File

@ -157,23 +157,33 @@ class MembersController < ApplicationController
project_info = []
if params[:membership]
if params[:membership][:user_ids]
attrs = params[:membership].dup
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
ActiveRecord::Base.transaction do
begin
attrs = params[:membership].dup
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
#给新成员发送加入项目的消息发送者id放在ForgeMessage的forge_message_id字段中
#forge_message_type设置为JoinProject
forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false)
forge_join.save
## added by nie
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager)
# ProjectInfo.create(:name => "test", :user_id => 123)
#给新成员发送加入项目的消息发送者id放在ForgeMessage的forge_message_id字段中
#forge_message_type设置为JoinProject
forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false)
forge_join.save
## added by nie
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager)
# ProjectInfo.create(:name => "test", :user_id => 123)
end
## end
end
rescue Gitlab::Error::Forbidden => e
@message = l(:label_pull_request_forbidden)
rescue Gitlab::Error::BadRequest => e
@message = "添加成员失败,可能是你添加的用户名中含有非法字符"
rescue Exception => e
puts e
end
## end
end
else
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
@ -297,26 +307,29 @@ class MembersController < ApplicationController
#增加对课程成员修改的支持
if @project
if params[:membership]
@member.role_ids = params[:membership][:role_ids]
#added by nie
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
if role.allowed_to?(:is_manager)
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
@projectInfo.save
else
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
ActiveRecord::Base.transaction do
begin
@member.role_ids = params[:membership][:role_ids]
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
if role.allowed_to?(:is_manager)
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
@projectInfo.save
else
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
end
end
@member.save!
rescue Exception => e
puts e
end
end
end
saved = @member.save
respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.js
@ -385,27 +398,33 @@ class MembersController < ApplicationController
#课程成员删除修改
if @project
if request.delete? && @member.deletable?
@member.destroy
# end
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
ActiveRecord::Base.transaction do
begin
@member.destroy
# end
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_grade.size > 0
user_grade.each do |grade|
grade.destroy
end
end
# 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除
applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => @member.user_id).first
unless applied_projects.nil?
applied_projects.delete
end
#移出项目发送消息
ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
rescue Exception => e
puts e
end
end
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_grade.size > 0
user_grade.each do |grade|
grade.destroy
end
end
# 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除
applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => @member.user_id).first
unless applied_projects.nil?
applied_projects.delete
end
#移出项目发送消息
ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
end
respond_to do |format|
format.html { redirect_to_settings_in_projects }

View File

@ -159,8 +159,8 @@ class MyController < ApplicationController
g = Gitlab.client
begin
g.edit_user(@user.gid, :email => params[:user][:mail])
rescue
logger.error "sync user's email of gitlab failed!"
rescue Exception => e
puts e
end
end

View File

@ -432,7 +432,7 @@ class ProjectsController < ApplicationController
# 如果已经邀请过该用户,则不重复发送
if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil?
email = params[:mail]
Mailer.request_member_to_project(email, @project, User.current).deliver
# Mailer.request_member_to_project(email, @project, User.current).deliver
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:notice_email_invited)
@ -445,7 +445,7 @@ class ProjectsController < ApplicationController
first_name = params[:first_name]
last_name = params[:last_name]
gender = params[:gender]
Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver
# Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver
@is_zhuce = false
flash[:notice] = l(:notice_email_sent, :value => email)
end
@ -458,13 +458,13 @@ class ProjectsController < ApplicationController
invite_list = InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first
if invite_list.nil?
email = params[:mail]
Mailer.request_member_to_project(email, @project, User.current).deliver
# Mailer.request_member_to_project(email, @project, User.current).deliver
flash[:notice] = l(:notice_email_sent, :value => email)
else
# 已经发送过了则隔3小时才能再次发送
if Time.now - invite_list.created_at > 10800
email = params[:mail]
Mailer.request_member_to_project(email, @project, User.current).deliver
# Mailer.request_member_to_project(email, @project, User.current).deliver
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:notice_email_invited)

View File

@ -35,7 +35,7 @@ class RepositoriesController < ApplicationController
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive, :export_rep_static]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :export_rep_static]
# 连接gitlab
# before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff]
@ -121,9 +121,15 @@ class RepositoriesController < ApplicationController
# 一键ZIP下载
def project_archive
g = Gitlab.client
g.get()
# g.project_archive(params[:gpid].to_i, params[:rev])
token = Gitlab.private_token
token = aes_encrypt(token, "abcd")
# g = Gitlab.client
# g.project_archive(@project.gpid, @rev)
# 'git archive --format zip --output /path/to/file.zip master' # 将 master 以zip格式打包到指定文件
#
# zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token
# f = open(zip_path).read
# send_file "/path/to/file.zip"
end
# 判断用户是否已经fork过该项目
@ -265,12 +271,23 @@ update
@repository.type = 'Repository::Gitlab'
@repository.identifier = @repository.identifier.downcase
@repository.url = @repository.identifier
if request.post? && @repository.save
s = Trustie::Gitlab::Sync.new
s.create_project(@project, @repository)
redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier))
else
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
ActiveRecord::Base.transaction do
begin
if request.post? && @repository.save
s = Trustie::Gitlab::Sync.new
s.create_project(@project, @repository)
raise "sync failed" if @project.gpid.blank?
redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier))
else
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
end
rescue Gitlab::Error::Forbidden => e
@message = l(:label_pull_request_forbidden)
rescue Gitlab::Error::NotFound => e
@message = l(:label_pull_request_notfound)
rescue Exception => e
puts e
end
end
end
end
@ -398,8 +415,12 @@ update
@creator = @project.owner.to_s
gitlab_address = Redmine::Configuration['gitlab_address']
# REDO:需优化,仅测试用
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token
gitlab_token = Gitlab.private_token
# token值加密解密
token = aes_encrypt("priEn3UwXfJs3Pmy", gitlab_token)
# token值解密
# gitlab_token = aes_dicrypt("priEn3UwXfJs3Pmy", token)
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + token
end
@creator = @project.owner.to_s

View File

@ -768,7 +768,7 @@ class UsersController < ApplicationController
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework_id].to_i)
if ah.empty?
ApplyHomework.create(:user_id => params[:id].to_i, :homework_common_id => params[:homework_id].to_i, :status => 1)
Mailer.run.apply_for_homework_request(homework, User.current)
# Mailer.run.apply_for_homework_request(homework, User.current)
CourseMessage.create(:user_id => homework.user_id, :course_id => homework.course.id, :viewed => false,:course_message_id=>params[:homework_id].to_i,:course_message_type=>'HomeworkCommon',:status=>5,:apply_user_id=>params[:id].to_i,:content=>params[:content])
@state = 2
@ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", params[:id].to_i, params[:homework_id].to_i).first

View File

@ -37,6 +37,23 @@ module ApplicationHelper
# super
# end
# 字符串加密
def aes_encrypt(key, encrypted_string)
aes = OpenSSL::Cipher::Cipher.new("AES-128-ECB")
aes.encrypt
aes.key = key
txt = aes.update(encrypted_string) << aes.final
txt.unpack('H*')[0].upcase
end
# 字符串解密
def aes_dicrypt(key, dicrypted_string)
aes = OpenSSL::Cipher::Cipher.new("AES-128-ECB")
aes.decrypt
aes.key = key
aes.update([dicrypted_string].pack('H*')) << aes.final
end
# 获取多种类型的user用户名
def user_message_username user
user.try(:show_name)

View File

@ -63,6 +63,11 @@ module PollHelper
def total_answer id
total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count
end
# 获取其它选项的答案
def other_answers poll_question
poll_question.poll_votes.select{|pv| !pv.try(:vote_text).blank?}
end
#页面体型显示
def options_show pq

View File

@ -64,9 +64,9 @@ class Comment < ActiveRecord::Base
end
def send_mail
if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
Mailer.run.news_comment_added(self)
end
# if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
# Mailer.run.news_comment_added(self)
# end
end
after_destroy :delete_kindeditor_assets

View File

@ -24,7 +24,7 @@ class Document < ActiveRecord::Base
after_save :be_user_score # user_score
after_destroy :down_user_score
acts_as_attachable :delete_permission => :delete_documents
after_create :send_mail
# after_create :send_mail
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# end
@ -89,7 +89,7 @@ class Document < ActiveRecord::Base
end
def send_mail
Mailer.run.document_added(self) if Setting.notified_events.include?('document_added')
# Mailer.run.document_added(self) if Setting.notified_events.include?('document_added')
end
end

View File

@ -31,7 +31,7 @@ class HomeworkCommon < ActiveRecord::Base
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail,:act_as_course_message
after_create :act_as_activity, :act_as_course_message
after_update :update_activity
after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets
@ -129,9 +129,9 @@ class HomeworkCommon < ActiveRecord::Base
end
def send_mail
if self.homework_detail_manual.comment_status != 0
Mailer.run.homework_added(self)
end
# if self.homework_detail_manual.comment_status != 0
# Mailer.run.homework_added(self)
# end
end
def is_program_homework?

View File

@ -19,10 +19,10 @@ class IssueObserver < ActiveRecord::Observer
def after_create(issue)
# 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送,
recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients
recipients.each do |rec|
Mailer.run.issue_add(issue,rec) if Setting.notified_events.include?('issue_added')
end
# recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients
# recipients.each do |rec|
# Mailer.run.issue_add(issue,rec) if Setting.notified_events.include?('issue_added')
# end
end
end

View File

@ -2,36 +2,36 @@ class IssueOverdue < ActiveRecord::Base
#缺陷到期后发送邮件提示
#只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。
def self.mail_issue
threads = []
issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null")
puts issues
issues.each do |issue|
thread = Thread.new do
while true
cur_issue = Issue.find issue.id
if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
break
end
if Time.now < Time.parse(cur_issue.due_date.to_s)
#休眠一个小时。。。
puts cur_issue.id.to_s
sleep 5
else
#发邮件
#puts "11" + issue.id.to_s
#Mailer.issue_expire(issue).deliver
recipients = issue.recipients
recipients.each do |rec|
Mailer.issue_edit(issue,rec).deliver
end
break
end
end
end
threads << thread
end
puts threads
return threads
# threads = []
# issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null")
# puts issues
# issues.each do |issue|
# thread = Thread.new do
# while true
# cur_issue = Issue.find issue.id
# if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
# break
# end
# if Time.now < Time.parse(cur_issue.due_date.to_s)
# #休眠一个小时。。。
# puts cur_issue.id.to_s
# sleep 5
# else
# #发邮件
# #puts "11" + issue.id.to_s
# #Mailer.issue_expire(issue).deliver
# recipients = issue.recipients
# recipients.each do |rec|
#
# Mailer.issue_edit(issue,rec).deliver
# end
# break
# end
# end
# end
# threads << thread
# end
# puts threads
# return threads
end
end

View File

@ -17,18 +17,18 @@
class JournalObserver < ActiveRecord::Observer
def after_create(journal)
if journal.notify? &&
(Setting.notified_events.include?('issue_updated') ||
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
(Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
(Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
)
# 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送,
recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients
recipients.each do |rec|
Mailer.run.issue_edit(journal,rec)
end
end
# if journal.notify? &&
# (Setting.notified_events.include?('issue_updated') ||
# (Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
# (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
# (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
# )
# # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送,
# recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients
# recipients.each do |rec|
#
# Mailer.run.issue_edit(journal,rec)
# end
# end
end
end

View File

@ -50,59 +50,59 @@ class Mailer < ActionMailer::Base
# 作业匿评开启
def send_mail_anonymous_comment_open(homework_common)
course = homework_common.course
recipients ||= []
course.members.each do |member|
user = User.find(member.user_id)
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
@token = Token.get_token_from_user(user, 'autologin')
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
@anonymous_comment_close_name = homework_common.name
@author = homework_common.user
#收件人邮箱
recipients << user.mail
end
mail :to => recipients,
:subject => @subject
# course = homework_common.course
# recipients ||= []
# course.members.each do |member|
# user = User.find(member.user_id)
# @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
# @token = Token.get_token_from_user(user, 'autologin')
# @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
# @anonymous_comment_close_name = homework_common.name
# @author = homework_common.user
# #收件人邮箱
# recipients << user.mail
# end
# mail :to => recipients,
# :subject => @subject
end
# 作业匿评关闭
def send_mail_anonymous_comment_close(homework_common)
course = homework_common.course
recipients ||= []
course.members.each do |member|
user = User.find(member.user_id)
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_close)}"
@token = Token.get_token_from_user(user, 'autologin')
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
@anonymous_comment_close_name = homework_common.name
@author = homework_common.user
#收件人邮箱
recipients << user.mail
end
mail :to => recipients,
:subject => @subject
# course = homework_common.course
# recipients ||= []
# course.members.each do |member|
# user = User.find(member.user_id)
# @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_close)}"
# @token = Token.get_token_from_user(user, 'autologin')
# @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
# @anonymous_comment_close_name = homework_common.name
# @author = homework_common.user
# #收件人邮箱
# recipients << user.mail
# end
# mail :to => recipients,
# :subject => @subject
end
# 匿评失败给老师发送邮件通知
def send_mail_anonymous_comment_fail(homework_common)
course = homework_common.course
recipients ||= []
# 只给该课程的老师发送邮件提醒
course.members.each do |member|
if member.user.allowed_to?(:as_teacher,course)
user = User.find(member.user_id)
@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
@token = Token.get_token_from_user(user, 'autologin')
@anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
@anonymous_comment_fail_name = homework_common.name
@author = homework_common.user
#收件人邮箱
recipients << user.mail
end
end
mail :to => recipients,
:subject => @subject
# course = homework_common.course
# recipients ||= []
# # 只给该课程的老师发送邮件提醒
# course.members.each do |member|
# if member.user.allowed_to?(:as_teacher,course)
# user = User.find(member.user_id)
# @subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
# @token = Token.get_token_from_user(user, 'autologin')
# @anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
# @anonymous_comment_fail_name = homework_common.name
# @author = homework_common.user
# #收件人邮箱
# recipients << user.mail
# end
# end
# mail :to => recipients,
# :subject => @subject
end
# author: alan
@ -146,149 +146,149 @@ class Mailer < ActionMailer::Base
end
# 邀请信息消息 注forge_message_id 为邀请人ID(特殊情况)
def send_message_request_member(user, project)
key = newpass(6).to_s
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
end
# def send_message_request_member(user, project)
# key = newpass(6).to_s
# ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
# end
# author: alan
# 根据用户选择发送个人日报或周报
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
date_from = "#{date_from} 17:59:59"
date_to = "#{date_to} 17:59:59"
# 生成token用于直接点击登录
@user = user
@token = Token.get_token_from_user(user, 'autologin')
# 查询user参加的项目及课程
projects = user.projects
courses = user.courses
project_ids = projects.map{|project| project.id}.join(",")
course_ids = courses.map {|course| course.id}.join(",")
# 查询user的缺陷项目中成员都能收到
sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}'
and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.project_id, i.updated_on desc"
@issues = Issue.find_by_sql(sql)
# issue回复
@issues_journals = Journal.find_by_sql("select j.* from journals j, members m, projects p, issues i
where m.user_id = '#{user.id}' and p.id = m.project_id and i.project_id = p.id and j.journalized_id = i.id
and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by i.project_id, created_on desc")
# @bids 查询课程作业包括老师发布的作业以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
@bids ||= [] # 老师发布的作业
unless courses.first.nil?
count = courses.count
count = count - 1
for i in 0..count do
bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'")
@bids += bids if bids.count > 0
@attachments += attachments if attachments.count > 0
end
# @bids = @bids.sort_by { |obj| obj.created_at }
end
# 项目附件
@project_attachments = Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a
where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, a.created_on desc")
# user 提交的作业
# @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
# 查询user所在项目添加wiki
@wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where
m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0
and (wc.updated_on between '#{date_from}' and '#{date_to}') order by m.project_id, updated_on desc")
# 查询user在课程中发布的讨论帖子
course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
b.id = me.board_id and b.course_id = m.course_id
and b.course_id is not Null and m.user_id = '#{user.id}'
and (me.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
# 查询user在项目中发布的讨论帖子
project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
b.id = me.board_id and b.project_id = m.project_id
and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
# messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@course_messages ||= []
@project_messages ||= []
unless course_mesages.first.nil?
course_mesages.each do |msg|
@course_messages << msg
end
end
unless project_messages.first.nil?
project_messages.each do |msg|
@project_messages << msg
end
end
# wiki
# 查询user在课程中发布的通知和回复通知
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
where n.course_id in (#{course_ids})
and (created_on between '#{date_from}' and '#{date_to}') order by n.course_id, created_on desc") : []
@course_news_comments = Comment.find_by_sql("select cm.* from comments cm, members m, courses c, news n
where m.user_id = '#{user.id}' and c.id = m.course_id and n.course_id = c.id and cm.commented_id = n.id
and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
# 查询user在项目中添加新闻和回复新闻
@project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
and (created_on between '#{date_from}' and '#{date_to}') order by n.project_id, created_on desc") : []
@project_news_comments = Comment.find_by_sql("select c.* from comments c, members m, projects p, news n
where m.user_id = '#{user.id}' and p.id = m.project_id and n.project_id = p.id and c.commented_id = n.id
and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
# 查询user在课程及个人中留言
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c
where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id
and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
@user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
# 查询user在项目中留言用户反馈
@project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p
where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id
and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
# 查询user新建贴吧或发布帖子
@forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
@memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments,
@course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?}
total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count +
@project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count +
@bids.count + @wiki_contents.count
subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]"
@subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}"
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发
mail :to => user.mail,:subject => @subject if has_content
# date_from = date_to - days.days
# date_from = "#{date_from} 17:59:59"
# date_to = "#{date_to} 17:59:59"
# # 生成token用于直接点击登录
# @user = user
# @token = Token.get_token_from_user(user, 'autologin')
#
# # 查询user参加的项目及课程
# projects = user.projects
# courses = user.courses
# project_ids = projects.map{|project| project.id}.join(",")
# course_ids = courses.map {|course| course.id}.join(",")
#
# # 查询user的缺陷项目中成员都能收到
# sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}'
# and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.project_id, i.updated_on desc"
# @issues = Issue.find_by_sql(sql)
#
# # issue回复
# @issues_journals = Journal.find_by_sql("select j.* from journals j, members m, projects p, issues i
# where m.user_id = '#{user.id}' and p.id = m.project_id and i.project_id = p.id and j.journalized_id = i.id
# and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by i.project_id, created_on desc")
#
# # @bids 查询课程作业包括老师发布的作业以及user提交作业
# # @attachments查询课程课件更新
# @attachments ||= []
# @bids ||= [] # 老师发布的作业
# unless courses.first.nil?
# count = courses.count
# count = count - 1
# for i in 0..count do
# bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
# attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'")
# @bids += bids if bids.count > 0
# @attachments += attachments if attachments.count > 0
# end
# # @bids = @bids.sort_by { |obj| obj.created_at }
# end
#
# # 项目附件
# @project_attachments = Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a
# where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, a.created_on desc")
#
# # user 提交的作业
# # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
#
# # 查询user所在项目添加wiki
# @wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where
# m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0
# and (wc.updated_on between '#{date_from}' and '#{date_to}') order by m.project_id, updated_on desc")
#
# # 查询user在课程中发布的讨论帖子
# course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
# b.id = me.board_id and b.course_id = m.course_id
# and b.course_id is not Null and m.user_id = '#{user.id}'
# and (me.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
#
# # 查询user在项目中发布的讨论帖子
# project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
# b.id = me.board_id and b.project_id = m.project_id
# and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
# # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
# @course_messages ||= []
# @project_messages ||= []
# unless course_mesages.first.nil?
# course_mesages.each do |msg|
# @course_messages << msg
# end
# end
# unless project_messages.first.nil?
# project_messages.each do |msg|
# @project_messages << msg
# end
# end
# # wiki
#
# # 查询user在课程中发布的通知和回复通知
# @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
# where n.course_id in (#{course_ids})
# and (created_on between '#{date_from}' and '#{date_to}') order by n.course_id, created_on desc") : []
#
# @course_news_comments = Comment.find_by_sql("select cm.* from comments cm, members m, courses c, news n
# where m.user_id = '#{user.id}' and c.id = m.course_id and n.course_id = c.id and cm.commented_id = n.id
# and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
#
# # 查询user在项目中添加新闻和回复新闻
# @project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
# and (created_on between '#{date_from}' and '#{date_to}') order by n.project_id, created_on desc") : []
#
# @project_news_comments = Comment.find_by_sql("select c.* from comments c, members m, projects p, news n
# where m.user_id = '#{user.id}' and p.id = m.project_id and n.project_id = p.id and c.commented_id = n.id
# and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
#
# # 查询user在课程及个人中留言
# @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c
# where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id
# and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
#
# @user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
#
# # 查询user在项目中留言用户反馈
# @project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p
# where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id
# and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
#
# # 查询user新建贴吧或发布帖子
# @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
# @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
# and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
#
# has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments,
# @course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?}
# total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count +
# @project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count +
# @bids.count + @wiki_contents.count
# subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]"
# @subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}"
# mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
# #有内容才发,没有不发
# mail :to => user.mail,:subject => @subject if has_content
end
# 作业截止时间邮件提醒
def homework_endtime__added(homework_common, user_id)
user = User.find(user_id)
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_homework_endtime)} "
@token = Token.get_token_from_user(user, 'autologin')
@homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
@homework_endtime_name = homework_common.name
@author = homework_common.user
#收件人邮箱
recipient = user.mail
mail :to => recipient,
:subject => @subject
# user = User.find(user_id)
# @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_homework_endtime)} "
# @token = Token.get_token_from_user(user, 'autologin')
# @homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
# @homework_endtime_name = homework_common.name
# @author = homework_common.user
# #收件人邮箱
# recipient = user.mail
# mail :to => recipient,
# :subject => @subject
end
# 公共讨论区发帖、回帖添加邮件发送信息
@ -382,20 +382,20 @@ class Mailer < ActionMailer::Base
# issue截止时间提醒
def issue_due_date(issue)
recipients ||= []
if issue.author.id != issue.assigned_to_id
recipients << issue.author.mail
end
# 被指派人邮箱地址加入数组
recipients << issue.assigned_to.mail
# cc = wiki_content.page.wiki.watcher_recipients - recipients
@author = issue.author
@issue_name = issue.subject
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
@subject = "#{l(:mail_issue)}#{issue.subject} #{l(:mail_issue_due_date)} "
mail :to => recipients,
:subject => @subject
# recipients ||= []
# if issue.author.id != issue.assigned_to_id
# recipients << issue.author.mail
# end
#
# # 被指派人邮箱地址加入数组
# recipients << issue.assigned_to.mail
# # cc = wiki_content.page.wiki.watcher_recipients - recipients
# @author = issue.author
# @issue_name = issue.subject
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
# @subject = "#{l(:mail_issue)}#{issue.subject} #{l(:mail_issue_due_date)} "
# mail :to => recipients,
# :subject => @subject
end
# Builds a Mail::Message object used to email recipients of the added issue.
@ -404,31 +404,31 @@ class Mailer < ActionMailer::Base
# issue_add(issue) => Mail::Message object
# Mailer.issue_add(issue).deliver => sends an email to issue recipients
def issue_add(issue, recipients)
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => issue_id,
'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id issue
@author = issue.author
@issue = issue
user = User.find_by_mail(recipients)
@user = user
# @token = Token.get_token_from_user(user, 'autologin')
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
# edit
@issue_author_url = url_for(user_activities_url(@author))
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id)
@user_url = url_for(my_account_url(user))
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
mail :to => recipients,
:subject => subject,
:filter => true
# issue_id = issue.project_index
# redmine_headers 'Project' => issue.project.identifier,
# 'Issue-Id' => issue_id,
# 'Issue-Author' => issue.author.login
# redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
# message_id issue
#
# @author = issue.author
# @issue = issue
# user = User.find_by_mail(recipients)
# @user = user
# # @token = Token.get_token_from_user(user, 'autologin')
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
#
# # edit
# @issue_author_url = url_for(user_activities_url(@author))
# @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id)
#
# @user_url = url_for(my_account_url(user))
#
#
# subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
# mail :to => recipients,
# :subject => subject,
# :filter => true
end
# issue.attachments.each do |attach|
# attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
@ -445,36 +445,36 @@ class Mailer < ActionMailer::Base
# issue_edit(journal) => Mail::Message object
# Mailer.issue_edit(journal).deliver => sends an email to issue recipients
def issue_edit(journal,recipients)
issue = journal.journalized.reload
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => issue_id.to_s,
'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id journal
references issue
@author = journal.user
user = User.find_by_mail(recipients)
@user = user
# @token = Token.get_token_from_user(user, 'autologin')
# edit
@issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id)
@user_url = url_for(my_account_url(user))
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}")
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject
@issue = issue
@journal = journal
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
mail :to => recipients,
:subject => s,
:filter => true
# issue = journal.journalized.reload
# issue_id = issue.project_index
# redmine_headers 'Project' => issue.project.identifier,
# 'Issue-Id' => issue_id.to_s,
# 'Issue-Author' => issue.author.login
# redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
# message_id journal
# references issue
# @author = journal.user
#
# user = User.find_by_mail(recipients)
# @user = user
# # @token = Token.get_token_from_user(user, 'autologin')
#
#
# # edit
# @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id)
# @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id)
# @user_url = url_for(my_account_url(user))
#
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}")
# s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
# s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
# s << issue.subject
# @issue = issue
# @journal = journal
# # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
# mail :to => recipients,
# :subject => s,
# :filter => true
end
def self.deliver_mailer(to,cc, subject)
@ -510,19 +510,19 @@ class Mailer < ActionMailer::Base
#缺陷到期邮件通知
def issue_expire issue
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => issue_id,
'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id issue
@author = issue.author
@issue = issue
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
recipients = issue.recipients
s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
mail :to => recipients,
:subject => s
# issue_id = issue.project_index
# redmine_headers 'Project' => issue.project.identifier,
# 'Issue-Id' => issue_id,
# 'Issue-Author' => issue.author.login
# redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
# message_id issue
# @author = issue.author
# @issue = issue
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
# recipients = issue.recipients
# s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
# mail :to => recipients,
# :subject => s
#########################################################################################################
#@issues = issues
#s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
@ -627,19 +627,19 @@ class Mailer < ActionMailer::Base
# attachments_added(attachments) => Mail::Message object
# Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients
def homework_added(homework_common)
logger.info "homework added"
@homework_common = homework_common
@author = homework_common.user
@homework_common_url = url_for(:controller => "homework_common", :action =>"index", :homework => @homework_common.id)
@homework_author_url = url_for(user_activities_url(@author))
recipients ||= []
#将帖子创建者邮箱地址加入数组
@homework_common.course.members.each do |member|
recipients << member.user.mail
end
mail :to => recipients,
:subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]",
:filter => true
# logger.info "homework added"
# @homework_common = homework_common
# @author = homework_common.user
# @homework_common_url = url_for(:controller => "homework_common", :action =>"index", :homework => @homework_common.id)
# @homework_author_url = url_for(user_activities_url(@author))
# recipients ||= []
# #将帖子创建者邮箱地址加入数组
# @homework_common.course.members.each do |member|
# recipients << member.user.mail
# end
# mail :to => recipients,
# :subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]",
# :filter => true
end
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
@ -649,28 +649,28 @@ class Mailer < ActionMailer::Base
# Mailer.news_added(news).deliver => sends an email to the news' project recipients
def news_added(news)
if news.project
# redmine_headers 'Project' => news.project.identifier
# @author = news.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id news
# @news = news
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# mail :to => news.recipients,
# :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = news.author
@issue_author_url = url_for(user_activities_url(@author))
message_id news
@news = news
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => recipients,
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
:filter => true
end
# if news.project
# # redmine_headers 'Project' => news.project.identifier
# # @author = news.author
# # @issue_author_url = url_for(user_activities_url(@author))
# # message_id news
# # @news = news
# # @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# # mail :to => news.recipients,
# # :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
# # :filter => true
# elsif news.course
# redmine_headers 'Course' => news.course.id
# @author = news.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id news
# @news = news
# recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# mail :to => recipients,
# :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
# end
end
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
@ -679,33 +679,33 @@ class Mailer < ActionMailer::Base
# news_comment_added(comment) => Mail::Message object
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
def news_comment_added(comment)
news = comment.commented
if news.project
# redmine_headers 'Project' => news.project.identifier
# @author = comment.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id comment
# @news = news
# @comment = comment
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# mail :to => news.recipients,
# :cc => news.watcher_recipients,
# :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = comment.author
@issue_author_url = url_for(user_activities_url(@author))
message_id comment
@news = news
@comment = comment
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
mail :to => recipients,
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
:filter => true
end
# news = comment.commented
# if news.project
# # redmine_headers 'Project' => news.project.identifier
# # @author = comment.author
# # @issue_author_url = url_for(user_activities_url(@author))
# # message_id comment
# # @news = news
# # @comment = comment
# # @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# # mail :to => news.recipients,
# # :cc => news.watcher_recipients,
# # :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
# # :filter => true
# elsif news.course
# redmine_headers 'Course' => news.course.id
# @author = comment.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id comment
# @news = news
# @comment = comment
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
#
# mail :to => recipients,
# :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
# end
end
# Builds a Mail::Message object used to email the recipients of the specified message that was posted.
@ -1032,21 +1032,21 @@ class Mailer < ActionMailer::Base
end
def join_course_request(course, user, role)
@receive = User.find(course.tea_id)
@course = course
@user = user
@role = role
@subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} "
mail :to => @receive.mail,
:subject => @subject
# @receive = User.find(course.tea_id)
# @course = course
# @user = user
# @role = role
# @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} "
# mail :to => @receive.mail,
# :subject => @subject
end
def apply_for_homework_request(homework, user)
@receive = User.find(homework.user_id)
@user = user
@subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} "
mail :to => @receive.mail,
:subject => @subject
# @receive = User.find(homework.user_id)
# @user = user
# @subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} "
# mail :to => @receive.mail,
# :subject => @subject
end
private

View File

@ -124,7 +124,7 @@ class Memo < ActiveRecord::Base
end
def send_mail
Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added')
# Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added')
end
def creator_user
@ -218,9 +218,9 @@ class Memo < ActiveRecord::Base
end
def send_notification
if Setting.notified_events.include?('message_posted')
Mailer.run.message_posted(self)
end
# if Setting.notified_events.include?('message_posted')
# Mailer.run.message_posted(self)
# end
end
def plusParentAndForum

View File

@ -389,7 +389,7 @@ class Message < ActiveRecord::Base
end
def send_mail
Mailer.run.message_posted(self) if Setting.notified_events.include?('message_posted')
# Mailer.run.message_posted(self) if Setting.notified_events.include?('message_posted')
end
# Time 2015-03-31 09:15:06

View File

@ -65,7 +65,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send
after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send
after_update :update_activity
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
@ -241,7 +241,7 @@ class News < ActiveRecord::Base
end
def send_mail
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
# Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
end
def delete_org_activities

View File

@ -158,9 +158,9 @@ class RelativeMemo < ActiveRecord::Base
end
def send_notification
if Setting.notified_events.include?('message_posted')
Mailer.run.message_posted(self)
end
# if Setting.notified_events.include?('message_posted')
# Mailer.run.message_posted(self)
# end
end
# def plusParentAndForum

View File

@ -17,12 +17,12 @@
class WikiContentObserver < ActiveRecord::Observer
def after_create(wiki_content)
Mailer.run.wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added')
# Mailer.run.wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added')
end
def after_update(wiki_content)
if wiki_content.text_changed?
Mailer.run.wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated')
end
# if wiki_content.text_changed?
# Mailer.run.wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated')
# end
end
end

View File

@ -658,7 +658,7 @@ class CoursesService
@state = 7
end
else
Mailer.run.join_course_request(course, current_user, params[:role])
# Mailer.run.join_course_request(course, current_user, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>current_user.id,:course_message_type=>'JoinCourseRequest',:status=>0)
#----------------微信通知----------------------

View File

@ -232,25 +232,27 @@ class UsersService
#修改密码
def change_password params
@current_user = User.find(params[:current_user_id])
if @current_user.check_password?(params[:password])
@current_user.password, @current_user.password_confirmation = params[:new_password], params[:new_password_confirmation]
@current_user.save
# 修改密码同步gitlab密码修改
unless @current_user.gid.nil?
begin
g = Gitlab.client
g.edit_user(@current_user.gid, :password => params[:new_password])
rescue Exception => e
logger.error "change users password failed! ===> #{e}"
ActiveRecord::Base.transaction do
@current_user = User.find(params[:current_user_id])
if @current_user.check_password?(params[:password])
@current_user.password, @current_user.password_confirmation = params[:new_password], params[:new_password_confirmation]
@current_user.save
# 修改密码同步gitlab密码修改
unless @current_user.gid.nil?
begin
g = Gitlab.client
g.edit_user(@current_user.gid, :password => params[:new_password])
rescue Exception => e
logger.error "change users password failed! ===> #{e}"
end
end
end
#raise @current_user.errors.full_message
#return @current_user
else
raise l(:notice_account_wrong_password,:locale => 'zh')
else
raise l(:notice_account_wrong_password,:locale => 'zh')
end
@current_user
end
@current_user
end
#搜索用户

View File

@ -28,7 +28,7 @@
<%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %>
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
<%= link_to(
l(:button_reply),
{:controller => 'issues', :action => 'reply', :user_id => comment.user_id, :id => issue.id, :journal_id => comment.id},
:remote => true,
@ -36,10 +36,11 @@
:title => l(:button_reply)) %>
<span id="reply_iconup_<%= comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<%= link_to(
<%= link_to(
l(:button_delete),
{:controller => 'issues',:action => 'delete_journal', :id => issue.id,:journal_id=>comment.id},
{:controller => 'issues',:action => 'delete_journal', :id => issue.id, :journal_id=>comment.id},
:method => :get,
:remote => true,
:id => "delete_reply_#{comment.id}",
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
@ -64,7 +65,7 @@
<div class="homepagePostReplyInputContainer mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= @issue.id %>' style="display:none;">
<%= form_for('new_form', :url => add_journal_issue_path(@issue.id), :method => "post", :remote => true) do |f| %>
<%= form_for('new_form', :url => add_journal_issue_path(@issue.id, :is_issue_show => true), :method => "post", :remote => true) do |f| %>
<input type="hidden" name="issue_id" value="<%=@issue.id%>"/>
<div nhname='toolbar_container_<%= @issue.id %>' ></div>
<div class="cl"></div>

View File

@ -7,7 +7,7 @@
<div class="ReplyToMessageInputContainer">
<% if User.current.logged? %>
<div nhname='new_message_<%= @jour.id%>' style="display:none;">
<%= form_for('new_form',:url => add_reply_issue_path(@issue.id),:method => "post", :remote => true) do |f|%>
<%= form_for('new_form',:url => add_reply_issue_path(@issue.id, :is_issue_show => true),:method => "post", :remote => true) do |f|%>
<input type="hidden" name="journal_id" value="<%=@jour.id%>"/>
<div nhname='toolbar_container_<%= @jour.id%>' ></div>
<div class="cl"></div>

View File

@ -1,10 +1,4 @@
/* $("#reply_div_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue}) %>");
$("#issue_detail_show").html('<%#= escape_javascript(render :partial => 'issues/detail') %>');
$("#issue_edit_show").html('<%#= escape_javascript(render :partial => 'issues/edit') %>');
$("#div_issue_attachment_<%#=@issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>");
sd_create_editor_from_data(<%#= @issue.id %>, null, "100%", "<%#= @issue.class.name %>");*/
location.reload();
$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>");
issue_desc_editor = KindEditor.create('#issue_description',
{"width":"85%",
"resizeType":0,
@ -18,6 +12,5 @@ issue_desc_editor = KindEditor.create('#issue_description',
"allowFileManager":true,
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"});
// $("#issue_test_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/edit', :locals => {:issue => Issue.find( @issue_id)}) %>");
// $(".homepagePostReplyBannerCount").html('<%#= escape_javascript(render :partial => 'issues/issue_reply_banner') %>');
// sd_create_editor_from_data(<%#= @issue.id%>, null, "100%","<%#= @issue.class.name %>");
$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>');
sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%= @issue.class.name %>");

View File

@ -1,6 +1,3 @@
<% if @issue_id %> //issue详情中回复
<%= render "jounal_refresh" %>
<%else%>
<% if params[:is_project] %>
$("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @issue, :user_activity_id => @user_activity_id}) %>");
<% else %>
@ -8,6 +5,6 @@ $("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(r
<% end %>
sd_create_editor_from_data(<%= @user_activity_id %>, null, "100%", "UserActivity");
//init_activity_KindEditor_data(<%= @user_activity_id %>,"","87%", 'UserActivity');
//init_activity_KindEditor_data(<%#= @user_activity_id %>,"","87%", 'UserActivity');
// sd_create_editor_from_data(<%#= @issue.id%>, null, "100%");
<%end %>

View File

@ -0,0 +1,19 @@
$("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @issue, :user_activity_id => @user_activity_id}) %>");
$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue}) %>");
$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>");
issue_desc_editor = KindEditor.create('#issue_description',
{"width":"85%",
"resizeType":0,
"no_label":true,
"at_id":<%= @issue.project_id%>,
"at_type":"Project",
"autoHeightMode":true,
"afterCreate":"eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);};if(typeof enableAt ==='function'){enableAt(self, \"<%=@issue.project_id %>\", 'Project');}; this.loadPlugin('autoheight')})",
"emotionsBasePath":'<%= Setting.host_name%>',
"height":300,
"allowFileManager":true,
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"});
$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>');
sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%= @issue.class.name %>");

View File

@ -1,28 +1,63 @@
<div class="ur_table_result">
<table border="0" cellspacing="0" cellpadding="0" >
<tbody>
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_options) %> </td>
<td class="td42"><%= l(:label_poll_subtotal) %> </td>
<td class="td287"><%= l(:label_poll_proportion) %> </td>
</tr>
<% poll_question.poll_answers.each do |poll_answer| %>
<tr>
<td class="td327"><%= poll_answer.answer_text == "" ? "其他" :poll_answer.answer_text %> </td>
<td class="td42"><%= poll_answer.poll_votes.count %> </td>
<td class="td287">
<div class="Bar">
<span style="width:<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%;" id="choice_percentage_<%= poll_answer.id %>"></span>
</div>
<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%</td>
</tr>
<% end %>
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_valid_commit) %> </td>
<td class="td42"><%= total_answer(poll_question.id) %></td>
<td class="td287">&nbsp; </td>
</tr>
</tbody>
</table>
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_options) %> </td>
<td class="td42"><%= l(:label_poll_subtotal) %> </td>
<td class="td287"><%= l(:label_poll_proportion) %> </td>
</tr>
<% poll_question.poll_answers.each do |poll_answer| %>
<tr>
<td class="td327">
<% if poll_answer.answer_text == "" %>
其它<a onclick="hidden_others(<%= poll_question.id %>, <%= poll_answer.id %>);" class="c_blue fr mr5" id ="other_answer_<%= poll_answer.id %>"><%= "隐藏" if other_answers(poll_question).count > 0 %></a>
<% else %>
<%= poll_answer.answer_text %>
<% end %>
</td>
<td class="td42"><%= poll_answer.poll_votes.count %> </td>
<td class="td287">
<div class="Bar">
<span style="width:<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%;" id="choice_percentage_<%= poll_answer.id %>"></span>
</div>
<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%</td>
</tr>
<% end %>
</tbody>
</table>
<div id="other_tip_<%= poll_question.id %>" style="display: block">
<% if other_answers(poll_question).count > 0 %>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr class="table_bluebg"><td class="pl5 w607">其它(详情)</td></tr>
<% other_answers(poll_question).each do |pv| %>
<tr><td class="pl5 w607"><%= pv.vote_text %></td></tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_valid_commit) %> </td>
<td class="td42"><%= total_answer(poll_question.id) %></td>
<td class="td287">&nbsp; </td>
</tr>
</table>
</div>
<script>
function hidden_others(id1, id2){
var other_answer = document.getElementById("other_answer_"+id2).innerText;
if (other_answer == "隐藏")
{
$("#other_answer_"+id2).text("显示");
$("#other_tip_"+id1).hide();
}
else
{
$("#other_answer_"+id2).text("隐藏");
$("#other_tip_"+id1).show();
}
}
</script>

View File

@ -13,6 +13,6 @@
</div>
<% end %>
<% if params[:action] == "commit_diff" %>
<div class="fr">Commit<a class="ml5" style="color: #3498db"><%= changeset.id %></a></div>
<div class="fr">Commit<a class="ml5" style="color: #999;"><%= changeset.id %></a></div>
<% end %>
</div>

View File

@ -0,0 +1,9 @@
class UpdateUserMailNotification < ActiveRecord::Migration
def up
sql = "update `users` set mail_notification ='all' where mail_notification in ('day','week');"
execute(sql)
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20161208015939) do
ActiveRecord::Schema.define(:version => 20161223030701) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -325,14 +325,16 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
create_table "changesets", :force => true do |t|
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.string "committer"
t.datetime "committed_on", :null => false
t.datetime "committed_on", :null => false
t.text "comments"
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
@ -426,6 +428,14 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "comments", ["author_id"], :name => "index_comments_on_author_id"
add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type"
create_table "commit_issues", :force => true do |t|
t.string "commit_id"
t.integer "issue_id"
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "commits", :force => true do |t|
t.integer "repository_id"
t.string "version"
@ -437,54 +447,123 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.datetime "updated_at", :null => false
end
create_table "contest_notifications", :force => true do |t|
t.text "title"
create_table "contest_activities", :force => true do |t|
t.integer "user_id"
t.integer "contest_id"
t.integer "contest_act_id"
t.string "contest_act_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contest_activities", ["contest_id"], :name => "index_contest_activities_on_contest_id"
add_index "contest_activities", ["user_id"], :name => "index_contest_activities_on_user_id"
create_table "contest_member_roles", :force => true do |t|
t.integer "contest_member_id"
t.integer "role_id"
t.boolean "is_current", :default => true
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contest_member_roles", ["contest_member_id"], :name => "index_contest_member_roles_on_contest_member_id"
add_index "contest_member_roles", ["role_id"], :name => "index_contest_member_roles_on_role_id"
create_table "contest_members", :force => true do |t|
t.integer "user_id"
t.integer "contest_id"
t.boolean "is_collect", :default => true
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contest_members", ["contest_id"], :name => "index_contest_members_on_contest_id"
add_index "contest_members", ["user_id"], :name => "index_contest_members_on_user_id"
create_table "contest_messages", :force => true do |t|
t.integer "user_id"
t.integer "contest_id"
t.integer "contest_message_id"
t.string "course_message_type"
t.boolean "viewed", :default => false
t.text "content"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
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 "contestant_for_contests", :force => true do |t|
t.integer "student_id"
t.integer "contest_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
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
add_index "contestant_for_contests", ["contest_id"], :name => "index_contestant_for_contests_on_contest_id"
add_index "contestant_for_contests", ["student_id"], :name => "index_contestant_for_contests_on_student_id"
create_table "contesting_softapplications", :force => true do |t|
t.integer "softapplication_id"
create_table "contestant_work_projects", :force => true do |t|
t.integer "contest_id"
t.integer "work_id"
t.integer "contestant_work_id"
t.integer "project_id"
t.integer "user_id"
t.string "description"
t.boolean "is_leader"
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
add_index "contestant_work_projects", ["contest_id"], :name => "index_contestant_work_projects_on_contest_id"
add_index "contestant_work_projects", ["contestant_work_id"], :name => "index_contestant_work_projects_on_contestant_work_id"
add_index "contestant_work_projects", ["user_id"], :name => "index_contestant_work_projects_on_user_id"
add_index "contestant_work_projects", ["work_id"], :name => "index_contestant_work_projects_on_work_id"
create_table "contestant_work_scores", :force => true do |t|
t.integer "contestant_work_id"
t.integer "user_id"
t.integer "score"
t.text "comment"
t.integer "reviewer_role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contestant_work_scores", ["contestant_work_id"], :name => "index_contestant_work_scores_on_contestant_work_id"
add_index "contestant_work_scores", ["user_id"], :name => "index_contestant_work_scores_on_user_id"
create_table "contestant_works", :force => true do |t|
t.string "name"
t.text "description"
t.integer "work_id"
t.integer "user_id"
t.float "work_score"
t.integer "project_id"
t.integer "work_status"
t.datetime "commit_time"
t.boolean "is_delete", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contestant_works", ["project_id"], :name => "index_contestant_works_on_project_id"
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 "contests", :force => true do |t|
t.integer "user_id"
t.string "name"
t.string "budget", :default => ""
t.integer "author_id"
t.date "deadline"
t.string "description"
t.integer "commit"
t.string "password"
t.datetime "created_on", :null => false
t.datetime "updated_on", :null => false
t.text "description"
t.boolean "is_public"
t.boolean "is_delete", :default => false
t.integer "visits", :default => 0
t.string "invite_code"
t.integer "invite_code_halt", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_activities", :force => true do |t|
@ -516,20 +595,6 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "container_id", :default => 0
end
create_table "course_class_post", :id => false, :force => true do |t|
t.integer "班级id", :default => 0, :null => false
t.string "班级名"
t.integer "帖子id", :default => 0, :null => false
t.integer "主贴id"
t.string "帖子标题", :default => "", :null => false
t.text "帖子内容"
t.integer "帖子用户id"
t.integer "帖子回复数", :default => 0, :null => false
t.integer "最后回帖id"
t.datetime "发帖时间", :null => false
t.datetime "帖子更新时间", :null => false
end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -598,8 +663,8 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.string "code"
t.integer "time"
t.string "extra"
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.string "location"
t.string "term"
t.string "string"
@ -609,27 +674,28 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "end_time"
t.string "end_term"
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "syllabus_id"
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
t.integer "invite_code_halt", :limit => 1, :default => 0
t.integer "qrcode_expiretime", :default => 0
t.integer "professional_level_id", :limit => 1
t.integer "invite_code_halt", :limit => 1, :default => 0
end
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
@ -680,6 +746,14 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id"
add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized"
create_table "data_exceptions", :force => true do |t|
t.string "message"
t.integer "container_id"
t.string "container_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0, :null => false
t.integer "attempts", :default => 0, :null => false
@ -696,6 +770,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "disciplines", :force => true do |t|
t.string "name"
t.integer "professional_level_id", :limit => 1
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -821,13 +900,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "exercise_status"
t.integer "user_id"
t.integer "time"
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.datetime "publish_time"
t.datetime "end_time"
t.integer "show_result"
t.integer "question_random", :default => 0
t.integer "choice_random", :default => 0
end
create_table "first_pages", :force => true do |t|
@ -944,6 +1021,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "is_open", :default => 0
t.datetime "simi_time"
t.integer "score_open", :default => 1
t.integer "anonymous_appeal", :default => 0
end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
@ -970,6 +1048,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "no_anon_penalty", :default => 1
t.integer "appeal_penalty", :default => 0
end
create_table "homework_detail_programings", :force => true do |t|
@ -1014,6 +1093,10 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.datetime "updated_at", :null => false
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -1545,9 +1628,12 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
end
create_table "professional_levels", :force => true do |t|
t.string "level"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
end
create_table "professions", :force => true do |t|
t.string "name"
t.integer "discipline_id", :limit => 1
end
create_table "project_infos", :force => true do |t|
@ -1610,7 +1696,6 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
@ -1618,6 +1703,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "publish_resource", :default => 0
t.integer "boards_count", :default => 0
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0
t.integer "visits", :default => 0
t.integer "hot", :default => 0
t.string "invite_code"
@ -1922,6 +2012,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "work_status", :default => 0
t.datetime "commit_time"
t.integer "is_delete", :default => 0
t.integer "appeal_penalty", :default => 0
end
add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id"
@ -1939,13 +2030,23 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "score"
t.text "comment"
t.integer "reviewer_role"
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 "appeal_status", :default => 0
end
add_index "student_works_scores", ["student_work_id"], :name => "student_work_id"
add_index "student_works_scores", ["user_id"], :name => "user_id"
create_table "student_works_scores_appeals", :force => true do |t|
t.integer "student_works_score_id"
t.integer "user_id"
t.text "comment"
t.integer "appeal_status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "students_for_courses", :force => true do |t|
t.integer "student_id"
t.integer "course_id"
@ -2004,8 +2105,8 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.string "title"
t.text "description"
t.integer "user_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.string "eng_name"
t.integer "syllabus_type"
t.integer "credit"
@ -2014,8 +2115,9 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
t.integer "practice_hours"
t.string "applicable_major"
t.string "pre_course"
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "professional_level_id", :limit => 1
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
@ -2379,6 +2481,17 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "wikis", ["project_id"], :name => "wikis_project_id"
create_table "work_detail_groups", :force => true do |t|
t.integer "work_id"
t.integer "min_num"
t.integer "max_num"
t.boolean "base_on_project"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "work_detail_groups", ["work_id"], :name => "index_work_detail_groups_on_work_id"
create_table "workflows", :force => true do |t|
t.integer "tracker_id", :default => 0, :null => false
t.integer "old_status_id", :default => 0, :null => false
@ -2396,6 +2509,25 @@ ActiveRecord::Schema.define(:version => 20161208015939) do
add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status"
add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id"
create_table "works", :force => true do |t|
t.string "name"
t.integer "user_id"
t.text "description"
t.date "publish_time"
t.date "end_time"
t.integer "work_type"
t.integer "contest_id"
t.boolean "is_delete", :default => false
t.boolean "score_open", :default => true
t.boolean "is_open", :default => false
t.integer "work_status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "works", ["contest_id"], :name => "index_works_on_contest_id"
add_index "works", ["user_id"], :name => "index_works_on_user_id"
create_table "works_categories", :force => true do |t|
t.string "category"
t.datetime "created_at", :null => false

View File

@ -10,7 +10,7 @@ namespace :homework_endtime do
homework_common.course.student.each do |s|
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
# 发送邮件通知
Mailer.homework_endtime__added(homework_common, s.student_id).deliver
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
end
end
end

View File

@ -53,7 +53,7 @@ namespace :homework_evaluation do
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
# 邮件通知
Mailer.send_mail_anonymous_comment_open(homework_common).deliver
# Mailer.send_mail_anonymous_comment_open(homework_common).deliver
else
#作业数小于2启动失败, 只给老师发
# status==4 发送失败
@ -65,7 +65,7 @@ namespace :homework_evaluation do
end
end
# 邮件通知
Mailer.send_mail_anonymous_comment_fail(homework_common).deliver
# Mailer.send_mail_anonymous_comment_fail(homework_common).deliver
end
end
end
@ -109,7 +109,7 @@ namespace :homework_evaluation do
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3)
end
# 邮件通知
Mailer.send_mail_anonymous_comment_close(homework_common).deliver
# Mailer.send_mail_anonymous_comment_close(homework_common).deliver
end
end
end

View File

@ -34,7 +34,7 @@ namespace :homework_publishtime do
homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
end
# 邮件通知
Mailer.run.homework_added(homework)
# Mailer.run.homework_added(homework)
end
end
Rails.logger.info("log--------------------------------homework_publish end")

View File

@ -17,7 +17,7 @@ namespace :issue_due_date do
end
end
# issue截止时间邮件提醒
Mailer.issue_due_date(issue).deliver
# Mailer.issue_due_date(issue).deliver
end
end
end