diff options
| author | Xinhui | 2017-05-22 15:22:52 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-05-22 15:22:59 +0200 | 
| commit | 897bc5fb10b1867970367ede388feac0ac1a5791 (patch) | |
| tree | 0f62692076d035a470033bc43082b96228162df3 | |
| parent | 7b498a92d79a0305b98418774b65cf9fcb1ce237 (diff) | |
| download | chouette-core-897bc5fb10b1867970367ede388feac0ac1a5791.tar.bz2 | |
TimeTables#actualize retrieve dates & periods from calendar
Refs #3445
| -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 | ||||
| -rw-r--r-- | config/locales/actions.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/actions.fr.yml | 1 | ||||
| -rw-r--r-- | config/locales/time_tables.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/time_tables.fr.yml | 2 | ||||
| -rw-r--r-- | config/routes.rb | 1 | 
8 files changed, 25 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' diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml index 5bfd9d9fb..6e2dd3aa2 100644 --- a/config/locales/actions.en.yml +++ b/config/locales/actions.en.yml @@ -13,6 +13,7 @@ en:      clean_up: 'Clean up'      sync: 'Synchronize'      combine: 'Combine' +    actualize: 'Actualize'    or: "or"    cancel: "Cancel"    search_hint: "Type in a search term" diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml index 94afc1393..8f2fc90f8 100644 --- a/config/locales/actions.fr.yml +++ b/config/locales/actions.fr.yml @@ -14,6 +14,7 @@ fr:      clean_up: 'Purger'      sync: 'Synchroniser'      combine: 'Combiner' +    actualize: 'Actualiser'    or: "ou"    cancel: "Annuler"    search_hint: "Entrez un texte à rechercher" diff --git a/config/locales/time_tables.en.yml b/config/locales/time_tables.en.yml index 495770987..6c5aac012 100644 --- a/config/locales/time_tables.en.yml +++ b/config/locales/time_tables.en.yml @@ -20,6 +20,8 @@ en:        add_period: "Add a period"        add_date: "Add a peculiar date"        add_excluded_date: "Add an excluded date" +    actualize: +      success: "Actualize succeded"      new:        title: "Add a new timetable"      edit: diff --git a/config/locales/time_tables.fr.yml b/config/locales/time_tables.fr.yml index fbd1386c8..36a588eb4 100644 --- a/config/locales/time_tables.fr.yml +++ b/config/locales/time_tables.fr.yml @@ -20,6 +20,8 @@ fr:        add_period: "Ajouter une période"        add_date: "Ajouter une date particulière"        add_excluded_date: "Ajouter une date exclue" +    actualize: +      success: "Actualisation terminée"      new:        title: "Ajouter un calendrier"      duplicate: diff --git a/config/routes.rb b/config/routes.rb index 4342052f7..f75578106 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,6 +168,7 @@ ChouetteIhm::Application.routes.draw do          get :tags        end        member do +        post 'actualize'          get 'duplicate'          get 'month', defaults: { format: :json }        end | 
