From 0746408a9df9a92af52a0c8285e3987cf0db07f9 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 16:55:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92=E5=8A=9F=E8=83=BD=EF=BC=88=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=94=B6=E5=88=B0=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 ++ app/models/applied_project.rb | 18 +++++++++++++++--- app/views/users/user_messages.html.erb | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f05fa891a..c738ab89a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -146,6 +146,8 @@ class UsersController < ApplicationController @message_alls << message_all.message end end + when 'invite_info' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc") when 'homework' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") when 'course_message' diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index accbc90e2..fb8bf90af 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -1,8 +1,21 @@ class AppliedProject < ActiveRecord::Base attr_accessible :project_id, :user_id - belongs_to :user - belongs_to :project + belongs_to :user + belongs_to :project + has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + + after_create :send_appliled_message + + def send_appliled_message + # if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.project.members.each do |m| + if m.roles.first.to_s.include?("Manager") + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + # end + end #删除用户申请 def self.deleteappiled(userid, projectid) @@ -11,5 +24,4 @@ class AppliedProject < ActiveRecord::Base applied.destroy end end - end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index cd64fb227..778805db6 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -134,6 +134,21 @@ <% end %> <% if ma.class == ForgeMessage %> + <% if ma.forge_message_type == "AppliedProject" %> + + <% end %> <% if ma.forge_message_type == "Issue" %>