forked from Gitlink/forgeplus
Merge branch 'develop' of https://git.trustie.net/jasder/forgeplus into develop
This commit is contained in:
commit
1f0388c1a1
|
@ -25,6 +25,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
Organizations::CreateForm.new(organization_params).validate!
|
||||
@organization = Organizations::CreateService.call(current_user, organization_params)
|
||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||
end
|
||||
|
|
|
@ -33,7 +33,10 @@ class Organizations::TeamsController < Organizations::BaseController
|
|||
end
|
||||
|
||||
def create
|
||||
@team = Organizations::Teams::CreateService.call(current_user, @organization, team_params)
|
||||
ActiveRecord::Base.transaction do
|
||||
Organizations::CreateTeamForm.new(team_params).validate!
|
||||
@team = Organizations::Teams::CreateService.call(current_user, @organization, team_params)
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
|
@ -60,7 +63,7 @@ class Organizations::TeamsController < Organizations::BaseController
|
|||
|
||||
private
|
||||
def team_params
|
||||
params.permit(:name, :description, :authorize, :includes_all_project, :can_create_org_project, :unit_types => [])
|
||||
params.permit(:name, :nickname, :description, :authorize, :includes_all_project, :can_create_org_project, :unit_types => [])
|
||||
end
|
||||
|
||||
def load_organization
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class Organizations::CreateForm < BaseForm
|
||||
NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾
|
||||
attr_accessor :name, :description, :website, :location, :repo_admin_change_team_access, :visibility, :max_repo_creation, :nickname
|
||||
|
||||
validates :name, :nickname, :visibility, presence: true
|
||||
validates :name, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class Organizations::CreateTeamForm < BaseForm
|
||||
NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾
|
||||
attr_accessor :name, :nickname, :description, :authorize, :includes_all_project, :can_create_org_project, :unit_types
|
||||
|
||||
validates :name, :nickname, :authorize, presence: true
|
||||
validates :name, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
||||
|
||||
end
|
|
@ -158,6 +158,7 @@ class Project < ApplicationRecord
|
|||
|
||||
#创建项目管理员
|
||||
def check_project_members
|
||||
return if owner.is_a?(Organization)
|
||||
unless members.present? && members.exists?(user_id: self.user_id)
|
||||
member_params = {
|
||||
user_id: self.user_id,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# gtid :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# nickname :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -27,7 +27,7 @@ class Organizations::Teams::UpdateService < ApplicationService
|
|||
if team.authorize == "owner"
|
||||
update_params = params.slice(:description)
|
||||
else
|
||||
update_params = params.slice(:name, :description, :authorize, :includes_all_project, :can_create_org_project)
|
||||
update_params = params.slice(:name, :nickname, :description, :authorize, :includes_all_project, :can_create_org_project)
|
||||
end
|
||||
update_params
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
json.id organization.id
|
||||
json.name organization.login
|
||||
json.nickname organization.nickname
|
||||
json.nickname organization.nickname.blank? ? organization.name : organization.nickname
|
||||
json.description organization.description
|
||||
json.website organization.website
|
||||
json.location organization.location
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.id team.id
|
||||
json.name team.name
|
||||
json.nickname team.nickname.blank? ? team.name : team.nickname
|
||||
json.description team.description
|
||||
json.authorize team.authorize
|
||||
json.includes_all_project team.includes_all_project
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddNicknameToTeams < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :teams, :nickname, :string
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue