mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
cla init
This commit is contained in:
63
app/controllers/organizations/clas_controller.rb
Normal file
63
app/controllers/organizations/clas_controller.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
class Organizations::ClasController < Organizations::BaseController
|
||||
before_action :load_organization
|
||||
before_action :load_cla, only: [:show, :update, :destroy]
|
||||
def index
|
||||
@cla = @organization.cla
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def create
|
||||
tip_exception("您的组织还未拥有创建CLA权限,请联系管理员") if @organization.cla == false
|
||||
ActiveRecord::Base.transaction do
|
||||
if @organization.cla.present?
|
||||
return tip_exception("组织已存在CLA!")
|
||||
else
|
||||
Organizations::CreateClaForm.new(cla_params).validate!
|
||||
@cla = Cla.build(cla_params)
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
Organizations::CreateClaForm.new(cla_params).validate!
|
||||
@cla.update(cla_params)
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def destroy
|
||||
tip_exception("组织CLA已被签署,无法删除") if @cla.user_clas.size > 0
|
||||
ActiveRecord::Base.transaction do
|
||||
@cla.destroy!
|
||||
end
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def cla_params
|
||||
params.permit(:name, :key, :content, :organization_id, :pr_need)
|
||||
end
|
||||
|
||||
def load_organization
|
||||
@organization = Organization.find_by(login: params[:organization_id]) || Organization.find_by(id: params[:organization_id])
|
||||
return render_not_found("组织不存在") if @organization.nil?
|
||||
return render_forbidden("没有查看组织的权限") if org_limited_condition || org_privacy_condition
|
||||
end
|
||||
|
||||
def load_cla
|
||||
@cla = Cla.find_by!(organization:params[:organization_id], key: params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user