add: team unit add type wiki

This commit is contained in:
yystopf 2021-08-24 18:30:58 +08:00
parent 3caa751d4d
commit 43add36d29
3 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ class Team < ApplicationRecord
validates :name, uniqueness: {scope: :organization_id} validates :name, uniqueness: {scope: :organization_id}
enum authorize: {common: 0, read: 1, write: 2, admin: 3, owner: 4} enum authorize: {read: 1, write: 2, admin: 3, owner: 4}
def self.build(organization_id, name, nickname, description, authorize, includes_all_project, can_create_org_project) def self.build(organization_id, name, nickname, description, authorize, includes_all_project, can_create_org_project)
self.create!(organization_id: organization_id, self.create!(organization_id: organization_id,

View File

@ -20,7 +20,7 @@ class TeamUnit < ApplicationRecord
belongs_to :organization belongs_to :organization
belongs_to :team belongs_to :team
enum unit_type: {code: 1, issues: 2, pulls: 3, releases: 4} enum unit_type: {code: 1, issues: 2, pulls: 3, wiki: 4, releases: 5}
validates :unit_type, uniqueness: { scope: [:organization_id, :team_id]} validates :unit_type, uniqueness: { scope: [:organization_id, :team_id]}

View File

@ -37,7 +37,7 @@ class Organizations::Teams::CreateService < ApplicationService
end end
def authorize def authorize
params[:authorize].present? ? params[:authorize] : "common" params[:authorize].present? ? params[:authorize] : "read"
end end
def includes_all_project def includes_all_project
@ -54,7 +54,7 @@ class Organizations::Teams::CreateService < ApplicationService
end end
def units_params def units_params
%w(admin owner).include?(authorize) ? %w(code issues pulls releases) : params[:unit_types] %w(admin owner).include?(authorize) ? %w(code issues pulls wiki releases) : params[:unit_types]
end end
def create_units def create_units