From c07677ef996237ddc06254baa475a33df8278c8f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 14:49:37 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=20=E6=8B=92=E7=BB=9D=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 6 +- app/controllers/members_controller.rb | 58 ++++++++++++++++++- app/helpers/users_helper.rb | 33 ++++++++++- app/models/applied_message.rb | 2 +- app/models/applied_project.rb | 2 +- app/models/project.rb | 4 +- .../applied_project_info.js.erb | 3 +- .../members/allow_to_join_project.js.erb | 6 ++ .../refused_allow_to_join_project.js.erb | 1 + .../_user_message_applide_action.html.erb | 12 ++++ .../_user_message_applide_users.html.erb | 2 + .../users/_user_message_applied.html.erb | 9 +-- config/routes.rb | 2 + ..._add_applied_user_id_to_applied_message.rb | 5 ++ public/javascripts/application.js | 1 + 15 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 app/views/members/allow_to_join_project.js.erb create mode 100644 app/views/members/refused_allow_to_join_project.js.erb create mode 100644 app/views/users/_user_message_applide_action.html.erb create mode 100644 app/views/users/_user_message_applide_users.html.erb create mode 100644 db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 117d022d6..b726ea504 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -1,5 +1,5 @@ class AppliedProjectController < ApplicationController - + helper :watchers #申请加入项目 def applied_join_project @project = Project.find_by_id(params[:object_id]) @@ -43,7 +43,7 @@ class AppliedProjectController < ApplicationController end # @flage:提示语标志(1:邀请码错误;2:已经是项目成员; 3:角色没有选择; 4:申请成功) - # role:成员角色 => 0(1:管理人员;2:开发人员;3:报告人员) + # role:成员角色 => 0(4:管理人员;5:开发人员;6:报告人员) # 申请成功则发送消息 def applied_project_info @project = Project.find(params[:project_id]) @@ -55,7 +55,7 @@ class AppliedProjectController < ApplicationController @flag = 3 else @flag = 4 - role = params[:member] == "member_manager" ? 1 : (params[:member] = "member_developer" ? 2 : 3) + role = params[:member] == "member_manager" ? 4 : (params[:member] = "member_developer" ? 5 : 6) applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 4dc2c52f5..dca6c6dd0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,10 +17,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class MembersController < ApplicationController + helper :users model_object Member - before_filter :find_model_object, :except => [:index, :create, :autocomplete] + before_filter :find_model_object, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project] #before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete] - before_filter :find_project_from_association, :except => [:index, :create, :autocomplete] + before_filter :find_project_from_association, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project] before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete] before_filter :authorize accept_api_auth :index, :show, :create, :update, :destroy @@ -49,6 +50,59 @@ class MembersController < ApplicationController end end + # 同意消息中申请加入项目 + # 之所以role不在参数中传送是考虑到安全问题 + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:决绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def allow_to_join_project + @applied_message = AppliedMessage.find(params[:applied_message_id]) + applied_project = @applied_message.applied + user = User.find(@applied_message.applied_user_id) + project = Project.find(applied_project.project_id) + + # applied_project = AppliedProject.where(:project_id => params[:project_id], :user_id => params[:user_id]).first + # @applied_message = AppliedMessage.find(params[:applied_id]) + if user.member_of?(project) + @flash_message = "您已经是项目成员了" + @applied_message.update_attribute(:status, 2) + else + ap_role = applied_project.try(:role) + if ap_role + begin + members = [] + user_grades = [] + project_info = [] + members << Member.new(:role_ids => ["#{ap_role}"], :user_id => params[:user_id]) + user_grades << UserGrade.new(:user_id => params[:user_id], :project_id => params[:project_id]) + role = Role.find(ap_role) + project_info << ProjectInfo.new(:project_id => params[:project_id], :user_id => params[:user_id]) if role.allowed_to?(:is_manager) + project.members << members + project.project_infos << project_info + project.user_grades << user_grades unless user_grades.first.user_id.nil? + # 添加成功后,申请人收到消息 + AppliedMessage.create(:user_id => params[:send_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => params[:user_id]) + # 添加成功后,批准人收到消息 + AppliedMessage.create(:user_id => params[:user_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => params[:send_id]) + rescue Exception => e + puts e + end + end + end + end + + # 同意消息中拒绝加入项目 + # params[:user_id]为申请者ID + # params[:send_id]为拒绝人ID + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def refused_allow_to_join_project + @applied_message = AppliedMessage.find(params[:applied_message_id]) + @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.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + end + def create if params[:refusal_button] members = [] diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index e9abe43a3..6d6c83d4a 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,15 +57,42 @@ module UsersHelper # 获取消息角色 def applied_project_message_type role case role - when 1 + when 4 "管理员" - when 2 + when 5 "开发人员" - when 3 + when 6 "报告人员" end end + # 判断当前用户能否对消息进行操作 + def allow_to_show applied_message + (User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false + end + + # 项目申请消息通过状态判断用户 + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def applied_project_users applied_message + case applied_message.status + when 3,2,1,5,4 + user = User.find(applied_message.applied_user_id) + when 6 + user = User.find(applied_message.user_id) + + end + end + + # 项目申请消息通过状态判断tip描述 + def applied_project_tip applied_message + case applied_message.status + when 4 + "拒绝申请加入项目:" + when 5,3,2,1 + "申请加入项目:" + end + end + def get_resource_origin attach type = attach.container_type content = attach.container diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index 1c6b3a8e7..0175fcf47 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 + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_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 8dbed9cda..fdc9a602e 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) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id) end # end end diff --git a/app/models/project.rb b/app/models/project.rb index edeee4f33..dcc01eb09 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -919,8 +919,8 @@ class Project < ActiveRecord::Base CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def generate_invite_code code = read_attribute(:invite_code) - if !code || code.size <5 - code = CODES.sample(5).join + if !code || code.size <6 + code = CODES.sample(6).join return generate_invite_code if Project.where(invite_code: code).present? update_attribute(:invite_code, code) end diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb index 1ac627b3e..7fff1b516 100644 --- a/app/views/applied_project/applied_project_info.js.erb +++ b/app/views/applied_project/applied_project_info.js.erb @@ -1,3 +1,4 @@ -var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>"; +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip') %>"; pop_box_new(htmlvalue,380,40,50); + //$("#join_in_project").attr('href','<%#= join_in_project_link(@project, User.current) %>'); diff --git a/app/views/members/allow_to_join_project.js.erb b/app/views/members/allow_to_join_project.js.erb new file mode 100644 index 000000000..df3ac6de3 --- /dev/null +++ b/app/views/members/allow_to_join_project.js.erb @@ -0,0 +1,6 @@ +<% if @flash_message %> + alert("<%= @flash_message %>"); +<% else%> + $("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); +<% end%> + diff --git a/app/views/members/refused_allow_to_join_project.js.erb b/app/views/members/refused_allow_to_join_project.js.erb new file mode 100644 index 000000000..109ed3a62 --- /dev/null +++ b/app/views/members/refused_allow_to_join_project.js.erb @@ -0,0 +1 @@ +$("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); \ No newline at end of file diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb new file mode 100644 index 000000000..24f2471b5 --- /dev/null +++ b/app/views/users/_user_message_applide_action.html.erb @@ -0,0 +1,12 @@ +<% if allow_to_show(ma) %> + :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post %> | + <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get %> +<% elsif ma.status == 4 %> + 被拒绝 +<% elsif ma.status == 5 %> + 您已拒绝 +<% elsif ma.status == 6 %> + 已通过 +<% elsif ma.status == 7 %> + 您已同意 +<% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_applide_users.html.erb b/app/views/users/_user_message_applide_users.html.erb new file mode 100644 index 000000000..18539c628 --- /dev/null +++ b/app/views/users/_user_message_applide_users.html.erb @@ -0,0 +1,2 @@ +<%=link_to applied_project_users(ma), user_path(applied_project_users(ma)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> +<%= applied_project_tip(ma) %> \ No newline at end of file diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index efd2bf8da..a2eff7189 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -20,13 +20,14 @@ <%=link_to image_tag(url_to_avatar(ma.applied.user), :width => "30", :height => "30"), user_path(ma.applied.user), :target => '_blank' %>
  • - <%=link_to ma.applied.user, user_path(ma.applied.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - ">申请加入项目: + <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • 以“<%= 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' %> - :同意 | 拒绝 + <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %> + + <%= render :partial => "users/user_message_applide_action", :locals =>{:ma => ma} %> +
  • <%= time_tag(ma.created_at).html_safe %>
  • diff --git a/config/routes.rb b/config/routes.rb index 52b7bab94..20fe203fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -767,6 +767,8 @@ RedmineApp::Application.routes.draw do collection do get 'autocomplete' get 'appliedproject' + post 'allow_to_join_project' + get 'refused_allow_to_join_project' end end diff --git a/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb b/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb new file mode 100644 index 000000000..480123b05 --- /dev/null +++ b/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddAppliedUserIdToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :applied_user_id, :integer + end +end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index d2cd50d0e..b4ccd1533 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1499,6 +1499,7 @@ function pop_box_new(value, Width, Top, Left){ $('#ajax-modal').siblings().remove(); $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); $('#ajax-modal').css({"padding":"0"}); + } // 公共提示弹框样式 From 450217e7c27c06ec770d9ca3e2e6d7656f5f33d7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 15:58:24 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=90=8C=E6=84=8F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=EF=BC=8C=E5=8F=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 2 +- app/controllers/members_controller.rb | 15 +++++++------ app/helpers/users_helper.rb | 21 +++++++++---------- .../members/allow_to_join_project.js.erb | 1 - 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index b726ea504..221adc7bc 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -55,7 +55,7 @@ class AppliedProjectController < ApplicationController @flag = 3 else @flag = 4 - role = params[:member] == "member_manager" ? 4 : (params[:member] = "member_developer" ? 5 : 6) + role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5) applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index dca6c6dd0..6d3cf6aa5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -58,9 +58,6 @@ class MembersController < ApplicationController applied_project = @applied_message.applied user = User.find(@applied_message.applied_user_id) project = Project.find(applied_project.project_id) - - # applied_project = AppliedProject.where(:project_id => params[:project_id], :user_id => params[:user_id]).first - # @applied_message = AppliedMessage.find(params[:applied_id]) if user.member_of?(project) @flash_message = "您已经是项目成员了" @applied_message.update_attribute(:status, 2) @@ -71,17 +68,18 @@ class MembersController < ApplicationController members = [] user_grades = [] project_info = [] - members << Member.new(:role_ids => ["#{ap_role}"], :user_id => params[:user_id]) - user_grades << UserGrade.new(:user_id => params[:user_id], :project_id => params[:project_id]) + members << Member.new(:role_ids => ["#{ap_role}"], :user_id => @applied_message.applied_user_id) + user_grades << UserGrade.new(:user_id => @applied_message.applied_user_id, :project_id => project.id) role = Role.find(ap_role) - project_info << ProjectInfo.new(:project_id => params[:project_id], :user_id => params[:user_id]) if role.allowed_to?(:is_manager) + project_info << ProjectInfo.new(:project_id => project.id, :user_id => @applied_message.applied_user_id) if role.allowed_to?(:is_manager) project.members << members project.project_infos << project_info project.user_grades << user_grades unless user_grades.first.user_id.nil? + @applied_message.update_attribute(:status, 2) # 添加成功后,申请人收到消息 - AppliedMessage.create(:user_id => params[:send_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => params[: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) # 添加成功后,批准人收到消息 - AppliedMessage.create(:user_id => params[:user_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => params[:send_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) rescue Exception => e puts e end @@ -101,6 +99,7 @@ class MembersController < ApplicationController 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.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + # applied_project.delete end def create diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 6d6c83d4a..a8427c326 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,11 +57,11 @@ module UsersHelper # 获取消息角色 def applied_project_message_type role case role - when 4 + when 3 "管理员" - when 5 + when 4 "开发人员" - when 6 + when 5 "报告人员" end end @@ -74,13 +74,10 @@ module UsersHelper # 项目申请消息通过状态判断用户 # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) def applied_project_users applied_message - case applied_message.status - when 3,2,1,5,4 - user = User.find(applied_message.applied_user_id) - when 6 - user = User.find(applied_message.user_id) - - end + # case applied_message.status + # when 3,2,1,5,4,7,6 + user = User.find(applied_message.applied_user_id) + # end end # 项目申请消息通过状态判断tip描述 @@ -88,8 +85,10 @@ module UsersHelper case applied_message.status when 4 "拒绝申请加入项目:" - when 5,3,2,1 + when 5,3,2,1,7 "申请加入项目:" + when 6 + "同意申请加入项目" end end diff --git a/app/views/members/allow_to_join_project.js.erb b/app/views/members/allow_to_join_project.js.erb index df3ac6de3..cbd37e188 100644 --- a/app/views/members/allow_to_join_project.js.erb +++ b/app/views/members/allow_to_join_project.js.erb @@ -3,4 +3,3 @@ <% else%> $("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); <% end%> - From 769a07bd9449429e64aee9324029b6828afbaedf Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 16:00:46 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=88=90=E5=91=98=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/settings/_new_members.html.erb | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/app/views/projects/settings/_new_members.html.erb b/app/views/projects/settings/_new_members.html.erb index b73ef647f..0773f7732 100644 --- a/app/views/projects/settings/_new_members.html.erb +++ b/app/views/projects/settings/_new_members.html.erb @@ -92,32 +92,6 @@ <% if roles.any? %>
    - <% if @project.applied_projects.any? %> -
    -

    <%= l(:label_apply_project) %>

    - <%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %> -
    - <%= render_principals_for_applied_members_new(@project) %> -
    -
      -
    • <%= l(:label_role_plural) %>:
    • - <% roles.each do |role| %> -
    • - <%= check_box_tag 'membership[role_ids][]', role.id %> - -
    • - <% end %> -
    - - <%= l(:label_approve) %> - - - <%= l(:label_refusal) %> - - <% end %> -
    -
    - <% end %>

    <%= l(:label_member_new) %>

    From 824b430fbde392398fe5572ea25ea1a6eca88dd3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 17:38:21 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=BC=B9=E5=87=BA=E7=A9=BA=E7=99=BD=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/quality_analysis_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 80c5a2468..c9873ade4 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -37,7 +37,7 @@ class QualityAnalysisController < ApplicationController quality_an.delete unless quality_an.blank? end # Checks if the given job exists in Jenkins. - unless @client.job.exists?(job_name) + # unless @client.job.exists?(job_name) @g = Gitlab.client branch = params[:branch] language = swith_language_type(params[:language]) @@ -111,7 +111,7 @@ class QualityAnalysisController < ApplicationController end end end - end + # end rescue => e @message = e.message end From 48a72ff816e1278063293f4b3b4cede170359f76 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 17:46:24 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=85=A5=E5=8F=A3=E6=94=BE=E7=BD=AE=E5=9C=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_development_group.html.erb | 6 ------ app/views/repositories/show.html.erb | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 6961fcbac..2c7d36fb5 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -55,12 +55,6 @@ <%= link_to "+"+l(:project_gitlab_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %> <% end %>
    - - <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> - - <% end %> <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 823d0c1ad..b80d9ee5b 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -7,6 +7,10 @@ <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> <% end %> <% end %> + + <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <% end %>
    <% if @entries.nil? %> From 60417b2db732b3d3f50596a2b5160c4945e065df Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 19:30:53 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/_user_message_applide_action.html.erb | 12 ++++++------ app/views/users/_user_message_applied.html.erb | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb index 24f2471b5..850f6d456 100644 --- a/app/views/users/_user_message_applide_action.html.erb +++ b/app/views/users/_user_message_applide_action.html.erb @@ -1,12 +1,12 @@ <% if allow_to_show(ma) %> - :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post %> | - <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get %> + :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | + <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get, :class => "link-blue" %> <% elsif ma.status == 4 %> - 被拒绝 + 被拒绝 <% elsif ma.status == 5 %> - 您已拒绝 + 您已拒绝 <% elsif ma.status == 6 %> - 已通过 + 已通过 <% elsif ma.status == 7 %> - 您已同意 + 您已同意 <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index a2eff7189..d15d8aac7 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -22,13 +22,15 @@
  • <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • -
  • +
  • 以“<%= applied_project_message_type(ma.applied.role) %>”身份加入 <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %> + +
  • +
  • <%= render :partial => "users/user_message_applide_action", :locals =>{:ma => ma} %> -
  • <%= time_tag(ma.created_at).html_safe %>
  • From 153efb7edabfd3afb228ba15524fef85c3ccdaf8 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 19:42:21 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_join_exit_project.html.erb | 10 +++------- app/views/projects/_applied_status.html.erb | 9 +++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 app/views/projects/_applied_status.html.erb diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index d39d3d67b..7d2f1b4d2 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -1,12 +1,8 @@
    - <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> - <%= watcher_link_for_project(@project, User.current) %> - - - <%= join_in_project_link(@project, User.current) %> - - <% end %> +
    + <%= render :partial => "projects/applied_status" %> +
    <% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %> <%= link_to "#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %> diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb new file mode 100644 index 000000000..d29819c03 --- /dev/null +++ b/app/views/projects/_applied_status.html.erb @@ -0,0 +1,9 @@ +<% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> + <%= watcher_link_for_project(@project, User.current) %> + + <% if AppliedProject.where(:user_id => User.current, :project_id => @project_id).first.nil? %> + <%= join_in_project_link(@project, User.current) %> + <% else %> + 等待审批 + <% end %> +<% end %> \ No newline at end of file From 0bf9b5c6e6ce213cfb2a0049bff5aae11ff1173e Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 20:31:24 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=20=20=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 14 +++++++---- app/models/user.rb | 3 ++- .../_applied_join_project.html.erb | 2 +- .../applied_join_project.js.erb | 2 +- app/views/layouts/new_base_user.html.erb | 23 +++++++++++++++++-- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 221adc7bc..d779c7759 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -2,7 +2,9 @@ class AppliedProjectController < ApplicationController helper :watchers #申请加入项目 def applied_join_project - @project = Project.find_by_id(params[:object_id]) + if params[:object_id] + @project = Project.find_by_id(params[:object_id]) + end # @user_id = params[:user_id] # if params[:project_join] # if @project @@ -46,8 +48,12 @@ class AppliedProjectController < ApplicationController # role:成员角色 => 0(4:管理人员;5:开发人员;6:报告人员) # 申请成功则发送消息 def applied_project_info - @project = Project.find(params[:project_id]) - if params[:invite_code].to_s != @project.invite_code + if params[:project_id].nil? + @project = Project.where(:invite_code => params[:invite_code]).first + else + @project = Project.find(params[:project_id]) + end + if !@project || params[:invite_code].to_s != @project.invite_code @flag = 1 elsif User.current.member_of?(@project) @flag = 2 @@ -56,7 +62,7 @@ class AppliedProjectController < ApplicationController else @flag = 4 role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5) - applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) + applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => @project.id, :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) end diff --git a/app/models/user.rb b/app/models/user.rb index 996aa9be7..8de109169 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -369,7 +369,8 @@ class User < Principal system_messages_count = SystemMessage.where("created_at >?", onclick_time).count at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count end # 查询指派给我的缺陷记录 diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb index ad2d020c2..457cdf9cc 100644 --- a/app/views/applied_project/_applied_join_project.html.erb +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -4,7 +4,7 @@
    - <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :remote => true, :id => 'project_applied_form') do %> + <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => (@project.nil? ? nil : @project.id)), :remote => true, :id => 'project_applied_form') do %>
    • diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index 6aa4481a4..5d9f7f87a 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,3 +1,3 @@ -var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => @project.id}) %>"; +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => (@project.nil? ? nil : @project.id)}) %>"; pop_box_new(htmlvalue,460,40,50); diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f280f6506..bcf00dd2c 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -245,8 +245,21 @@
    <%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :class => "homepageMenuText" %> - <% if is_current_user%> - <%=link_to "", new_project_path(:host=> Setting.host_name), :class => "homepageMenuSetting fr", :style => "margin-right:10px;", :title => "新建项目"%> + <% if is_current_user %> +
    +
      +
    • +
        +
      • + <%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :class => "menuGrey"%> +
      • +
      • + <%= link_to "加入项目", applied_join_project_path,:remote => true,:class => "menuGrey",:method => "post"%> +
      • +
      +
    • +
    +
    <% end%>
    <%# if @user.projects.visible.count > 0 @@ -362,6 +375,12 @@ $("#courseMenu").mouseleave(function(){ $("#topnav_course_menu").hide(); }); + $("#projectMenu").mouseenter(function(){ + $("#topnav_project_menu").show(); + }); + $("#projectMenu").mouseleave(function(){ + $("#topnav_project_menu").hide(); + }); function leftCourseslistChange(){ $('#homepageLeftMenuCourses').slideToggle(); $('#hide_show_courseicon').toggleClass("homepageLeftMenuHideIcon"); From 643b06484b34adeebe62fcaa4a7586e05b29db23 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 20:50:55 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 8 ++++---- app/models/applied_message.rb | 2 +- app/models/applied_project.rb | 2 +- .../users/_user_message_applied.html.erb | 2 +- ...60729124038_add_role_to_applied_message.rb | 5 +++++ ...24833_add_project_id_to_applied_message.rb | 5 +++++ db/schema.rb | 20 +++++++++++-------- 7 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20160729124038_add_role_to_applied_message.rb create mode 100644 db/migrate/20160729124833_add_project_id_to_applied_message.rb 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| From 8d625eff5e6b11d9b57abbfd60da0408d2500ba3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 21:04:01 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=B0=B1=E7=94=A8=E6=88=B7=E5=9B=BE=E5=83=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 12 ++++++++---- .../users/_user_message_applide_action.html.erb | 4 ++-- app/views/users/_user_message_applied.html.erb | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 31d32bb59..4f34bb252 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -77,9 +77,11 @@ 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, :role => applied_project.role) + 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, :project_id => applied_project.project_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) + 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, :project_id => applied_project.project_id) rescue Exception => e puts e end @@ -96,9 +98,11 @@ 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, :role => applied_project.role) + 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, :project_id => applied_project.project_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) + 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, :project_id => applied_project.project_id) # applied_project.delete end diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb index 850f6d456..fc56b9f22 100644 --- a/app/views/users/_user_message_applide_action.html.erb +++ b/app/views/users/_user_message_applide_action.html.erb @@ -1,6 +1,6 @@ <% if allow_to_show(ma) %> - :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | - <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get, :class => "link-blue" %> + :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.project_id, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | + <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.project_id, :applied_message_id => ma.id), :remote => true, :method => :get, :class => "link-blue" %> <% elsif ma.status == 4 %> 被拒绝 <% elsif ma.status == 5 %> diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index af62276e0..825610057 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -17,14 +17,14 @@ <% elsif ma && ma.applied_type == "AppliedProject" %>