aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/export.rb
diff options
context:
space:
mode:
authorLuc Donnet2015-04-27 16:30:07 +0200
committerLuc Donnet2015-04-27 16:30:07 +0200
commit245286c7643b426b36deb400b7c7682c88eb4c2d (patch)
treea200f399988d130ddbb377b9c89bb4bb36265727 /app/models/export.rb
parent8d2329a9c7172689901186e293951fb48636b254 (diff)
downloadchouette-core-245286c7643b426b36deb400b7c7682c88eb4c2d.tar.bz2
Update export views
Diffstat (limited to 'app/models/export.rb')
-rw-r--r--app/models/export.rb63
1 files changed, 19 insertions, 44 deletions
diff --git a/app/models/export.rb b/app/models/export.rb
index 95317504a..b9cef12e0 100644
--- a/app/models/export.rb
+++ b/app/models/export.rb
@@ -10,8 +10,16 @@ class Export
@datas = response
end
+ def links
+ {}.tap do |links|
+ datas.links.each do |link|
+ links[link["rel"]] = link["href"]
+ end
+ end
+ end
+
def report
- report_path = datas.links.select{ |link| link["rel"] == "action_report"}.first.href
+ report_path = links["action_report"]
if report_path
response = Ievkit.get(report_path)
ExportReport.new(response)
@@ -20,31 +28,16 @@ class Export
end
end
- def compliance_check
- compliance_check_path = datas.links.select{ |link| link["rel"] == "validation_report"}.first.href
- if compliance_check_path
- response = Ievkit.get(compliance_check_path)
- ComplianceCheck.new(response)
- else
- raise Ievkit::Error("Impossible to access compliance check path link for export")
- end
- end
-
- def delete
- delete_path = datas.links.select{ |link| link["rel"] == "delete"}.first.href
+ def destroy
+ delete_path = links["delete"]
+ cancel_path = links["cancel"]
+
if delete_path
Ievkit.delete(delete_path)
- else
- raise Ievkit::Error("Impossible to access delete path link for export")
- end
- end
-
- def cancel
- cancel_path = datas.links.select{ |link| link["rel"] == "cancel"}.first.href
- if cancel_path
+ elsif cancel_path
Ievkit.delete(cancel_path)
else
- raise Ievkit::Error("Impossible to access cancel path link for export")
+ raise Ievkit::Error("Impossible to access delete or cancel path link for import")
end
end
@@ -53,7 +46,7 @@ class Export
end
def status
- datas.status
+ datas.status.downcase
end
def format
@@ -68,16 +61,6 @@ class Export
File.extname(filename) if filename
end
- def percentage_progress
- if %w{created}.include? status
- 0
- elsif %w{ terminated canceled aborted }.include? status
- 100
- else
- 20
- end
- end
-
def referential_name
datas.referential
end
@@ -90,19 +73,11 @@ class Export
datas.action_parameters.user_name
end
- def created_at?
- datas.created?
- end
-
- def created_at
- Time.at(datas.created.to_i / 1000) if created_at?
+ def created_at
+ Time.at(datas.created.to_i / 1000) if datas.created
end
- def updated_at?
- datas.updated?
- end
-
def updated_at
- Time.at(datas.updated.to_i / 1000) if updated_at?
+ Time.at(datas.updated.to_i / 1000) if datas.updated
end
end