diff options
| author | Michel Etienne | 2014-10-01 17:07:33 +0200 |
|---|---|---|
| committer | Michel Etienne | 2014-10-01 17:07:33 +0200 |
| commit | ad37841236153979c9d2ad82c613c2b69c4ffbb6 (patch) | |
| tree | 787f87e990cd1a68627f6360266ec18ea2ef5ea2 | |
| parent | 94e2f80aa99843c21e290ce75a7f8912f3368f3f (diff) | |
| download | chouette-core-ad37841236153979c9d2ad82c613c2b69c4ffbb6.tar.bz2 | |
time table combination , Mantis 29109
| -rw-r--r-- | app/controllers/time_table_combinations_controller.rb | 8 | ||||
| -rw-r--r-- | app/models/time_table_combination.rb | 17 |
2 files changed, 8 insertions, 17 deletions
diff --git a/app/controllers/time_table_combinations_controller.rb b/app/controllers/time_table_combinations_controller.rb index 32a3dcab9..ebae9f225 100644 --- a/app/controllers/time_table_combinations_controller.rb +++ b/app/controllers/time_table_combinations_controller.rb @@ -19,16 +19,18 @@ class TimeTableCombinationsController < ChouetteController def create + Rails.logger.warn( params.inspect) @time_table_combination = TimeTableCombination.new( params[:time_table_combination].merge( :source_id => parent.id)) + Rails.logger.warn( @time_table_combination.inspect) @year = params[:year] ? params[:year].to_i : Date.today.cwyear if @time_table_combination.valid? begin @time_table = @time_table_combination.combine flash[:notice] = t('time_table_combinations.success') render "create_success" - rescue => e - Rails.logger.error( "TimeTableCombination error, @time_table_combination=#{@time_table_combination.inspect}") - Rails.logger.error( e.inspect) + rescue => e + Rails.logger.error( "TimeTableCombination error, @time_table_combination=#{@time_table_combination.inspect}") + Rails.logger.error( e.inspect) flash[:error] = t('time_table_combinations.failure') render "create_failure" end diff --git a/app/models/time_table_combination.rb b/app/models/time_table_combination.rb index 85ab20bb7..1fa497d73 100644 --- a/app/models/time_table_combination.rb +++ b/app/models/time_table_combination.rb @@ -3,29 +3,18 @@ class TimeTableCombination include ActiveModel::Conversion extend ActiveModel::Naming - attr_accessor :source_id, :combined_id, :combined_name, :operation + attr_accessor :source_id, :combined_id, :operation - validates_presence_of :source_id, :combined_id, :operation, :combined_name + validates_presence_of :source_id, :combined_id, :operation validates_inclusion_of :operation, :in => %w( union intersection disjunction) def clean self.source_id = nil self.combined_id = nil - self.combined_name = nil self.operation = nil self.errors.clear end - - def valid?(context = nil) - self.combined_name = nil if self.combined_id.blank? - super context - end - - def invalid?(context = nil) - self.combined_name = nil if self.combined_id.blank? - super context - end - + def self.operations %w( union intersection disjunction) end |
