aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/gtfs_export.rb
blob: 86bf3c368293c40ed9fcf5bba07b8b31a0274a5d (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
36
37
38
39
class GtfsExport < ExportTask

  validates_presence_of :time_zone
  attr_accessor :time_zone, :object_id_prefix

  enumerize :references_type, in: %w( network line company group_of_line stop_area )
  
  after_initialize :init_params
  
  def init_params
    if time_zone.nil?
      self.time_zone = "Paris"
    end
  end

  def time_zone=(time_zone)
    ActiveSupport::TimeZone.find_tzinfo(time_zone).name
  end

  def action_params
    {
      "gtfs-export" => {
        "name" => name,
        "references_type" => references_type,
        "reference_ids" => reference_ids,
        "user_name" => user_name,
        "organisation_name" => organisation.name,
        "referential_name" => referential.name,
        "time_zone" => time_zone,
        "object_id_prefix" => object_id_prefix
      }
    }
  end

  def data_format
    "gtfs"
  end

end