diff options
| author | Michel Etienne | 2012-09-05 15:44:40 +0200 |
|---|---|---|
| committer | Michel Etienne | 2012-09-05 15:44:40 +0200 |
| commit | e524f087ae7fe7543bffbdf281ed9e07c00b9418 (patch) | |
| tree | cf452640b261c1c6beb9a3dd7bb743bdd4eb7aa3 /app | |
| parent | f19f90ee215a6019a6647b0b23d03a06a3458aa6 (diff) | |
| download | chouette-core-e524f087ae7fe7543bffbdf281ed9e07c00b9418.tar.bz2 | |
affect file_validation to organisation
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/file_validations_controller.rb | 14 | ||||
| -rw-r--r-- | app/models/file_validation.rb | 3 | ||||
| -rw-r--r-- | app/models/organisation.rb | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/app/controllers/file_validations_controller.rb b/app/controllers/file_validations_controller.rb index f56cf8ceb..cc50a7499 100644 --- a/app/controllers/file_validations_controller.rb +++ b/app/controllers/file_validations_controller.rb @@ -18,9 +18,15 @@ class FileValidationsController < InheritedResources::Base end protected - - def collection - @file_validations ||= end_of_association_chain.paginate(:page => params[:page]) + def resource + @file_validation ||= current_organisation.file_validations.find_by_id(params[:id]) end - + def collection + @file_validations ||= current_organisation.file_validations.paginate(:page => params[:page]) + end + def create_resource(file_validation) + file_validation.organisation = current_organisation + super + end + end diff --git a/app/models/file_validation.rb b/app/models/file_validation.rb index 30569a092..a4c76ebf0 100644 --- a/app/models/file_validation.rb +++ b/app/models/file_validation.rb @@ -6,6 +6,9 @@ class FileValidation < ActiveRecord::Base attr_accessor :resources,:uncheck_count,:ok_count,:warning_count,:error_count,:fatal_count,:log_message_tree attr_accessor :validator + belongs_to :organisation + validates_presence_of :organisation + has_many :log_messages, :class_name => "FileValidationLogMessage", :order => :position, :dependent => :destroy serialize :options diff --git a/app/models/organisation.rb b/app/models/organisation.rb index a57d9f5a5..2cc6a9c3c 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -2,6 +2,7 @@ class Organisation < ActiveRecord::Base has_many :users, :dependent => :destroy has_many :referentials, :dependent => :destroy + has_many :file_validations, :dependent => :destroy validates_presence_of :name validates_uniqueness_of :name |
