[ADD]组织项目相关

This commit is contained in:
2021-01-19 19:02:51 +08:00
parent 1dc43a23b7
commit f094fe1799
31 changed files with 406 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
class Organizations::TeamsController < Organizations::BaseController
before_action :load_organization
before_action :load_team, only: [:show, :update, :destroy]
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
def index
if @organization.is_owner?(current_user)
@@ -16,7 +17,6 @@ class Organizations::TeamsController < Organizations::BaseController
end
def create
tip_exception("您没有权限进行该操作") unless @organization.is_owner?(current_user)
@team = Organizations::Teams::CreateService.call(current_user, @organization, team_params)
rescue Exception => e
uid_logger_error(e.message)
@@ -24,7 +24,6 @@ class Organizations::TeamsController < Organizations::BaseController
end
def update
tip_exception("您没有权限进行该操作") unless @organization.is_owner?(current_user)
@team = Organizations::Teams::UpdateService.call(current_user, @team, team_params)
rescue Exception => e
uid_logger_error(e.message)
@@ -32,9 +31,8 @@ class Organizations::TeamsController < Organizations::BaseController
end
def destroy
tip_exception("您没有权限进行该操作") unless @organization.is_owner?(current_user)
ActiveRecord::Base.transaction do
Gitea::Organization::Team::DeleteService.call(current_user.gitea_token, @team.gtid)
Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid)
@team.destroy!
end
render_ok