aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/workgroup.rb
blob: 6a1746eb8ceb8624ebdd4a0b64be240a4f763df4 (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
29
30
31
32
33
34
35
class Workgroup < ApplicationModel
  belongs_to :line_referential
  belongs_to :stop_area_referential

  has_many :workbenches
  has_many :calendars
  has_many :organisations, through: :workbenches
  has_many :referentials, through: :workbenches

  validates_uniqueness_of :name

  validates_presence_of :line_referential_id
  validates_presence_of :stop_area_referential_id
  validates_uniqueness_of :stop_area_referential_id
  validates_uniqueness_of :line_referential_id

  has_many :custom_fields

  def custom_fields_definitions
    Hash[*custom_fields.map{|cf| [cf.code, cf]}.flatten]
  end

  def has_export? export_name
    export_types.include? export_name
  end

  def import_compliance_control_set_id
    # XXX
    nil
  end

  def import_compliance_control_set
    import_compliance_control_set_id && ComplianceControlSet.find(import_compliance_control_set_id)
  end
end