[ADD]组织、组织团队
This commit is contained in:
parent
0c58447afb
commit
289d1877d6
|
@ -32,12 +32,19 @@ class Organizations::BaseController < ApplicationController
|
|||
params[:repo_name] || params[:id]
|
||||
end
|
||||
|
||||
private
|
||||
def limited_condition
|
||||
def org_limited_condition
|
||||
@organization.organization_extension.limited? && !current_user.logged?
|
||||
end
|
||||
|
||||
def privacy_condition
|
||||
def org_privacy_condition
|
||||
@organization.organization_extension.privacy? && @organization.organization_users.where(user_id: current_user.id).blank?
|
||||
end
|
||||
|
||||
def team_not_found_condition
|
||||
@team.team_users.where(user_id: current_user.id).blank? && !@organization.is_owner?(current_user)
|
||||
end
|
||||
|
||||
def user_mark
|
||||
params[:username] || params[:id]
|
||||
end
|
||||
end
|
|
@ -11,7 +11,6 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
@organizations = Organization.from("( #{ logged_organizations_sql } UNION #{ privacy_organizations_sql } ) AS users")
|
||||
else
|
||||
@organizations = Organization.with_visibility("common")
|
||||
kaminari_paginate(@organizations)
|
||||
end
|
||||
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
||||
@organizations = @organizations.includes(:organization_extension).order("organization_extensions.#{sort_by} #{sort_direction}")
|
||||
|
@ -32,6 +31,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
end
|
||||
|
||||
def update
|
||||
tip_exception("您没有权限进行该操作") unless @organization.is_owner?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
login = @organization.login
|
||||
@organization.update!(login: organization_params[:name]) if organization_params[:name].present?
|
||||
|
|
|
@ -31,4 +31,8 @@ class OrganizationUser < ApplicationRecord
|
|||
def teams
|
||||
organization.teams.joins(:team_users).where(team_users: {user_id: user_id})
|
||||
end
|
||||
|
||||
def teams
|
||||
organization.teams.joins(:team_users).where(team_users: {user_id: user_id})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,30 +11,16 @@ class Organizations::CreateService < ApplicationService
|
|||
Rails.logger.info("######Organization create_service begin######")
|
||||
Rails.logger.info("######params #{params}######")
|
||||
ActiveRecord::Base.transaction do
|
||||
<<<<<<< HEAD
|
||||
create_org_and_extension
|
||||
create_owner_info
|
||||
create_gitea_org
|
||||
sync_owner_team_gtid
|
||||
=======
|
||||
@organization = Organization.build(params[:name])
|
||||
org_extension = OrganizationExtension.build(@organization.id, description, website,
|
||||
location, repo_admin_change_team_access,
|
||||
visibility, max_repo_creation)
|
||||
team = Team.build_owner(@organization.id)
|
||||
TeamUnit.build_owner(@organization.id, team.id)
|
||||
OrganizationUser.build(@organization.id, user.id, true)
|
||||
TeamUser.build(@organization.id, user.id, team.id)
|
||||
|
||||
Gitea::Organization::CreateService.call(user.gitea_token, @organization)
|
||||
>>>>>>> 38887e6... [FIX]
|
||||
|
||||
Rails.logger.info("######Organization create_service end######")
|
||||
end
|
||||
@organization
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
private
|
||||
def description
|
||||
params[:description]
|
||||
|
@ -44,20 +30,8 @@ class Organizations::CreateService < ApplicationService
|
|||
params[:website]
|
||||
end
|
||||
|
||||
def location
|
||||
params[:location]
|
||||
=======
|
||||
def description
|
||||
params[:description].present? ? params[:description] : nil
|
||||
end
|
||||
|
||||
def website
|
||||
params[:website].present? ? params[:website] : nil
|
||||
end
|
||||
|
||||
def location
|
||||
params[:location].present? ? params[:location] : nil
|
||||
>>>>>>> 38887e6... [FIX]
|
||||
end
|
||||
|
||||
def repo_admin_change_team_access
|
||||
|
|
|
@ -65,7 +65,11 @@ class Organizations::Teams::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
def create_gitea_team
|
||||
<<<<<<< HEAD
|
||||
@gitea_team = Gitea::Organization::Team::CreateService.call(org.gitea_token, org, team)
|
||||
=======
|
||||
@gitea_team = Gitea::Organization::Team::CreateService.call(user.gitea_token, org, team)
|
||||
>>>>>>> 4a50873... [ADD]组织、组织团队
|
||||
end
|
||||
|
||||
def sync_team_gtid
|
||||
|
|
|
@ -4,4 +4,4 @@ json.user do
|
|||
end
|
||||
|
||||
json.team_names org_user.teams.pluck(:name)
|
||||
json.created_at org_user.created_at.strftime("%Y-%m-%d")
|
||||
json.created_at org_user.created_at.strftime("%Y-%m-%d")
|
||||
|
|
|
@ -2,4 +2,4 @@ json.id team_user.id
|
|||
json.user do
|
||||
json.partial! "organizations/user_detail", user: team_user.user
|
||||
end
|
||||
json.created_at team_user.created_at.strftime("%Y-%m-%d")
|
||||
json.created_at team_user.created_at.strftime("%Y-%m-%d")
|
||||
|
|
Loading…
Reference in New Issue