项目申请消息发送
This commit is contained in:
parent
4a9eec0cce
commit
a8fa4a55e3
|
@ -42,7 +42,8 @@ class AppliedProjectController < ApplicationController
|
|||
# end
|
||||
end
|
||||
|
||||
# @flage:提示语标志(1 邀请码错误;2 已经是项目成员; 3 角色没有选择; 4 申请成功)
|
||||
# @flage:提示语标志(1:邀请码错误;2:已经是项目成员; 3:角色没有选择; 4:申请成功)
|
||||
# role:成员角色 => 0(1:管理人员;2:开发人员;3:报告人员)
|
||||
# 申请成功则发送消息
|
||||
def applied_project_info
|
||||
@project = Project.find(params[:project_id])
|
||||
|
@ -54,12 +55,10 @@ class AppliedProjectController < ApplicationController
|
|||
@flag = 3
|
||||
else
|
||||
@flag = 4
|
||||
applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id])
|
||||
role = params[:member] == "member_manager" ? 1 : (params[:member] = "member_developer" ? 2 : 3)
|
||||
applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role)
|
||||
# 申请成功则给项目管理员发送邮件及发送消息
|
||||
Mailer.run.applied_project(appliedproject)
|
||||
@project.managers.each do |member|
|
||||
AppliedMessage.create(:user_id => member.user_id, :status => true, :applied_id => applied_project.id, :applied_type => "AppliedProject", :viewed => true)
|
||||
end
|
||||
Mailer.run.applied_project(applied_project)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -54,6 +54,18 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 获取消息角色
|
||||
def applied_project_message_type role
|
||||
case role
|
||||
when 1
|
||||
"管理员"
|
||||
when 2
|
||||
"开发人员"
|
||||
when 3
|
||||
"报告人员"
|
||||
end
|
||||
end
|
||||
|
||||
def get_resource_origin attach
|
||||
type = attach.container_type
|
||||
content = attach.container
|
||||
|
|
|
@ -372,7 +372,7 @@ module WatchersHelper
|
|||
method = 'post'
|
||||
@applied_flag = project.instance_of?(Project)
|
||||
if applied
|
||||
link = "<a class ='pr_join_a'>text</a>"
|
||||
link = "<a class ='pr_join_a'>#{text}</a>"
|
||||
else
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a")
|
||||
end
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
class AppliedProject < ActiveRecord::Base
|
||||
attr_accessible :project_id, :user_id
|
||||
attr_accessible :project_id, :user_id, :role
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :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
|
||||
self.project.managers.each do |member|
|
||||
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false)
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>";
|
||||
pop_box_new(htmlvalue,380,40,50);
|
||||
//$("#join_in_project").attr('href','<%#= join_in_project_link(@project, User.current) %>');
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %>
|
||||
<span><%= watcher_link_for_project(@project, User.current) %></span>
|
||||
<!--加入项目 -->
|
||||
<%= join_in_project_link(@project, User.current) %>
|
||||
<span id="join_in_project">
|
||||
<%= join_in_project_link(@project, User.current) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<!--配置项目-->
|
||||
<% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %>
|
||||
|
|
|
@ -14,5 +14,22 @@
|
|||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% elsif ma && ma.applied_type == "AppliedProject" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.applied.user), :width => "30", :height => "30"), user_path(ma.applied.user), :target => '_blank' %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to ma.applied.user, user_path(ma.applied.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">申请加入项目:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
以“<%= applied_project_message_type(ma.applied.role) %>”身份加入
|
||||
<%= link_to ma.applied.project, settings_project_path(:id => ma.applied.project.id, :tab => "members"), :class => "link-blue", :target => '_blank' %>
|
||||
:同意 | 拒绝
|
||||
</a>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,5 @@
|
|||
class AddRoleToAppliedProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :applied_projects, :role, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160728041943) do
|
||||
ActiveRecord::Schema.define(:version => 20160728075947) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -85,8 +85,9 @@ ActiveRecord::Schema.define(:version => 20160728041943) do
|
|||
end
|
||||
|
||||
create_table "applied_projects", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "role", :default => 0
|
||||
end
|
||||
|
||||
create_table "apply_add_schools", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue