aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/chouette/stop_area.rb2
-rw-r--r--app/models/organisation.rb4
-rw-r--r--app/models/user.rb1
-rw-r--r--app/models/workbench.rb7
4 files changed, 13 insertions, 1 deletions
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index bb8747faa..830fe8b78 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -384,8 +384,8 @@ module Chouette
def country_name
return unless country_code
-
country = ISO3166::Country[country_code]
+ return unless country
country.translations[I18n.locale.to_s] || country.name
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index da7d1fcf3..e8fb4e060 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -80,4 +80,8 @@ class Organisation < ActiveRecord::Base
features && features.include?(feature.to_s)
end
+ def default_workbench
+ workbenches.default
+ end
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 1342f60ed..31e634415 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -15,6 +15,7 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
# attr_accessible :email, :password, :current_password, :password_confirmation, :remember_me, :name, :organisation_attributes
belongs_to :organisation
+ has_many :workbenches, through: :organisation
accepts_nested_attributes_for :organisation
validates :organisation, :presence => true
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index b80fa64ac..eb53af7aa 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -1,4 +1,6 @@
class Workbench < ActiveRecord::Base
+ DEFAULT_WORKBENCH_NAME = "Gestion de l'offre"
+
include ObjectidFormatterSupport
belongs_to :organisation
belongs_to :line_referential
@@ -40,6 +42,11 @@ class Workbench < ActiveRecord::Base
end
end
+ def self.default
+ self.last if self.count == 1
+ where(name: DEFAULT_WORKBENCH_NAME).last
+ end
+
private
def initialize_output