add: org add nickname
This commit is contained in:
parent
a66e5b876d
commit
d6c3bcfaf1
|
@ -36,8 +36,10 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
def update
|
def update
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
login = @organization.login
|
login = @organization.login
|
||||||
@organization.update!(login: organization_params[:name]) if organization_params[:name].present?
|
@organization.login = organization_params[:name] if organization_params[:name].present?
|
||||||
@organization.organization_extension.update_attributes!(organization_params.except(:name))
|
@organization.nickname = organization_params[:nickname] if organization_params[:nickname].present?
|
||||||
|
@organization.save!
|
||||||
|
@organization.organization_extension.update_attributes!(organization_params.except(:name, :nickname))
|
||||||
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
|
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
|
||||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||||
end
|
end
|
||||||
|
@ -82,7 +84,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
def organization_params
|
def organization_params
|
||||||
params.permit(:name, :description, :website, :location,
|
params.permit(:name, :description, :website, :location,
|
||||||
:repo_admin_change_team_access, :visibility,
|
:repo_admin_change_team_access, :visibility,
|
||||||
:max_repo_creation)
|
:max_repo_creation, :nickname)
|
||||||
end
|
end
|
||||||
|
|
||||||
def password
|
def password
|
||||||
|
|
|
@ -78,8 +78,8 @@ class Organization < Owner
|
||||||
|
|
||||||
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
||||||
|
|
||||||
def self.build(name, gitea_token=nil)
|
def self.build(name, nickname, gitea_token=nil)
|
||||||
self.create!(login: name, gitea_token: gitea_token)
|
self.create!(login: name, nickname: nickname, gitea_token: gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_create_project?(user_id)
|
def can_create_project?(user_id)
|
||||||
|
@ -113,7 +113,9 @@ class Organization < Owner
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
login
|
name = lastname + firstname
|
||||||
|
name = name.blank? ? (nickname.blank? ? login : nickname) : name
|
||||||
|
name.gsub(/\s+/, '').strip #6.11 -hs
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_real_name
|
def show_real_name
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_org_and_extension
|
def create_org_and_extension
|
||||||
@organization = Organization.build(params[:name], user.gitea_token)
|
@organization = Organization.build(params[:name], params[:nickname], user.gitea_token)
|
||||||
org_extension = OrganizationExtension.build(organization.id, description, website,
|
org_extension = OrganizationExtension.build(organization.id, description, website,
|
||||||
location, repo_admin_change_team_access,
|
location, repo_admin_change_team_access,
|
||||||
visibility, max_repo_creation)
|
visibility, max_repo_creation)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
json.id organization.id
|
json.id organization.id
|
||||||
json.name organization.login
|
json.name organization.login
|
||||||
|
json.nickname organization.nickname
|
||||||
json.description organization.description
|
json.description organization.description
|
||||||
json.website organization.website
|
json.website organization.website
|
||||||
json.location organization.location
|
json.location organization.location
|
||||||
|
|
Loading…
Reference in New Issue