diff options
| -rw-r--r-- | app/controllers/api/v1/internals/application_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/api/v1/internals/compliance_check_sets_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/api/v1/internals/netex_imports_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/compliance_check_set.rb | 2 | ||||
| -rw-r--r-- | config/locales/compliance_check_sets.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/compliance_check_sets.fr.yml | 2 | ||||
| -rw-r--r-- | config/routes.rb | 2 | ||||
| -rw-r--r-- | config/secrets.yml | 3 | 
8 files changed, 14 insertions, 8 deletions
| diff --git a/app/controllers/api/v1/internals/application_controller.rb b/app/controllers/api/v1/internals/application_controller.rb index 2a9f2558a..77b74f5f6 100644 --- a/app/controllers/api/v1/internals/application_controller.rb +++ b/app/controllers/api/v1/internals/application_controller.rb @@ -2,16 +2,13 @@ module Api    module V1      module Internals        class ApplicationController < ActionController::Base -        inherit_resources          respond_to :json          layout false          before_action :authenticate          private          def authenticate -          authenticate_with_http_token do |token, options| -            @current_organisation = Api::V1::ApiKey.find_by_token(token).try(:organisation) -          end +          authenticate_with_http_token { |token| Rails.application.secrets.api_token == token }          end        end      end diff --git a/app/controllers/api/v1/internals/compliance_check_sets_controller.rb b/app/controllers/api/v1/internals/compliance_check_sets_controller.rb index 5e9137cb5..db92c3fad 100644 --- a/app/controllers/api/v1/internals/compliance_check_sets_controller.rb +++ b/app/controllers/api/v1/internals/compliance_check_sets_controller.rb @@ -1,7 +1,7 @@  module Api    module V1      module Internals -      class ComplianceCheckSetsController < Api::V1::Internals::ApplicationController +      class ComplianceCheckSetsController < ApplicationController          include ControlFlow          def validated @@ -19,7 +19,7 @@ module Api          def notify_parent            find_compliance_check_set -          if  @compliance_check_set.notify_parent +          if  @compliance_check_set.notify_parent && @compliance_check_set.parent              render json: {                status: "ok",                message:"#{@compliance_check_set.parent_type} (id: #{@compliance_check_set.parent_id}) successfully notified at #{l(@compliance_check_set.notified_parent_at)}" diff --git a/app/controllers/api/v1/internals/netex_imports_controller.rb b/app/controllers/api/v1/internals/netex_imports_controller.rb index c8e33f7b8..89bc1b81d 100644 --- a/app/controllers/api/v1/internals/netex_imports_controller.rb +++ b/app/controllers/api/v1/internals/netex_imports_controller.rb @@ -1,7 +1,7 @@  module Api    module V1      module Internals -      class NetexImportsController < Api::V1::Internals::ApplicationController +      class NetexImportsController < ApplicationController          include ControlFlow          def create diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index f440f9b6e..4e14b054f 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -23,6 +23,8 @@ class ComplianceCheckSet < ActiveRecord::Base      if parent        parent.child_change        update(notified_parent_at: DateTime.now) +    else +      errors.add(:base, I18n.t('compliance_check_sets.errors.no_parent'))      end    end diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index 87d9abef0..8023da0f7 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -22,6 +22,8 @@ en:        table_state: "%{lines_status} lines imported on %{lines_in_compliance_check_set} in the archive"        table_explanation: "These controls apply to all imported data and condition the construction of your organization's offer."        metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +    errors: +      no_parent: "The compliance check set doesn't any parent"    activerecord:      attributes:        compliance_check_set: diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index 84db8b934..0382f2937 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -18,6 +18,8 @@ fr:        table_state: "%{lines_status} lignes importées sur %{lines_in_compliance_check_set} présentes dans l'archive"        table_explanation: Ces contrôles s’appliquent pour toutes les données importées et conditionnent la construction de l’offre de votre organisation        metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +    errors: +      no_parent: "Le jeux de contrôle n'a pas de parent"    activerecord:      attributes:        compliance_check_set: diff --git a/config/routes.rb b/config/routes.rb index 92ff134b6..d6ff21bee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,7 +65,7 @@ ChouetteIhm::Application.routes.draw do        resources :time_tables, only: [:index, :show]        resources :vehicle_journeys, only: :show        namespace :internals do -        get 'compliance_check_sets/:id/notify_parent', to: 'compliance_check_sets#notify_parent', as: 'compliance_check_set' +        get 'compliance_check_sets/:id/notify_parent', to: 'compliance_check_sets#notify_parent', as: 'compliance_check_sets'          get 'netex_imports/:id/notify_parent', to: 'netex_imports#notify_parent', as: 'netex_imports'        end      end diff --git a/config/secrets.yml b/config/secrets.yml index 2f9d5abe6..0de3fd6ef 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -13,6 +13,7 @@  development:    secret_key_base: e901adb90fc1fff22f7237d138ef232a5425b67e81ccb3ce7003aab2c002d35a7c3d593c0fca3dcb21e8c911a8260c984a830d1d61776ad3005eb373abebc695    api_endpoint: "http://localhost:8080/chouette_iev/" +  api_token: VFHir2GWWjuRNZnHHnQD5Hn+ubRMQ1kNLnu7oCLf+4KR8+PmYqb1EzKZmmuRfVP/yxS0aQ3NklfNbbgUatTtly5540oo4L6ePdbYkwDzrBXF9xgYekOlTCwIGSl430mluv3wcXNEbrRLu2CevIBULtiRZriAEYVOpp9G+lQI+t8=    google_analytic_tracker: "UA-AAAAAAAA"    # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa"    newrelic_licence_key: "" @@ -21,6 +22,7 @@ development:  test:    secret_key_base: 54f61aab23322611dd0bbf73b7f034db34281f7f4b3c4992eaaff20ecc9673bbd467beaa6fcb48379ca69b80bc5662deac4e33ca144f2482146123d3e966016a    api_endpoint: "http://localhost:8080/chouette_iev/" +  api_token: VFHir2GWWjuRNZnHHnQD5Hn+ubRMQ1kNLnu7oCLf+4KR8+PmYqb1EzKZmmuRfVP/yxS0aQ3NklfNbbgUatTtly5540oo4L6ePdbYkwDzrBXF9xgYekOlTCwIGSl430mluv3wcXNEbrRLu2CevIBULtiRZriAEYVOpp9G+lQI+t8=    google_analytic_tracker: "UA-AAAAAAAA"    # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa"    osrm_endpoint: "http://router.project-osrm.org" @@ -30,6 +32,7 @@ test:  production:    secret_key_base: 54f61aab23322611dd0bbf73b7f034db34281f7f4b3c4992eaaff20ecc9673bbd467beaa6fcb48379ca69b80bc5662deac4e33ca144f2482146123d3e966016a    api_endpoint: "http://localhost:8080/chouette_iev/" +  api_token: VFHir2GWWjuRNZnHHnQD5Hn+ubRMQ1kNLnu7oCLf+4KR8+PmYqb1EzKZmmuRfVP/yxS0aQ3NklfNbbgUatTtly5540oo4L6ePdbYkwDzrBXF9xgYekOlTCwIGSl430mluv3wcXNEbrRLu2CevIBULtiRZriAEYVOpp9G+lQI+t8=    google_analytic_tracker: "UA-AAAAAAAA"    # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa"    newrelic_licence_key: "" | 
