增加用户申请加入项目消息提醒功能(管理员收到消息提醒)
This commit is contained in:
parent
ae2aa2fedd
commit
0746408a9d
|
@ -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'
|
||||
|
|
|
@ -3,6 +3,19 @@ class AppliedProject < ActiveRecord::Base
|
|||
|
||||
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
|
||||
|
|
|
@ -134,6 +134,21 @@
|
|||
<% end %>
|
||||
<!--项目消息-->
|
||||
<% if ma.class == ForgeMessage %>
|
||||
<% if ma.forge_message_type == "AppliedProject" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.forge_message.user), :width => "30", :height => "30"), user_path(ma.forge_message.user) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to ma.forge_message.user, user_path(ma.forge_message.user), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">申请加入项目:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ma.project, project_path(ma.project_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ma.project}" %></a>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.forge_message_type == "Issue" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
|
|
Loading…
Reference in New Issue