Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq

This commit is contained in:
ouyangxuhua 2015-09-17 16:25:46 +08:00
commit 43eeb8f457
10 changed files with 62 additions and 10 deletions

View File

@ -14,8 +14,7 @@ class SystemMessagesController < ApplicationController
# end
def index
render_403
# @system_messages = SystemMessage.all
@system_messages = SystemMessage.all
end
# def show
@ -39,7 +38,8 @@ class SystemMessagesController < ApplicationController
return
end
@system_messages = SystemMessage.new
@system_messages.description = params[:system_messages][:description]
@system_messages.description = params[:system_message][:description]
@system_messages.subject = params[:system_message][:subject]
@system_messages.user_id = User.current.id
respond_to do |format|
if @system_messages.save

View File

@ -46,7 +46,7 @@ class UsersController < ApplicationController
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :system_messages]
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -201,7 +201,7 @@ class UsersController < ApplicationController
end
# 系统消息
def system_messages
def user_system_messages
@sytem_messages = SystemMessage.order("created_at desc").all
@sytem_messages = paginateHelper @sytem_messages,25
respond_to do |format|

View File

@ -207,6 +207,47 @@ class Mailer < ActionMailer::Base
mail :to => user.mail,:subject => subject if has_content
end
# 作业截止时间邮件提醒
def homework_endtime__added(homework_common, course)
# modify by nwb
#如果是直接留言并且留言对象是课程
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
@author = journals_for_message.user
#课程的教师
@members = course_all_member journals_for_message.jour
#收件人邮箱
students = course.student
recipients ||= []
students.each do |students|
recipients << recipients.user.mail
end
mail :to => @recipients,
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ",
:filter => true
# elsif journals_for_message.jour.class.to_s.to_sym == :Bid
# if !journals_for_message.jour.author.notify_about? journals_for_message
# return -1
# end
#
# mail :to => recipients, :subject => @title,:filter => true
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
mail :to => recipients, :subject => @title,:filter => true
else
mail :to => recipients1, :subject => @title,:filter => true
end
recipients ||= []
# 将帖子创建者邮箱地址加入数组
recipients << course.student
# 回复人邮箱地址加入数组
recipients << @author.mail
end
# 公共讨论区发帖、回帖添加邮件发送信息
def forum_message_added(memo)
@memo = memo

View File

@ -1,7 +1,8 @@
class SystemMessage < ActiveRecord::Base
attr_accessible :content, :id, :user_id, :description
attr_accessible :content, :id, :user_id, :description, :subject
belongs_to :user
validates :description, presence: true
validates :subject, presence: true
# validates :description, presence: true
validates_length_of :description, maximum: 10000
end

View File

@ -4,6 +4,9 @@
</h3><br/>
<div style="padding-top: 20px; padding-left: 5px;">
<%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %>
<div class="field">
<%= f.text_area :subject %>
</div>
<div class="field">
<%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>
<p id="content_notice_span" class="ml55"></p>

View File

@ -25,7 +25,7 @@
<%# 系统贴吧 %>
<li><%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %></li>
<%# 系统消息 %>
<li><%= link_to "系统消息", system_messages_path(User.current), :class => "resourcesGrey" %></li>
<li><%= link_to "系统消息", user_system_messages_path(User.current), :class => "resourcesGrey" %></li>
</ul>
</li>
</ul>

View File

@ -389,7 +389,7 @@ RedmineApp::Application.routes.draw do
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
#消息
match 'users/:id/user_messages', :to => 'users#user_messages', :via => :get, :as => "user_message"
match 'users/:id/system_messages', :to => 'users#system_messages', :via => :get, :as => "system_messages"
match 'users/:id/user_system_messages', :to => 'users#user_system_messages', :via => :get, :as => "user_system_messages"
#match 'users/:id/user_messages/:homework', :to => 'users#user_messages_homework', :via => :get, :as => "user_message_homewrok"

View File

@ -0,0 +1,5 @@
class AddSubjectToSystemMessage < ActiveRecord::Migration
def change
add_column :system_messages, :subject, :string
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 => 20150915063302) do
ActiveRecord::Schema.define(:version => 20150917081214) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1365,6 +1365,7 @@ ActiveRecord::Schema.define(:version => 20150915063302) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "description"
t.string "subject"
end
create_table "taggings", :force => true do |t|

View File

@ -10,6 +10,7 @@ namespace :homework_endtime do
if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year
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.run.homework_endtime__added(homework_common, homework_common.course)
end
end
end