blob: fb141c164d30fe32d27973882bf4adc7a70e9601 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# frozen_string_literal: true
module Organizations
class OrganizationSetting < ApplicationRecord
extend ::Organization::CurrentOrganization
belongs_to :organization
validates :settings, json_schema: { filename: "organization_settings" }
jsonb_accessor :settings,
restricted_visibility_levels: [:integer, { array: true }]
validates_each :restricted_visibility_levels do |record, attr, value|
value&.each do |level|
unless Gitlab::VisibilityLevel.options.value?(level)
record.errors.add(attr, format(_("'%{level}' is not a valid visibility level"), level: level))
end
end
end
def self.for_current_organization
return unless current_organization
current_organization.settings || current_organization.build_settings
end
end
end
|