diff options
| author | Luc Donnet | 2017-09-07 22:02:08 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-09-07 22:02:08 +0200 |
| commit | 34c854e93727202ea643f650bd37a451b5fc48ea (patch) | |
| tree | 38e7a6a2d8205798db0d616b1f325cac2cf212e8 /app | |
| parent | 155faedfb87943af3227c9c09cff6996e988db1b (diff) | |
| parent | 99aff9c3e63fb15b555806847bc14fbf56eeef2a (diff) | |
| download | chouette-core-34c854e93727202ea643f650bd37a451b5fc48ea.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/autocomplete_time_tables_controller.rb | 5 | ||||
| -rw-r--r-- | app/models/chouette/active_record.rb | 13 | ||||
| -rw-r--r-- | app/models/netex_import.rb | 1 | ||||
| -rw-r--r-- | app/models/referential.rb | 6 | ||||
| -rw-r--r-- | app/views/calendars/index.html.slim | 4 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_main_nav_left.html.slim | 18 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_form.html.slim | 2 |
8 files changed, 33 insertions, 21 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cc1c30703..8cb5726c4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -33,6 +33,11 @@ class ApplicationController < ActionController::Base end helper_method :current_organisation + def current_offer_workbench + current_organisation.workbenches.where(name: "Gestion de l'offre") + end + helper_method :current_offer_workbench + def current_functional_scope functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation JSON.parse(functional_scope) if functional_scope diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb index d0cd94e26..f65f5b9f6 100644 --- a/app/controllers/autocomplete_time_tables_controller.rb +++ b/app/controllers/autocomplete_time_tables_controller.rb @@ -22,7 +22,12 @@ class AutocompleteTimeTablesController < InheritedResources::Base scope.distinct end + def split_params! search + params[:q][search] = params[:q][search].split(" ") if params[:q][search] + end + def collection + split_params! :comment_or_objectid_cont_any @time_tables = select_time_tables.search(params[:q]).result.paginate(page: params[:page]) end end diff --git a/app/models/chouette/active_record.rb b/app/models/chouette/active_record.rb index 1862319af..e12f30266 100644 --- a/app/models/chouette/active_record.rb +++ b/app/models/chouette/active_record.rb @@ -2,10 +2,8 @@ require 'deep_cloneable' module Chouette class ActiveRecord < ::ActiveRecord::Base - self.abstract_class = true - - before_save :nil_if_blank + before_save :nil_if_blank, :set_data_source_ref # to be overridden to set nullable attrs when empty def self.nullable_attributes @@ -16,17 +14,22 @@ module Chouette self.class.nullable_attributes.each { |attr| self[attr] = nil if self[attr].blank? } end - def human_attribute_name(*args) self.class.human_attribute_name(*args) end + def set_data_source_ref + if self.respond_to?(:data_source_ref) + self.data_source_ref ||= 'DATASOURCEREF_EDITION_BOIV' + end + end + # TODO: Can we remove this? # class << self # alias_method :create_reflection_without_chouette_naming, :create_reflection # def create_reflection(macro, name, options, active_record) - # options = + # options = # Reflection.new(macro, name, options, active_record).options_with_default # create_reflection_without_chouette_naming(macro, name, options, active_record) diff --git a/app/models/netex_import.rb b/app/models/netex_import.rb index 90ac42f2c..32939a741 100644 --- a/app/models/netex_import.rb +++ b/app/models/netex_import.rb @@ -6,7 +6,6 @@ class NetexImport < Import def launch_java_import return if self.class.finished_statuses.include?(status) - logger.warn "Call iev get #{Rails.configuration.iev_url}/boiv_iev/referentials/importer/new?id=#{id}" Thread.new do begin diff --git a/app/models/referential.rb b/app/models/referential.rb index ecfc69c4a..65e203f9f 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,3 +1,4 @@ +# coding: utf-8 class Referential < ActiveRecord::Base include DataFormatEnumerations @@ -185,7 +186,6 @@ class Referential < ActiveRecord::Base before_validation :assign_slug, :on => :create before_validation :assign_prefix, :on => :create before_create :create_schema - after_create :clone_schema, if: :created_from before_destroy :destroy_schema @@ -289,7 +289,9 @@ class Referential < ActiveRecord::Base end def create_schema - Apartment::Tenant.create slug + unless created_from + Apartment::Tenant.create slug + end end def assign_slug diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim index 56232b0af..24ed15484 100644 --- a/app/views/calendars/index.html.slim +++ b/app/views/calendars/index.html.slim @@ -31,6 +31,10 @@ attribute: 'short_name' \ ), \ TableBuilderHelper::Column.new( \ + key: :organisation, \ + attribute: Proc.new { |c| c.organisation.name } \ + ), \ + TableBuilderHelper::Column.new( \ key: :shared, \ attribute: Proc.new { |c| t("#{c.try(:shared)}") } \ ) \ diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 74442692d..4560f5fa0 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -31,16 +31,10 @@ #miTwo.panel-collapse.collapse .list-group - = link_to '#', class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do + = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do span Jeux de données - - - if @workbench - = link_to workbench_imports_path(@workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do - span Import - - else - = link_to '#', class: 'list-group-item disabled' do + = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do span Import - = link_to calendars_path, class: 'list-group-item' do span Modèles de calendrier = link_to '#', class: 'list-group-item' do @@ -62,13 +56,13 @@ .list-group = link_to referential_networks_path(current_referential), class: 'list-group-item' do span = t('networks.index.title') - + = link_to referential_companies_path(current_referential), class: 'list-group-item' do span = t('companies.index.title') - + = link_to '#', class: 'list-group-item disabled' do span Tracés - + = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do span = t('time_tables.index.title') @@ -95,7 +89,7 @@ h4.panel-title = link_to '#miFive', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do |Outils - + #miFive.panel-collapse.collapse .list-group = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do diff --git a/app/views/time_table_combinations/_form.html.slim b/app/views/time_table_combinations/_form.html.slim index 8e2d77d46..426624ee3 100644 --- a/app/views/time_table_combinations/_form.html.slim +++ b/app/views/time_table_combinations/_form.html.slim @@ -7,7 +7,7 @@ abbr title='Champ requis' * = f.input :combined_type, as: :boolean, checked_value: 'time_table', unchecked_value: 'calendar', required: false, label: content_tag(:span, t("time_table_combinations.combined_type.#{@combination.combined_type}"), class: 'switch-label', data: { checkedValue: 'Calendriers', uncheckedValue: 'Modèles de calendriers' }), wrapper_html: { class: 'col-sm-8 col-xs-7' } - = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_cont_or_objectid_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json, :source_id => @combination.source_id)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''} + = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_or_objectid_cont_any', url: referential_autocomplete_time_tables_path(@referential, format: :json, :source_id => @combination.source_id)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''} = f.input :calendar_id, as: :select, input_html: { class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un modèle de calendrier...', term: 'name_cont', url: autocomplete_calendars_path}}, wrapper_html: {class: @combination.combined_type != 'calendar' ? 'hidden' : ''} |
