diff options
| author | Zog | 2018-03-07 08:38:38 +0100 | 
|---|---|---|
| committer | Zog | 2018-03-12 12:00:14 +0100 | 
| commit | 0b9269780989dbd69a9be9d63670aab12050cf60 (patch) | |
| tree | 1c9d3c4c5c9a881b1ffb5402705941cf2d9318e0 /app/models/import | |
| parent | 565641838e020f992e58f05d94ab0097b74a27b2 (diff) | |
| download | chouette-core-0b9269780989dbd69a9be9d63670aab12050cf60.tar.bz2 | |
Refs #6133; Exports naive implementation
Diffstat (limited to 'app/models/import')
| -rw-r--r-- | app/models/import/base.rb | 37 | 
1 files changed, 2 insertions, 35 deletions
| diff --git a/app/models/import/base.rb b/app/models/import/base.rb index 0e1eae2c0..e2ae129be 100644 --- a/app/models/import/base.rb +++ b/app/models/import/base.rb @@ -11,51 +11,17 @@ class Import::Base < ActiveRecord::Base    include IevInterfaces::Task -  mount_uploader :file, ImportUploader - -  has_many :children, foreign_key: :parent_id, class_name: "Import::Base", dependent: :destroy - -  validates :file, presence: true - -  before_create :initialize_fields -    def self.model_name      ActiveModel::Name.new Import::Base, Import::Base, "Import::Base"    end -  def children_succeedeed -    children.with_status(:successful, :warning).count -  end -    def child_change      return if self.class.finished_statuses.include?(status) -    update_status +    super      update_referentials    end -  def update_status -    status = -      if children.where(status: self.class.failed_statuses).count > 0 -        'failed' -      elsif children.where(status: "warning").count > 0 -        'warning' -      elsif children.where(status: "successful").count == children.count -        'successful' -      end - -    attributes = { -      current_step: children.count, -      status: status -    } - -    if self.class.finished_statuses.include?(status) -      attributes[:ended_at] = Time.now -    end - -    update attributes -  end -    def update_referentials      return unless self.class.finished_statuses.include?(status) @@ -67,6 +33,7 @@ class Import::Base < ActiveRecord::Base    private    def initialize_fields +    super      self.token_download = SecureRandom.urlsafe_base64    end | 
