diff options
Diffstat (limited to 'app/models/hub_export.rb')
| -rw-r--r-- | app/models/hub_export.rb | 67 | 
1 files changed, 37 insertions, 30 deletions
| diff --git a/app/models/hub_export.rb b/app/models/hub_export.rb index 88c8e061c..8bd2e3a96 100644 --- a/app/models/hub_export.rb +++ b/app/models/hub_export.rb @@ -1,35 +1,42 @@ -# class HubExport < Export +class HubExport < ExportTask -#   option :start_date -#   option :end_date -   -#   after_initialize :init_period +  attr_accessor :start_date, :end_date +  enumerize :references_type, in: %w( all network line company groupofline ) + +  validates :start_date, presence: true , if: "end_date.present?"    +  validates :end_date, presence: true, if: "start_date.present?"  -#   def init_period -#     unless Chouette::TimeTable.start_validity_period.nil? -#       if start_date.nil? -#         self.start_date = Chouette::TimeTable.start_validity_period -#       end -#       if end_date.nil? -#         self.end_date = Chouette::TimeTable.end_validity_period -#       end -#     end -#   end +  after_initialize :init_period -#   def export_options -#     if (start_date.empty? && end_date.empty?) -#       super.merge(:format => :hub).except(:start_date).except(:end_date) -#     elsif start_date.empty? -#       super.merge(:format => :hub, :end_date => end_date).except(:start_date) -#     elsif end_date.empty? -#       super.merge(:format => :hub, :start_date => start_date).except(:end_date) -#     else -#       super.merge(:format => :hub, :start_date => start_date, :end_date => end_date) -#     end -#   end +  def init_period +    unless Chouette::TimeTable.start_validity_period.nil? +      if start_date.nil? +        self.start_date = Chouette::TimeTable.start_validity_period +      end +      if end_date.nil? +        self.end_date = Chouette::TimeTable.end_validity_period +      end +    end +  end + +  def action_params +    { +      "parameters" => { +        "hub-export" => { +          "name" => name, +          "references_type" => references_type, +          "user_name" => user_name, +          "organisation_name" => organisation.name, +          "referential_name" => referential.name, +          "start_date" => start_date, +          "end_date" => end_date +        } +      } +    } +  end -#   def exporter -#     exporter ||= ::Chouette::Hub::Exporter.new(referential, self) -#   end +  def data_format +    "hub" +  end  -# end +end | 
