socialforge/app/controllers/applied_project_controller.rb

88 lines
3.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class AppliedProjectController < ApplicationController
helper :watchers
#申请加入项目
def applied_join_project
if params[:object_id]
@project = Project.find_by_id(params[:object_id])
end
# @user_id = params[:user_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])
# Mailer.run.applied_project(appliedproject)
# @status = 2
# else
# @status = 1
# end
# end
# 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])
# Mailer.run.applied_project(appliedproject)
# 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
# @flage:提示语标志1邀请码错误2已经是项目成员 3角色没有选择; 4申请成功
# role:成员角色 => 04管理人员5开发人员6报告人员
# 申请成功则发送消息
def applied_project_info
if params[:project_id].nil?
@project = Project.where(:invite_code => params[:invite_code]).first
else
@project = Project.find(params[:project_id])
end
if !@project || params[:invite_code].to_s != @project.invite_code
@flag = 1
elsif User.current.member_of?(@project)
@flag = 2
elsif params[:member].nil?
@flag = 3
elsif !AppliedProject.where(:project_id => @project.id, :user_id => User.current.id).first.nil?
@flag = 5
else
@flag = 4
role = params[:member] == "member_manager" ? 3 : (params[:member] == "member_developer" ? 4 :5)
applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => @project.id, :role => role)
# 申请成功则给项目管理员发送邮件及发送消息
# Mailer.run.applied_project(applied_project)
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