aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers
diff options
context:
space:
mode:
authorAlban Peignier2016-11-20 22:38:47 +0100
committerAlban Peignier2016-11-20 22:38:47 +0100
commit85fd6480daebe50e423ba27bce772c7b7f86fbf6 (patch)
tree04285d132e00fa82cb4786f946a605ac9f549795 /config/initializers
parent7b05ae21fc9421b81fc071976f3bb98ed7c87f43 (diff)
parent65c8a96a00f8d3afbd02cfb019b34f39ad44bc3e (diff)
downloadchouette-core-85fd6480daebe50e423ba27bce772c7b7f86fbf6.tar.bz2
Merge branch 'master' into staging
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/apartment.rb8
-rw-r--r--config/initializers/assets.rb2
-rw-r--r--config/initializers/delayed_job_config.rb6
-rw-r--r--config/initializers/devise_async.rb2
-rw-r--r--config/initializers/postgresql_adapter_patch.rb42
-rw-r--r--config/initializers/simple_form.rb18
-rw-r--r--config/initializers/simple_form_bootstrap.rb67
7 files changed, 86 insertions, 59 deletions
diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb
index db352fa6f..b439821d2 100644
--- a/config/initializers/apartment.rb
+++ b/config/initializers/apartment.rb
@@ -19,9 +19,9 @@ Apartment.configure do |config|
#
config.excluded_models = [
"Referential",
+ "ReferentialMetadata",
"Organisation",
"User",
- "Delayed::Backend::ActiveRecord::Job",
"Api::V1::ApiKey",
"RuleParameterSet",
"StopAreaReferential",
@@ -34,7 +34,11 @@ Apartment.configure do |config|
"Chouette::Line",
"Chouette::GroupOfLine",
"Chouette::Company",
- "Chouette::Network"
+ "Chouette::Network",
+ "ReferentialCloning",
+ "Workbench",
+ "CleanUp",
+ "CleanUpResult"
]
# use postgres schemas?
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index d2f4ec33a..928236c4a 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -5,4 +5,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-# Rails.application.config.assets.precompile += %w( search.js )
+Rails.application.config.assets.precompile += %w( es6_browserified/*.js )
diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb
deleted file mode 100644
index 147b2550e..000000000
--- a/config/initializers/delayed_job_config.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# config/initializers/delayed_job_config.rb
-#Delayed::Job.destroy_failed_jobs = false
-silence_warnings do
- Delayed::Job.const_set("MAX_ATTEMPTS", 1)
- Delayed::Job.const_set("MAX_RUN_TIME", 12.hours)
-end \ No newline at end of file
diff --git a/config/initializers/devise_async.rb b/config/initializers/devise_async.rb
index 3ee0a7858..10f4d98b6 100644
--- a/config/initializers/devise_async.rb
+++ b/config/initializers/devise_async.rb
@@ -1,2 +1,2 @@
-Devise::Async.backend = :delayed_job
+Devise::Async.backend = :sidekiq
Devise::Async.enabled = false # Set to true to use Delayed Job for asynchronous mail
diff --git a/config/initializers/postgresql_adapter_patch.rb b/config/initializers/postgresql_adapter_patch.rb
index ae228f62f..2e4d73f85 100644
--- a/config/initializers/postgresql_adapter_patch.rb
+++ b/config/initializers/postgresql_adapter_patch.rb
@@ -10,3 +10,45 @@
# end
# end
# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:primary_key] = "bigserial primary key"
+
+# Add missing double-quote to write array of daterange in SQL query
+# See #1782
+
+class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
+
+ def self.array_to_string(value, column, adapter)
+ casted_values = value.map do |val|
+ if String === val
+ if val == "NULL"
+ "\"#{val}\""
+ else
+ quote_and_escape(adapter.type_cast(val, column, true))
+ end
+ elsif Range === val
+ casted_value = adapter.type_cast(val, column, true)
+ "\"#{casted_value}\""
+ else
+ adapter.type_cast(val, column, true)
+ end
+ end
+ "{#{casted_values.join(',')}}"
+ end
+
+end
+
+module ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID
+ class DateRange < Range
+ # Unnormalize daterange
+ # [2016-11-19,2016-12-26) -> 2016-11-19..2016-12-25
+ def type_cast(value)
+ result = super value
+
+ if result.respond_to?(:exclude_end?) && result.exclude_end?
+ ::Range.new(result.begin, result.end - 1, false)
+ else
+ result
+ end
+ end
+ end
+ register_type 'daterange', DateRange.new(:date)
+end
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index d5492e529..472863fa8 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -5,8 +5,9 @@ SimpleForm.setup do |config|
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
- config.wrappers :default, class: :input,
- hint_class: :field_with_hint, error_class: :field_with_errors do |b|
+ config.wrappers :default, class: 'form-group',
+ error_class: 'has-error' do |b|
+ # hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
@@ -41,8 +42,8 @@ SimpleForm.setup do |config|
## Inputs
b.use :label_input
- b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
## full_messages_for
# If you want to display the full error message for the attribute, you can
@@ -72,7 +73,7 @@ SimpleForm.setup do |config|
config.error_notification_tag = :div
# CSS class to add for error notification helper.
- config.error_notification_class = 'error_notification'
+ config.error_notification_class = 'alert alert-error'
# ID to add for error notification helper.
# config.error_notification_id = nil
@@ -90,25 +91,24 @@ SimpleForm.setup do |config|
# config.collection_wrapper_class = nil
# You can wrap each item in a collection of radio/check boxes with a tag,
- # defaulting to :span. Please note that when using :boolean_style = :nested,
- # SimpleForm will force this option to be a label.
+ # defaulting to :span.
# config.item_wrapper_tag = :span
# You can define a class to use in all item wrappers. Defaulting to none.
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
- # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
# You can define the default class to be used on forms. Can be overriden
# with `html: { :class }`. Defaulting to none.
- # config.default_form_class = nil
+ config.default_form_class = 'form'
# You can define which elements should obtain additional classes
- # config.generate_additional_classes_for = [:wrapper, :label, :input]
+ config.generate_additional_classes_for = [:label, :input]
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb
index 4f4dc23b3..be0f4bf55 100644
--- a/config/initializers/simple_form_bootstrap.rb
+++ b/config/initializers/simple_form_bootstrap.rb
@@ -14,8 +14,8 @@ SimpleForm.setup do |config|
b.use :label, class: 'control-label'
b.use :input, class: 'form-control'
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -26,8 +26,8 @@ SimpleForm.setup do |config|
b.use :label, class: 'control-label'
b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -38,8 +38,8 @@ SimpleForm.setup do |config|
ba.use :label_input
end
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -47,8 +47,8 @@ SimpleForm.setup do |config|
b.optional :readonly
b.use :label, class: 'control-label'
b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -62,8 +62,8 @@ SimpleForm.setup do |config|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input, class: 'form-control'
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -76,8 +76,8 @@ SimpleForm.setup do |config|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -90,8 +90,8 @@ SimpleForm.setup do |config|
ba.use :label_input
end
- wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -103,8 +103,8 @@ SimpleForm.setup do |config|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -118,45 +118,32 @@ SimpleForm.setup do |config|
b.use :label, class: 'sr-only'
b.use :input, class: 'form-control'
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
- config.wrappers :form_without_label, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
-
+ config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
- b.use :placeholder
- b.optional :maxlength
- b.optional :pattern
- b.optional :min_max
b.optional :readonly
-
- b.wrapper tag: 'div', class: 'col-sm-12' do |ba|
+ b.use :label, class: 'control-label'
+ b.wrapper tag: 'div', class: 'form-inline' do |ba|
ba.use :input, class: 'form-control'
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
- end
-
- config.wrappers :nested, :tag => 'span', :error_class => 'has-error' do |b|
- b.use :html5
- b.use :placeholder
- b.optional :readonly
- b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
-
# Wrappers for forms and inputs using the Bootstrap toolkit.
# Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
- config.default_wrapper = :horizontal_form
+ config.default_wrapper = :vertical_form
config.wrapper_mappings = {
check_boxes: :vertical_radio_and_checkboxes,
radio_buttons: :vertical_radio_and_checkboxes,
file: :vertical_file_input,
boolean: :vertical_boolean,
+ datetime: :multi_select,
+ date: :multi_select,
+ time: :multi_select
}
end
-