From 87fdd840ecb014257c1ea5b4d3967ffdc665f319 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 11:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=A0=E5=85=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=A2=9E=E5=8A=A0=E5=B7=B2=E6=98=AF=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 17 +++++++++++------ .../applied_project/applied_join_project.js.erb | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) 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