diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6d3cf6aa5..31d32bb59 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -77,9 +77,9 @@ class MembersController < ApplicationController project.user_grades << user_grades unless user_grades.first.user_id.nil? @applied_message.update_attribute(:status, 2) # 添加成功后,申请人收到消息 - AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id) + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role) # 添加成功后,批准人收到消息 - AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role) rescue Exception => e puts e end @@ -96,9 +96,9 @@ class MembersController < ApplicationController @applied_message.update_attribute(:status, 3) applied_project = @applied_message.applied # 发送消息给被拒者,user_id对应的收到信息的用户 - AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id) + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role) # 发送消息给拒绝者 - AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role) # applied_project.delete end diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index 0175fcf47..ee22f21c8 100644 --- a/app/models/applied_message.rb +++ b/app/models/applied_message.rb @@ -1,6 +1,6 @@ class AppliedMessage < ActiveRecord::Base # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 - attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id, :role, :project_id belongs_to :applied ,:polymorphic => true belongs_to :apply_add_schools belongs_to :user diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index fdc9a602e..b1945a937 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -10,7 +10,7 @@ class AppliedProject < ActiveRecord::Base # 仅仅给项目管理人员发送消息 def send_appliled_message self.project.managers.each do |member| - self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id) end # end end diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index d15d8aac7..af62276e0 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -23,7 +23,7 @@ <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • - 以“<%= applied_project_message_type(ma.applied.role) %>”身份加入 + 以“<%= applied_project_message_type(ma.role) %>”身份加入 <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %>
  • diff --git a/db/migrate/20160729124038_add_role_to_applied_message.rb b/db/migrate/20160729124038_add_role_to_applied_message.rb new file mode 100644 index 000000000..c6a73c794 --- /dev/null +++ b/db/migrate/20160729124038_add_role_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddRoleToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :role, :integer + end +end diff --git a/db/migrate/20160729124833_add_project_id_to_applied_message.rb b/db/migrate/20160729124833_add_project_id_to_applied_message.rb new file mode 100644 index 000000000..803c5d8aa --- /dev/null +++ b/db/migrate/20160729124833_add_project_id_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddProjectIdToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :project_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 4747a74e3..f8a113834 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 => 20160728075947) do +ActiveRecord::Schema.define(:version => 20160729124833) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -78,16 +78,20 @@ ActiveRecord::Schema.define(:version => 20160728075947) do t.integer "user_id" t.integer "applied_id" t.string "applied_type" - t.integer "viewed", :default => 0 - t.integer "status", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "viewed", :default => 0 + t.integer "status", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "applied_user_id" + t.integer "role" + t.integer "project_id" end create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "role", :default => 0 + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "role", :default => 0 + t.integer "applied_user_id" end create_table "apply_add_schools", :force => true do |t|