forgeplus/app/controllers/projects/applied_transfer_projects_c...

33 lines
1.1 KiB
Ruby
Raw Normal View History

2021-04-25 18:41:13 +08:00
class Projects::AppliedTransferProjectsController < Projects::BaseController
before_action :check_auth
2021-09-02 13:59:09 +08:00
before_action :check_user_profile_completed, only: [:create]
2021-04-25 18:41:13 +08:00
def organizations
@organizations = Organization.includes(:organization_extension).joins(team_users: :team).where(team_users: {user_id: current_user.id}, teams: {authorize: %w(admin owner)})
end
def create
2021-04-26 11:04:10 +08:00
@applied_transfer_project = Projects::ApplyTransferService.call(current_user, @project, params)
2021-04-25 18:41:13 +08:00
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
def cancel
@applied_transfer_project = Projects::CancelTransferService.call(current_user, @project)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
private
def check_auth
return render_forbidden unless current_user.admin? ||@project.owner?(current_user)
end
def check_user_profile_completed
@owner = Owner.find_by(login: params[:owner_name])
return if @owner.is_a?(Organization)
require_user_profile_completed(@owner)
end
2021-04-25 18:41:13 +08:00
end