From 02f01c1aba02a77939acae9d88918ffc37df6efe Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 23 Jan 2015 17:10:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 19 ++++++++++++++++++- .../applied_join_project.js.erb | 7 +++++++ app/views/projects/_join_project.html.erb | 4 ++-- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 app/views/applied_project/applied_join_project.js.erb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 3d061ef74..d7b65174f 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -3,7 +3,24 @@ class AppliedProjectController < ApplicationController #申请加入项目 def applied_join_project @user_id = params[:user_id] - @project = Project.find(params[:project_id]) + @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 + end + @status = 1 + else + @status = 0 + end + respond_to do |format| + format.js + end + return + end + @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]) diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb new file mode 100644 index 000000000..9fd358ede --- /dev/null +++ b/app/views/applied_project/applied_join_project.js.erb @@ -0,0 +1,7 @@ +<% if @status == 0%> + alert("您申请的项目不存在"); +<% elsif @status == 1%> + alert("申请成功"); +<%else%> + alert("申请失败"); +<%end%> \ No newline at end of file diff --git a/app/views/projects/_join_project.html.erb b/app/views/projects/_join_project.html.erb index c7ce29dae..d30ec73e1 100644 --- a/app/views/projects/_join_project.html.erb +++ b/app/views/projects/_join_project.html.erb @@ -1,4 +1,3 @@ -
@@ -34,7 +33,7 @@ { hideModal(obj); $("#new-watcher-form").submit(); - alert("申请成功"); +// alert("申请成功"); } function hidden_join_course_form() @@ -60,6 +59,7 @@