首页加入项目增加已是当前项目的判断
This commit is contained in:
parent
a265556cfe
commit
87fdd840ec
|
@ -6,13 +6,18 @@ class AppliedProjectController < ApplicationController
|
||||||
@project = Project.find_by_id(params[:project_id])
|
@project = Project.find_by_id(params[:project_id])
|
||||||
if params[:project_join]
|
if params[:project_join]
|
||||||
if @project
|
if @project
|
||||||
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
|
user = User.find @user_id
|
||||||
if @applieds.count == 0
|
if user.member_of?(@project)
|
||||||
appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
@status = 3
|
||||||
Mailer.applied_project(appliedproject).deliver
|
|
||||||
@status = 2
|
|
||||||
else
|
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
|
end
|
||||||
else
|
else
|
||||||
@status = 0
|
@status = 0
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
alert("请勿重复申请加入该项目");
|
alert("请勿重复申请加入该项目");
|
||||||
<% elsif @status == 2%>
|
<% elsif @status == 2%>
|
||||||
alert("申请成功");
|
alert("申请成功");
|
||||||
|
<% elsif @status == 3%>
|
||||||
|
alert("您已加入该项目");
|
||||||
<%else%>
|
<%else%>
|
||||||
alert("申请失败");
|
alert("申请失败");
|
||||||
<%end%>
|
<%end%>
|
Loading…
Reference in New Issue