diff options
| -rw-r--r-- | app/models/referential.rb | 10 | ||||
| -rw-r--r-- | config/locales/referential_suites.en.yml | 3 | ||||
| -rw-r--r-- | config/locales/referential_suites.fr.yml | 3 | ||||
| -rw-r--r-- | config/locales/referentials.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/referentials.fr.yml | 1 | 
5 files changed, 17 insertions, 1 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index c7b52ddf8..04cdf986d 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,4 +1,3 @@ -# coding: utf-8  class Referential < ActiveRecord::Base    include DataFormatEnumerations @@ -28,6 +27,15 @@ class Referential < ActiveRecord::Base    belongs_to :organisation    validates_presence_of :organisation +  validate def validate_consistent_organisation +    return true if workbench_id.nil? +    ids = [workbench.organisation_id, organisation_id] +    return true if ids.first == ids.last +    errors.add(:inconsistent_organisation, +               I18n.t('referentials.errors.inconsistent_organisation', +                      indirect_name: workbench.organisation.name, +                      direct_name: organisation.name)) +  end    belongs_to :line_referential    validates_presence_of :line_referential diff --git a/config/locales/referential_suites.en.yml b/config/locales/referential_suites.en.yml index 1a77d9026..9cb1e33d3 100644 --- a/config/locales/referential_suites.en.yml +++ b/config/locales/referential_suites.en.yml @@ -1,2 +1,5 @@  en:    referential_suites: +    errors: +      inconsistent_current: "Le current referential (%{name}) n'appartient pas à cette referential suite" +      inconsistent_new: "Le new referential (%{name}) n'appartient pas à cette referential suite" diff --git a/config/locales/referential_suites.fr.yml b/config/locales/referential_suites.fr.yml index c87b32fc7..aa6fef0e2 100644 --- a/config/locales/referential_suites.fr.yml +++ b/config/locales/referential_suites.fr.yml @@ -1,2 +1,5 @@  fr:    referential_suites: +    errors: +      inconsistent_current: "The current referential (%{name}) does not belong to this referential suite" +      inconsistent_new: "The new referential (%{name}) does not belong to this referential suite" diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index 14b4dbe66..bf638f562 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -38,6 +38,7 @@ en:        edit: "Edit this data space"        clone: "Clone this data space"      errors: +      inconsistent_organisation: "Organisation of asscociated workstation is (%{indirect_name}), while directly associated organisation is (%{direct_name}), they need to be equal"        validity_period: "Invalid validity periode"        pg_excluded: "can't begins with pg_"        public_excluded: "public is a reserved value" diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index b90f6e5b6..a033b8ca5 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -38,6 +38,7 @@ fr:        edit: "Editer ce jeu de données"        clone: "Cloner ce jeu de données"      errors: +      inconsistent_organisation: "L'organisation asscociée par workstation est (%{indirect_name}), mais l'organisation associée directement est (%{direct_name}), elles doivent être identiques."        validity_period: "Période de validité invalide"        pg_excluded: "ne peut pas commencer par pg_ (valeurs réservées)"        public_excluded: "public est une valeur réservée" | 
