aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers/stif.rb
blob: 7a61e70449c03d6ff5822cd3230445385bd2d797 (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
# coding: utf-8

Rails.application.config.to_prepare do
  Organisation.after_create do |organisation|
    unless organisation.code == "STIF" # seed is in action
      line_referential      = LineReferential.find_by(name: "CodifLigne")
      stop_area_referential = StopAreaReferential.find_by(name: "Reflex")

      line_referential.organisations << organisation
      stop_area_referential.organisations << organisation

      workgroup = Workgroup.find_or_create_by(name: "Gestion de l'offre théorique IDFm") do |w|
        w.line_referential      = line_referential
        w.stop_area_referential = stop_area_referential
      end

      organisation.workbenches.find_or_create_by(name: "Gestion de l'offre") do |w|
        w.line_referential      = line_referential
        w.stop_area_referential = stop_area_referential
        w.objectid_format       = Workbench.objectid_format.stif_netex
        w.workgroup             = workgroup

        Rails.logger.debug "Create Workbench for #{organisation.name}"
      end
    end
  end
end

Rails.application.config.to_prepare do
  Organisation.before_validation(on: :create) do |organisation|
    organisation.custom_view = "stif"
  end
  Dashboard.default_class = Stif::Dashboard
  Chouette::VehicleJourneyAtStop.day_offset_max = 1
end