mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
add: transfer project
This commit is contained in:
18
app/controllers/users/applied_messages_controller.rb
Normal file
18
app/controllers/users/applied_messages_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Users::AppliedMessagesController < Users::BaseController
|
||||
before_action :check_auth
|
||||
after_action :view_messages, only: [:index]
|
||||
|
||||
def index
|
||||
@applied_messages = @_observed_user.applied_messages.order(viewed: :asc, created_at: :desc)
|
||||
@applied_messages = paginate @applied_messages
|
||||
end
|
||||
|
||||
private
|
||||
def check_auth
|
||||
return render_forbidden unless observed_logged_user?
|
||||
end
|
||||
|
||||
def view_messages
|
||||
@applied_messages.update_all(viewed: 'viewed')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,41 @@
|
||||
class Users::AppliedTransferProjectsController < Users::BaseController
|
||||
before_action :check_auth
|
||||
before_action :find_applied_transfer_project, except: [:index]
|
||||
before_action :find_project, except: [:index]
|
||||
|
||||
def index
|
||||
user_collection_sql = AppliedTransferProject.where(owner_id: @_observed_user.id).to_sql
|
||||
org_collection_sql = AppliedTransferProject.where(owner_id: Organization.joins(team_users: :team).where(team_users: {user_id: @_observed_user.id}, teams: {authorize: %w(admin owner)} )).to_sql
|
||||
@applied_transfer_projects = AppliedTransferProject.from("( #{ user_collection_sql } UNION #{ org_collection_sql } ) AS applied_transfer_projects")
|
||||
@applied_transfer_projects = paginate @applied_transfer_projects
|
||||
end
|
||||
|
||||
# 接受迁移
|
||||
def accept
|
||||
@applied_transfer_project = Projects::AcceptTransferService.call(current_user, @project)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
# 拒绝迁移
|
||||
def refuse
|
||||
@applied_transfer_project = Projects::RefuseTransferService.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 observed_logged_user?
|
||||
end
|
||||
|
||||
def find_applied_transfer_project
|
||||
@applied_transfer_project = AppliedTransferProject.find_by_id params[:id]
|
||||
end
|
||||
|
||||
def find_project
|
||||
@project = @applied_transfer_project.project
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user