diff options
| author | Michel Etienne | 2012-06-13 09:40:38 +0200 |
|---|---|---|
| committer | Michel Etienne | 2012-06-13 09:40:38 +0200 |
| commit | 1b9b836f25cd7af78c0ec5f48b999e1dea27fa97 (patch) | |
| tree | 1a9bbea9c68e1c083d707925513e2223b07c87c9 | |
| parent | 132e0d11e9f6d558a420a9ef6ce0a355222e67ec (diff) | |
| download | chouette-core-1b9b836f25cd7af78c0ec5f48b999e1dea27fa97.tar.bz2 | |
show import log for Neptune and CSV formats
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | app/assets/images/severity-fatal.png | bin | 0 -> 523 bytes | |||
| -rw-r--r-- | app/assets/images/severity-ok.png | bin | 0 -> 1277 bytes | |||
| -rw-r--r-- | app/assets/images/severity-uncheck.png | bin | 0 -> 225 bytes | |||
| -rw-r--r-- | app/models/import.rb | 9 | ||||
| -rw-r--r-- | app/models/import_log_message.rb | 3 | ||||
| -rw-r--r-- | config/environments/development.rb | 4 | ||||
| -rw-r--r-- | config/environments/production.rb | 2 | ||||
| -rw-r--r-- | config/environments/test.rb | 2 | ||||
| -rw-r--r-- | config/locales/imports.yml | 82 | ||||
| -rw-r--r-- | db/migrate/20120611090254_resize_argument_to_import_log_messages.rb | 5 | ||||
| -rw-r--r-- | db/migrate/20120611090325_resize_argument_to_export_log_messages.rb | 5 | ||||
| -rw-r--r-- | db/migrate/20120612071936_add_file_type_to_import.rb | 8 | ||||
| -rw-r--r-- | db/schema.rb | 7 |
14 files changed, 117 insertions, 12 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 5e192e69c..03f9e748b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: e97b575029669774bd03101e24f7c13a8afe5631 + revision: 8b078199d237b4d0b26a881b7a93ddf671163cf5 specs: ninoxe (0.0.8) GeoRuby diff --git a/app/assets/images/severity-fatal.png b/app/assets/images/severity-fatal.png Binary files differnew file mode 100644 index 000000000..2cb3e9113 --- /dev/null +++ b/app/assets/images/severity-fatal.png diff --git a/app/assets/images/severity-ok.png b/app/assets/images/severity-ok.png Binary files differnew file mode 100644 index 000000000..ab7c378c0 --- /dev/null +++ b/app/assets/images/severity-ok.png diff --git a/app/assets/images/severity-uncheck.png b/app/assets/images/severity-uncheck.png Binary files differnew file mode 100644 index 000000000..4a892e60c --- /dev/null +++ b/app/assets/images/severity-uncheck.png diff --git a/app/models/import.rb b/app/models/import.rb index c96d2fdad..662fe4a84 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -61,6 +61,11 @@ class Import < ActiveRecord::Base self.status ||= "pending" end + before_validation :extract_file_type, :on => :create + def extract_file_type + self.file_type = resources.original_filename.rpartition(".").last + end + after_create :delayed_import def delayed_import save_resources @@ -81,7 +86,7 @@ class Import < ActiveRecord::Base end def saved_resources - "#{root}/#{id}.zip" + "#{root}/#{id}.#{file_type}" end def name @@ -89,7 +94,7 @@ class Import < ActiveRecord::Base end def import_options - { :import_id => self.id } + { :import_id => self.id , :file_format => self.file_type } end def import diff --git a/app/models/import_log_message.rb b/app/models/import_log_message.rb index 699c9603d..f06a61213 100644 --- a/app/models/import_log_message.rb +++ b/app/models/import_log_message.rb @@ -30,7 +30,8 @@ class ImportLogMessage < ActiveRecord::Base end def full_message - I18n.translate key, arguments.symbolize_keys.merge(:scope => "import_log_messages.messages") + last_key=key.rpartition("|").last + I18n.translate last_key, arguments.symbolize_keys.merge(:scope => "import_log_messages.messages").merge(:default => :undefined).merge(:key => last_key) end end diff --git a/config/environments/development.rb b/config/environments/development.rb index b6fd603a1..250c17def 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -33,9 +33,9 @@ ChouetteIhm::Application.configure do config.to_prepare do chouette_command_script = "tmp/chouette-command/chouette" if File.exists? chouette_command_script - Chouette::Loader.chouette_command = "tmp/chouette-command/chouette" + Chouette::Command.command = "tmp/chouette-command/chouette" else - Chouette::Loader.chouette_command = "true" + Chouette::Command.command = "true" end end diff --git a/config/environments/production.rb b/config/environments/production.rb index d79d98df7..ffbd6be76 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,7 +65,7 @@ ChouetteIhm::Application.configure do config.action_mailer.default_url_options = { :host => 'chouette.dryade.net/chouette2' } config.to_prepare do - Chouette::Loader.chouette_command = "/usr/local/lib/chouette-command/chouette" + Chouette::Command.command = "/usr/local/lib/chouette-command/chouette" Import.root = "/var/lib/chouette/imports" end diff --git a/config/environments/test.rb b/config/environments/test.rb index 33c54b4f4..b2c29057b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -38,6 +38,6 @@ ChouetteIhm::Application.configure do config.active_support.deprecation = :stderr config.to_prepare do - Chouette::Loader.chouette_command = "true" + Chouette::Command.command = "true" end end diff --git a/config/locales/imports.yml b/config/locales/imports.yml index 40db6d65e..af8867bc1 100644 --- a/config/locales/imports.yml +++ b/config/locales/imports.yml @@ -19,10 +19,50 @@ en: started: Started import completed: Completed import failed: Failed import + undefined: %{key} undefined + NEPTUNE_ONE: Conformité du fichier + NEPTUNE_Test1_Sheet1: 'Fiche n° 1.1 : Conformité à la syntaxe XML suivant les recommandations du W3C' + NEPTUNE_Test1_Sheet1_Step1: Conformité à la syntaxe XML + NEPTUNE_Test1_Sheet1_Step2: Conformité au schéma XML du profil CHOUETTE + NEPTUNE_TooMuchDetails: ( %{0} erreurs / warnings supplémentaires ) + NEPTUNE_Test1_Sheet1_Step0_fatal: "Erreur fatale : Impossible d'ouvrir le fichier %{0}" + NEPTUNE_Test1_Sheet1_Step0_error: "Impossible d'importer cette entrée %{0} du zip" + NEPTUNE_Test1_Sheet1_Step0_warning: "Cette entrée %{0} du zip n'est pas un fichier xml et a été ignoré" + NEPTUNE_Test1_Sheet1_Step1_error: "le fichier %{0} n'est pas correctement formé selon les recommandations du W3C" + NEPTUNE_Test1_Sheet1_Step2_error: "le fichier %{0} ne respecte pas le modèle CHOUETTE" + NEPTUNE_Test1_Sheet1_Step2_fatal: "Erreur fatale \: Aucune entrée valide trouvée dans le fichier" + CSV_IMPORT: Import CVS file + CSV_OK_LINE: line %{0} imported + CSV_OK_TIMETABLE: timetables %{0} (%{1}) imported + CSV_OK_PTNETWORK: "network %{0} : %{1} imported" + CSV_OK_COMPANY: company %{0} imported + CSV_FILE_NOT_FOUND: "file %{0} : error %{1}" + CSV_FILE_IGNORED: file %{0} ignored (not XML) + CSV_VALIDATION_ERROR: "XML file don't agree with Neptune XSD : %{0}" + CSV_VALIDATION_CAUSE: %{0} + CSV_PARSE_OBJECT: Analyse %{0} + CSV_MANDATORY_TAG: "missing or empty mandatory tag : %{0}" + CSV_UNKNOWN_ENUM: "Unknown %{0} enumaration value : %{1}" + CSV_EMPTY_TAG: "empty tag : %{0}" + CSV_TIMETABLE_COUNT: "timetable count : %{0}" + CSV_LINE_COUNT: "line count : %{0}" + CSV_END_OF_FILE: Unexpected end of file + CSV_BAD_TIMETABLE_PERIODS: Bad timetable periods + CSV_INVALID_LINE: "invalid line : %{0}" + CSV_STOP_WITHOUT_COORDS: "Stop without coords : %{0}" + CSV_VJ_MISSING_TIMETABLE: "Unable to find timetable of vehicle journey : %{0}" + CSV_FILE_FORMAT: Invalid or deprecated CSV format + CSV_BAD_ID: "Invalid built Neptune Object ID : %{1} for %{0} " + CSV_UNUSED_TIMETABLE: Unused timetable %{0} (%{1}) + SAVE: Save + SAVE_OK: %{0} saved severities: info: Information + uncheck: Unchecked + ok: Ok warning: Warning error: Error + fatal: Fatal activerecord: models: import: @@ -57,11 +97,51 @@ fr: messages: started: Import démarré completed: Import achevé avec succès - failed: Import interromptu + failed: Import interrompu + undefined: %{key} non défini + NEPTUNE_ONE: Conformité du fichier + NEPTUNE_Test1_Sheet1: 'Fiche n° 1.1 : Conformité à la syntaxe XML suivant les recommandations du W3C' + NEPTUNE_Test1_Sheet1_Step1: Conformité à la syntaxe XML + NEPTUNE_Test1_Sheet1_Step2: Conformité au schéma XML du profil CHOUETTE + NEPTUNE_TooMuchDetails: ( %{0} erreurs / warnings supplémentaires ) + NEPTUNE_Test1_Sheet1_Step0_fatal: "Erreur fatale : Impossible d'ouvrir le fichier %{0}" + NEPTUNE_Test1_Sheet1_Step0_error: "Impossible d'importer cette entrée %{0} du zip" + NEPTUNE_Test1_Sheet1_Step0_warning: "Cette entrée %{0} du zip n'est pas un fichier xml et a été ignoré" + NEPTUNE_Test1_Sheet1_Step1_error: "le fichier %{0} n'est pas correctement formé selon les recommandations du W3C" + NEPTUNE_Test1_Sheet1_Step2_error: "le fichier %{0} ne respecte pas le modèle CHOUETTE" + NEPTUNE_Test1_Sheet1_Step2_fatal: "Erreur fatale : Aucune entrée valide trouvée dans le fichier" + CSV_IMPORT: Import de fichier au format CSV + CSV_OK_LINE: Ligne %{0} importée + CSV_OK_TIMETABLE: Tableau de marche %{0} (%{1}) importé + CSV_OK_PTNETWORK: "Réseau %{0} : %{1} importé" + CSV_OK_COMPANY: "Transporteur %{0} importé" + CSV_FILE_ERROR: "Fichier %{0} : erreur %{1}" + CSV_FILE_IGNORED: "Fichier %{0} ignoré (non CSV) " + CSV_VALIDATION_ERROR: "Fichier CSV ne respecte pas le format Chouette : %{0}" + CSV_VALIDATION_CAUSE: %{0} + CSV_PARSE_OBJECT: Analyse %{0} + CSV_MANDATORY_TAG: "Tag obligatoire absent ou vide : %{0}" + CSV_UNKNOWN_ENUM: "Valeur de l'enum %{0} inconnue : %{1}" + CSV_EMPTY_TAG: "Tag vide : %{0}" + CSV_TIMETABLE_COUNT: "Nombre de tableaux de marche : %{0}" + CSV_LINE_COUNT: "Nombre de lignes : %{0}" + CSV_END_OF_FILE: Fichier tronqué + CSV_BAD_TIMETABLE_PERIODS: Mauvaises périodes dans le tableau de marche + CSV_INVALID_LINE: "ligne invalide : %{0}" + CSV_STOP_WITHOUT_COORDS: "Arret sans coordonnées : %{0}" + CSV_VJ_MISSING_TIMETABLE: "Impossible de trouver le tableau de marche de la course : %{0}" + CSV_FILE_FORMAT: Format CSV invalide ou obsolète + CSV_BAD_ID: "Identifiant Neptune produit invalide : %{1} pour %{0} " + CSV_UNUSED_TIMETABLE: "Tableau de marche %{0} (%{1}) inutilisé" + SAVE: Sauvegarde + SAVE_OK: %{0} enregistré severities: info: Information + uncheck: Non testé + ok: Ok warning: Alerte error: Erreur + fatal: Fatal activerecord: models: import: diff --git a/db/migrate/20120611090254_resize_argument_to_import_log_messages.rb b/db/migrate/20120611090254_resize_argument_to_import_log_messages.rb new file mode 100644 index 000000000..c5636329a --- /dev/null +++ b/db/migrate/20120611090254_resize_argument_to_import_log_messages.rb @@ -0,0 +1,5 @@ +class ResizeArgumentToImportLogMessages < ActiveRecord::Migration + def change + change_column :import_log_messages, :arguments, :string, :limit => 1000 + end +end diff --git a/db/migrate/20120611090325_resize_argument_to_export_log_messages.rb b/db/migrate/20120611090325_resize_argument_to_export_log_messages.rb new file mode 100644 index 000000000..7b51be073 --- /dev/null +++ b/db/migrate/20120611090325_resize_argument_to_export_log_messages.rb @@ -0,0 +1,5 @@ +class ResizeArgumentToExportLogMessages < ActiveRecord::Migration + def change + change_column :export_log_messages, :arguments, :string, :limit => 1000 + end +end diff --git a/db/migrate/20120612071936_add_file_type_to_import.rb b/db/migrate/20120612071936_add_file_type_to_import.rb new file mode 100644 index 000000000..fccd91cce --- /dev/null +++ b/db/migrate/20120612071936_add_file_type_to_import.rb @@ -0,0 +1,8 @@ +class AddFileTypeToImport < ActiveRecord::Migration + def change + change_table :imports do |t| + t.string :file_type + end + Import.update_all :file_type => "zip" + end +end diff --git a/db/schema.rb b/db/schema.rb index bad1719eb..7d1d92845 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120607064625) do +ActiveRecord::Schema.define(:version => 20120612071936) do create_table "access_links", :force => true do |t| t.integer "access_point_id", :limit => 8 @@ -123,7 +123,7 @@ ActiveRecord::Schema.define(:version => 20120607064625) do create_table "export_log_messages", :force => true do |t| t.integer "export_id" t.string "key" - t.string "arguments" + t.string "arguments", :limit => 1000 t.integer "position" t.string "severity" t.datetime "created_at" @@ -193,7 +193,7 @@ ActiveRecord::Schema.define(:version => 20120607064625) do create_table "import_log_messages", :force => true do |t| t.integer "import_id" t.string "key" - t.string "arguments" + t.string "arguments", :limit => 1000 t.integer "position" t.string "severity" t.datetime "created_at" @@ -209,6 +209,7 @@ ActiveRecord::Schema.define(:version => 20120607064625) do t.datetime "updated_at" t.string "type" t.string "options" + t.string "file_type" end add_index "imports", ["referential_id"], :name => "index_imports_on_referential_id" |
