36 lines
1.3 KiB
Ruby
36 lines
1.3 KiB
Ruby
class AppliedProjectController < ApplicationController
|
|
|
|
#申请加入项目
|
|
def applied_join_project
|
|
@user_id = params[:user_id]
|
|
@project = Project.find(params[:project_id])
|
|
@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
|
|
|
|
#redirect_to project_path(params[:project_id])
|
|
#redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true}
|
|
respond_to do |format|
|
|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
|
format.js { render :partial => 'set_applied'}
|
|
end
|
|
end
|
|
|
|
#取消申请
|
|
def unapplied_join_project
|
|
@project = Project.find(params[:project_id])
|
|
#@applied = AppliedProject.find(params[:id])
|
|
#@applied.destroy
|
|
|
|
AppliedProject.deleteappiled(params[:user_id], params[:project_id])
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
|
format.js { render :partial => 'set_applied' }
|
|
end
|
|
end
|
|
|
|
end
|