forked from Gitlink/forgeplus
组织支持中文名称
This commit is contained in:
commit
c3a1fb78ea
|
@ -36,8 +36,10 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
login = @organization.login
|
||||
@organization.update!(login: organization_params[:name]) if organization_params[:name].present?
|
||||
@organization.organization_extension.update_attributes!(organization_params.except(:name))
|
||||
@organization.login = organization_params[:name] if organization_params[:name].present?
|
||||
@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)
|
||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||
end
|
||||
|
@ -82,7 +84,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
def organization_params
|
||||
params.permit(:name, :description, :website, :location,
|
||||
:repo_admin_change_team_access, :visibility,
|
||||
:max_repo_creation)
|
||||
:max_repo_creation, :nickname)
|
||||
end
|
||||
|
||||
def password
|
||||
|
|
|
@ -16,6 +16,7 @@ class ProjectsController < ApplicationController
|
|||
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
|
||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
||||
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources")
|
||||
menu.append(menu_hash_by_name("activity"))
|
||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module RepositoriesHelper
|
||||
def render_permission(user, project)
|
||||
return "Admin" if user&.admin?
|
||||
return "Owner" if user === project.owner
|
||||
project.get_premission(user)
|
||||
end
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ class Organization < Owner
|
|||
|
||||
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
||||
|
||||
def self.build(name, gitea_token=nil)
|
||||
self.create!(login: name, gitea_token: gitea_token)
|
||||
def self.build(name, nickname, gitea_token=nil)
|
||||
self.create!(login: name, nickname: nickname, gitea_token: gitea_token)
|
||||
end
|
||||
|
||||
def can_create_project?(user_id)
|
||||
|
@ -113,7 +113,9 @@ class Organization < Owner
|
|||
end
|
||||
|
||||
def real_name
|
||||
login
|
||||
name = lastname + firstname
|
||||
name = name.blank? ? (nickname.blank? ? login : nickname) : name
|
||||
name.gsub(/\s+/, '').strip #6.11 -hs
|
||||
end
|
||||
|
||||
def show_real_name
|
||||
|
|
|
@ -242,10 +242,12 @@ class Project < ApplicationRecord
|
|||
end
|
||||
|
||||
def get_premission user
|
||||
permission = "Reporter"
|
||||
member = members.find_by(user: user)
|
||||
return "Owner" if owner?(user)
|
||||
return "Manager" if manager?(user)
|
||||
return "Developer" if develper?(user)
|
||||
return "Reporter" if reporter?(user)
|
||||
|
||||
member&.roles&.last&.name || permission
|
||||
return ""
|
||||
end
|
||||
|
||||
def fork_project
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
class ProjectUnit < ApplicationRecord
|
||||
belongs_to :project
|
||||
|
||||
enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5}
|
||||
enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5, resources: 6}
|
||||
|
||||
validates :unit_type, uniqueness: { scope: :project_id}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
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,
|
||||
location, repo_admin_change_team_access,
|
||||
visibility, max_repo_creation)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.id organization.id
|
||||
json.name organization.login
|
||||
json.nickname organization.nickname
|
||||
json.description organization.description
|
||||
json.website organization.website
|
||||
json.location organization.location
|
||||
|
|
|
@ -25,6 +25,7 @@ json.projects @projects do |project|
|
|||
json.image_url render_educoder_avatar_url(project.project_educoder)
|
||||
else
|
||||
user = project.owner
|
||||
json.type user.type
|
||||
json.name user.try(:show_real_name)
|
||||
json.login user.login
|
||||
json.image_url render_avatar_url(user)
|
||||
|
|
Loading…
Reference in New Issue