45 lines
1.5 KiB
Ruby
45 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: teams
|
|
#
|
|
# id :integer not null, primary key
|
|
# organization_id :integer
|
|
# name :string(255)
|
|
# description :string(255)
|
|
# authorize :integer default("0")
|
|
# num_projects :integer default("0")
|
|
# num_users :integer default("0")
|
|
# includes_all_project :boolean default("0")
|
|
# can_create_org_project :boolean default("0")
|
|
# gtid :integer
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_teams_on_organization_id (organization_id)
|
|
#
|
|
|
|
class Team < ApplicationRecord
|
|
|
|
belongs_to :organization
|
|
has_many :team_projects, dependent: :destroy
|
|
has_many :team_units, dependent: :destroy
|
|
has_many :team_users, dependent: :destroy
|
|
|
|
enum authorize: {common: 0, read: 1, write: 2, admin: 3, owner: 4}
|
|
|
|
def self.build(organization_id, name, description, authorize, includes_all_project, can_create_org_project)
|
|
self.create!(organization_id: organization_id,
|
|
name: name,
|
|
description: description,
|
|
authorize: authorize,
|
|
includes_all_project: includes_all_project,
|
|
can_create_org_project: can_create_org_project)
|
|
end
|
|
|
|
def self.build_owner(organization_id)
|
|
self.build(organization_id, "Owner", "", 4, true, true)
|
|
end
|
|
end
|