首页加入项目增加已是当前项目的判断

This commit is contained in:
sw 2015-01-30 11:39:19 +08:00
parent a265556cfe
commit 87fdd840ec
2 changed files with 13 additions and 6 deletions

View File

@ -6,6 +6,10 @@ class AppliedProjectController < ApplicationController
@project = Project.find_by_id(params[:project_id])
if params[:project_join]
if @project
user = User.find @user_id
if user.member_of?(@project)
@status = 3
else
@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])
@ -14,6 +18,7 @@ class AppliedProjectController < ApplicationController
else
@status = 1
end
end
else
@status = 0
end

View File

@ -4,6 +4,8 @@
alert("请勿重复申请加入该项目");
<% elsif @status == 2%>
alert("申请成功");
<% elsif @status == 3%>
alert("您已加入该项目");
<%else%>
alert("申请失败");
<%end%>