diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index f5c42f7b4..f2c0eb056 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -6,13 +6,18 @@ class AppliedProjectController < ApplicationController @project = Project.find_by_id(params[:project_id]) if params[:project_join] if @project - @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) - if @applieds.count == 0 - appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - Mailer.applied_project(appliedproject).deliver - @status = 2 + user = User.find @user_id + if user.member_of?(@project) + @status = 3 else - @status = 1 + @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) + if @applieds.count == 0 + appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + Mailer.applied_project(appliedproject).deliver + @status = 2 + else + @status = 1 + end end else @status = 0 diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index deac2c9ce..3f4f6aff7 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -4,6 +4,8 @@ alert("请勿重复申请加入该项目"); <% elsif @status == 2%> alert("申请成功"); +<% elsif @status == 3%> + alert("您已加入该项目"); <%else%> alert("申请失败"); <%end%> \ No newline at end of file