aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorMarc Florisson2012-08-24 11:46:09 +0200
committerMarc Florisson2012-08-24 11:46:09 +0200
commit6fd69ca92e3090a2a8b7b73e7511bc1070290e22 (patch)
tree8f25b31f44fe9b239b25d232f8aee8844c7d0688 /app/models
parent1fd4e99d38e25ba4e70324a2f06aa532ee0e7862 (diff)
downloadchouette-core-6fd69ca92e3090a2a8b7b73e7511bc1070290e22.tar.bz2
create organisation
Diffstat (limited to 'app/models')
-rw-r--r--app/models/organisation.rb5
-rw-r--r--app/models/referential.rb2
-rw-r--r--app/models/user.rb6
3 files changed, 13 insertions, 0 deletions
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
new file mode 100644
index 000000000..28d592fc9
--- /dev/null
+++ b/app/models/organisation.rb
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+class Organisation < ActiveRecord::Base
+ has_many :users, :dependent => :destroy
+ has_many :referentials, :dependent => :destroy
+end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 953038168..b87ba81e8 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -20,6 +20,8 @@ class Referential < ActiveRecord::Base
has_many :imports, :dependent => :destroy
has_many :exports, :dependent => :destroy
+
+ belongs_to :organisation
def slug_excluded_values
if ! slug.nil?
diff --git a/app/models/user.rb b/app/models/user.rb
index b2f7c8ec9..53853530f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -6,4 +6,10 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
+
+ belongs_to :organisation
+
+ before_validation(:on => :create) do
+ self.password ||= Devise.friendly_token.first(6)
+ end
end