diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 9 | ||||
| -rw-r--r-- | app/models/chouette/time_table.rb | 6 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.slim | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 228b31c05..dcf8f3e5e 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -95,6 +95,15 @@ class TimeTablesController < ChouetteController render :new end + def actualize + @time_table = resource + if @time_table.calendar + @time_table.actualize + flash[:notice] = t('.success') + end + redirect_to referential_time_table_path @referential, @time_table + end + def tags @tags = ActsAsTaggableOn::Tag.where("tags.name LIKE ?", "%#{params[:tag]}%") respond_to do |format| diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 6fba5bab6..eacc5c827 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -134,6 +134,12 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord [Chouette::TimeTable.maximum(:end_date)].compact.max end + def actualize + self.dates.clear + self.periods.clear + self.merge! self.calendar.convert_to_time_table + end + def month_inspect(date) (date.beginning_of_month..date.end_of_month).map do |d| { diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 9c40a13a2..46c32f4b0 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -11,9 +11,11 @@ .col-lg-12.text-right / - if policy(@time_table).create? && @referential.organisation == current_organisation / = link_to t('time_tables.actions.new'), new_referential_time_table_path(@referential), class: 'btn btn-primary' + - if @time_table.calendar + = link_to t('actions.actualize'), actualize_referential_time_table_path(@referential, @time_table), method: :post, class: 'btn btn-primary' /- if policy(@time_table).create? && @referential.organisation == current_organisation - = link_to t('actions.combine'), new_referential_time_table_time_table_combination_path(@referential, @time_table), {remote: true, 'data-toggle' => "modal", 'data-target' => '#modal_combine', class: 'btn btn-primary' } + = link_to t('actions.combine'), new_referential_time_table_time_table_combination_path(@referential, @time_table), class: 'btn btn-primary' - if policy(@time_table).create? && @referential.organisation == current_organisation = link_to t('actions.clone'), duplicate_referential_time_table_path(@referential, @time_table), class: 'btn btn-primary' |
