aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2015-04-28 11:33:06 +0200
committerLuc Donnet2015-04-28 11:33:06 +0200
commit65c184fd0408f5f1d2eec6891cfdf918eb7c8b3b (patch)
tree0d051f7a1a5e6f91c6a84c1baa34edfddc9b1206
parentabdfb2c468c6267bcf3cdc335faa05132e5a6a2a (diff)
downloadchouette-core-65c184fd0408f5f1d2eec6891cfdf918eb7c8b3b.tar.bz2
refactor css and model for import
-rw-r--r--app/assets/stylesheets/main/exports.css.scss57
-rw-r--r--app/assets/stylesheets/main/imports.css.scss67
-rw-r--r--app/assets/stylesheets/modules/report.css.scss65
-rw-r--r--app/models/import.rb10
-rw-r--r--app/models/import_task.rb18
5 files changed, 89 insertions, 128 deletions
diff --git a/app/assets/stylesheets/main/exports.css.scss b/app/assets/stylesheets/main/exports.css.scss
index dd5a38f48..b4f8cfbad 100644
--- a/app/assets/stylesheets/main/exports.css.scss
+++ b/app/assets/stylesheets/main/exports.css.scss
@@ -7,60 +7,5 @@
}
#workspace.exports.show {
- .resume {
- &:after{
- content: " ";
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
- }
-
- #files_statistics { height: 225px; }
- #objects_statistics { height: 225px; }
-
- .caption {
- text-align :center;
- font-weight: bold;
- }
- }
-
- .report {
- margin-top: 20px;
-
- .files {
- img {
- margin-right: 5px;
- }
-
- .file_name{
- font-weight: bold;
- margin-right: 30px;
- }
- }
-
- .files_error{
- color: #e22b1b;
- display: none;
- }
-
- .files_ignored{
- color: #898e7f;
- display: none;
- }
-
- .files_ok{
- color: #8fc861;
- display: none;
- }
-
- .lines{
- display: none;
-
- th, td{
- text-align: center;
- }
-
- }
- }
+ @import "../modules/report";
}
diff --git a/app/assets/stylesheets/main/imports.css.scss b/app/assets/stylesheets/main/imports.css.scss
index 8ac7314ff..a91bb3afe 100644
--- a/app/assets/stylesheets/main/imports.css.scss
+++ b/app/assets/stylesheets/main/imports.css.scss
@@ -3,75 +3,12 @@
}
#workspace.imports.show {
-
- .status {
- margin-left: 10px;
- }
-
- .status_aborted,.status_canceled { color: #a94442;}
- .status_created { color: #31708f;}
- .status_scheduled { color: #31708f;}
- .status_terminated { color: #3c763d;}
+ @import "../modules/report";
.links{
margin: 0 0 20px 0;
img{ margin: 0 5px 0 15px; }
}
- .resume {
- &:after{
- content: " ";
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
- }
-
- #files_statistics { height: 225px; }
- #objects_statistics { height: 225px; }
-
- .caption {
- text-align :center;
- font-weight: bold;
- }
- }
-
- .report {
- margin-top: 20px;
-
- .files {
- img {
- margin-right: 5px;
- }
-
- .file_name{
- font-weight: bold;
- margin-right: 30px;
- }
- }
-
- .files_error{
- color: #e22b1b;
- display: none;
- }
-
- .files_ignored{
- color: #898e7f;
- display: none;
- }
-
- .files_ok{
- color: #8fc861;
- display: none;
- }
-
- .lines{
- display: none;
-
- th, td{
- text-align: center;
- }
-
- }
- }
+
}
diff --git a/app/assets/stylesheets/modules/report.css.scss b/app/assets/stylesheets/modules/report.css.scss
new file mode 100644
index 000000000..f983925f3
--- /dev/null
+++ b/app/assets/stylesheets/modules/report.css.scss
@@ -0,0 +1,65 @@
+.status {
+ margin-left: 10px;
+}
+
+.status_aborted,.status_canceled { color: #a94442;}
+.status_started { color: #31708f;}
+.status_scheduled { color: #31708f;}
+.status_terminated { color: #3c763d;}
+
+.resume {
+ &:after{
+ content: " ";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
+
+ #files_statistics { height: 225px; }
+ #objects_statistics { height: 225px; }
+
+ .caption {
+ text-align :center;
+ font-weight: bold;
+ }
+}
+
+.report {
+ margin-top: 20px;
+
+ .files {
+ img {
+ margin-right: 5px;
+ }
+
+ .file_name{
+ font-weight: bold;
+ margin-right: 30px;
+ }
+ }
+
+ .files_error{
+ color: #e22b1b;
+ display: none;
+ }
+
+ .files_ignored{
+ color: #898e7f;
+ display: none;
+ }
+
+ .files_ok{
+ color: #8fc861;
+ display: none;
+ }
+
+ .lines{
+ display: none;
+
+ th, td{
+ text-align: center;
+ }
+
+ }
+}
diff --git a/app/models/import.rb b/app/models/import.rb
index 13e76823f..f626e89bc 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -28,6 +28,16 @@ class Import
end
end
+ def rule_parameter_set
+ rule_parameter_set_path = links["validation_report"]
+ if rule_parameter_set_path
+ response = Ievkit.get(rule_parameter_set_path)
+ #ComplianceCheck.new(response)
+ else
+ raise Ievkit::Error("Impossible to access rule parameter set path link for import")
+ end
+ end
+
def compliance_check
compliance_check_path = links["validation_report"]
if compliance_check_path
diff --git a/app/models/import_task.rb b/app/models/import_task.rb
index 797085752..b454983d4 100644
--- a/app/models/import_task.rb
+++ b/app/models/import_task.rb
@@ -43,7 +43,7 @@ class ImportTask
# Call Iev Server
begin
Ievkit.create_job(referential.name, "importer", data_format, {
- :file1 => action_params_io,
+ :file1 => params_io,
:file2 => transport_data_io
}
@@ -69,11 +69,13 @@ class ImportTask
def self.data_formats
self.data_format.values
end
-
- def action_params_io
- file = StringIO.new( action_params.to_s )
+
+ def params_io
+ params = action_params.merge(validation_params)
+ puts params.inspect
+ file = StringIO.new( params.to_s )
Faraday::UploadIO.new(file, "application/json", "parameters.json")
- end
+ end
def transport_data_io
file = File.new(saved_resources_path, "r")
@@ -85,8 +87,10 @@ class ImportTask
end
# TODO : How to find RuleParameterSet
- def rule_parameter_set_io
- UploadIO.new(rule_parameter_set.parameters, "application/octet-stream", "rule_parameter_set") if rule_parameter_set.present?
+ def validation_params
+ {
+ "validation" => rule_parameter_set.parameters
+ } if rule_parameter_set.present?
end
def save_resources