diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 2697f17b5..66ec6c2d7 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c88ceb299..c9253ad59 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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| diff --git a/app/models/mailer.rb b/app/models/mailer.rb index c2b66f2a5..931e2dbf0 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -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 diff --git a/app/models/system_message.rb b/app/models/system_message.rb index 3430bea5f..2a810e8b8 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -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 diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 26a54d647..5e49822ad 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -4,6 +4,9 @@
<%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %> +
+ <%= f.text_area :subject %> +
<%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>

diff --git a/app/views/users/system_messages.html.erb b/app/views/users/user_system_messages.html.erb similarity index 96% rename from app/views/users/system_messages.html.erb rename to app/views/users/user_system_messages.html.erb index 21bb1c3f7..078b16809 100644 --- a/app/views/users/system_messages.html.erb +++ b/app/views/users/user_system_messages.html.erb @@ -25,7 +25,7 @@ <%# 系统贴吧 %>
  • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
  • <%# 系统消息 %> -
  • <%= link_to "系统消息", system_messages_path(User.current), :class => "resourcesGrey" %>
  • +
  • <%= link_to "系统消息", user_system_messages_path(User.current), :class => "resourcesGrey" %>
  • diff --git a/config/routes.rb b/config/routes.rb index e35c7ff3b..17a30807c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/db/migrate/20150917081214_add_subject_to_system_message.rb b/db/migrate/20150917081214_add_subject_to_system_message.rb new file mode 100644 index 000000000..69cdd2a63 --- /dev/null +++ b/db/migrate/20150917081214_add_subject_to_system_message.rb @@ -0,0 +1,5 @@ +class AddSubjectToSystemMessage < ActiveRecord::Migration + def change + add_column :system_messages, :subject, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 5eec29135..7d8678753 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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| diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake index 9fef281a3..fe92842e3 100644 --- a/lib/tasks/homework_endtime.rake +++ b/lib/tasks/homework_endtime.rake @@ -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