首页加入项目增加已是当前项目的判断
This commit is contained in:
parent
a265556cfe
commit
87fdd840ec
|
@ -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
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
alert("请勿重复申请加入该项目");
|
||||
<% elsif @status == 2%>
|
||||
alert("申请成功");
|
||||
<% elsif @status == 3%>
|
||||
alert("您已加入该项目");
|
||||
<%else%>
|
||||
alert("申请失败");
|
||||
<%end%>
|
Loading…
Reference in New Issue