diff --git a/.gitignore b/.gitignore index 9da0843d..88c89a75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,21 @@ -# Rails -# ===== -.bundle -db/*.sqlite3 -log/*.log -tmp/**/* +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' -# Passenger -tmp/restart.txt +# Ignore bundler config. +/.bundle -# Vendor -vendor/cache -vendor/bundle +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal -# Volatile -doc/api -doc/app -public/stylesheets/all.css +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp/**/* # Local -config/database.yml config/application.yml config/deploy/production.rb config/deploy/staging.rb @@ -32,7 +29,15 @@ public/stylesheets/compiled db/sphinx config/*.sphinx.conf config/sphinx/ -config/initializers/mail.rb # Aspell db/aspell/aspell.de_CH.pws + +# Ignore mac ds_store files +.DS_Store + +# Sensitive data. +.env* + +# Ignore coverage report +/doc/coverage diff --git a/.rspec b/.rspec index 4e1e0d2f..83e16f80 100644 --- a/.rspec +++ b/.rspec @@ -1 +1,2 @@ --color +--require spec_helper diff --git a/.travis.yml b/.travis.yml index 8e368924..ade7062c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_script: - mysql -e 'create database katalog_test' - DB=mysql bundle exec rake katalog:setup - DB=mysql bundle exec rake db:create db:schema:load - - bundle exec rake katalog:ts:export_lists ts:rebuild katalog:raspell:update + - bundle exec rake katalog:ts:export_lists ts:rebuild katalog:aspell:update script: "bundle exec rake spec" diff --git a/Capfile b/Capfile index 04d8d05f..805f7404 100644 --- a/Capfile +++ b/Capfile @@ -1,7 +1,14 @@ -require 'bundler/setup' +# Load DSL and Setup Up Stages +require 'capistrano/setup' -load 'deploy' if respond_to?(:namespace) # cap2 differentiator -Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } -Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) } +# Includes default deployment tasks +require 'capistrano/deploy' -load 'config/deploy' # remove this line to skip loading any of the default tasks +# Includes tasks from other gems included in your Gemfile +require 'capistrano/rbenv' +require 'capistrano/bundler' +require 'capistrano/rails/assets' +require 'capistrano/rails/migrations' + +# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index fc948d20..c2a1181a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,128 +1,144 @@ # Settings # ======== -source 'http://rubygems.org' +source 'https://rubygems.org' # Rails # ===== gem 'rails' - -# Unicorn -# ======= -gem 'unicorn' - # Database +# ======== gem 'mysql2' -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails' - gem 'coffee-rails' - gem 'therubyracer' - gem 'uglifier' - gem 'compass-rails' -end +# Journaling +# ========== +gem 'paper_trail' + +# Asset Pipeline +# ============== +# Issue https://github.com/sstephenson/sprockets/issues/540 +gem 'sprockets', '~> 2.11.0' +gem 'sass-rails' +gem 'uglifier' +gem 'coffee-rails' +gem 'therubyracer', platforms: :ruby +gem 'quiet_assets' +gem 'compass-rails' + +# CRUD +# ==== +gem 'inherited_resources', '~> 1.5.0' # Dependency on has_scope release candidate +gem 'jbuilder' +gem 'has_scope' +gem 'show_for' +gem 'will_paginate' +gem 'nokogiri' +gem 'holidays' +# I18n +# ==== +gem 'i18n_rails_helpers', github: 'huerlisi/i18n_rails_helpers' + +# UI +# == +gem 'simple-navigation' gem 'jquery-rails' gem 'jquery-ui-rails' +gem 'formtastic' +gem 'cocoon' -# Test -# === -group :test do - # Matchers/Helpers - gem 'shoulda' -end +# WYSIWYG Editor +# ============== +gem 'ckeditor' -group :test, :development do - # Framework - gem 'rspec-rails' +# Model extensions +# ============= +gem 'acts-as-taggable-on' - # Fixtures - gem 'factory_girl_rails' - gem 'database_cleaner' +# Search +# ====== +gem 'thinking-sphinx' - # Debugger - gem 'pry-rails' - gem 'pry-byebug' -end +# Spellchecking +# ============= +gem 'ffi-aspell' -# Development +# PDF reports # =========== -group :development do - # RDoc - gem 'rdoc' +gem 'prawn_rails' +gem 'prawn' +gem 'prawn-table' - # Deployment - gem 'capistrano', '~> 2.15.5' - gem 'capistrano-rbenv', '~> 1.0' - gem 'capones_recipes' +# Generate excel files +# ==================== +gem 'spreadsheet' - gem 'quiet_assets' +# Page fetcher +# ============ +gem 'mechanize' - # Code quality - gem 'rubocop', require: false +# Docs +# ==== +group :doc do + # Docs + gem 'sdoc', require: false end -# Standard helpers -# ================ -gem 'haml-rails' - -gem 'formtastic' -gem 'will_paginate', git: 'https://github.com/huerlisi/will_paginate.git', branch: 'show_always' -gem 'inherited_resources' -gem 'has_scope' -gem 'i18n_rails_helpers', github: 'huerlisi/i18n_rails_helpers' -gem 'simple-navigation' -gem 'nokogiri' -# Katalog -# ======= -# Authentication +# Access Control +# ============== gem 'devise' +gem 'cancancan' -# Authorization -gem 'cancan' +# Deployment +# ========== +gem 'unicorn-rails' -# Tagging -gem 'acts-as-taggable-on' +# Exception Notifier +# ================== +gem 'airbrake' -# Search -gem 'thinking-sphinx' +# Profiling +# ========= +gem 'rack-google-analytics' -# Spellchecking -gem 'ffi-aspell' +# Application settings +# ==================== +gem 'settingslogic' -# Reports -gem 'prawn_rails' -gem 'prawn' -gem 'prawn-table' +group :development do + # Generators + gem 'haml-rails' -# CRUD helpers -gem 'show_for' + # Debugging + gem 'better_errors' + gem 'binding_of_caller' # Needed by binding_of_caller to enable html console -# WYSIWYG Editor -gem 'ckeditor' - -# Change log for model data -gem 'paper_trail' + # Deployment + gem 'capistrano', '~> 3.2.0' + gem 'capistrano-rails' + gem 'capistrano-bundler' + gem 'capistrano-rbenv' +end -gem 'revertible_paper_trail' +group :development, :test do + # (Pre-)loading + gem 'spring' + gem 'spring-commands-rspec' -# Generate excel files -gem 'spreadsheet' + # Testing Framework + gem 'rspec-rails' -# Load html content -gem 'mechanize' + # Matchers/Helpers + gem 'shoulda' -# Date handling -gem 'holidays' + # QA + gem 'simplecov', require: false + gem 'rubocop', require: false -# Monitoring -# ========== -gem 'settingslogic' -group :staging, :production do - # Traffic - gem 'rack-google-analytics' + # Debugger + gem 'pry-rails' + gem 'pry-byebug' - # Exceptions - gem 'airbrake' + # Fixtures + gem 'factory_girl_rails' + gem 'database_cleaner' end diff --git a/Gemfile.lock b/Gemfile.lock index 58b2f4be..6776e200 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,79 +5,70 @@ GIT i18n_rails_helpers (2.0.0.beta1) rails (> 3.0.0) -GIT - remote: https://github.com/huerlisi/will_paginate.git - revision: dca0b70fbaa44c4dffd2631a229ed304ef7f8d40 - branch: show_always - specs: - will_paginate (3.0.3) - GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - actionmailer (3.2.21) - actionpack (= 3.2.21) - mail (~> 2.5.4) - actionpack (3.2.21) - activemodel (= 3.2.21) - activesupport (= 3.2.21) - builder (~> 3.0.0) + actionmailer (4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.8) + actionview (= 4.1.8) + activesupport (= 4.1.8) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.8) + activesupport (= 4.1.8) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.21) - activesupport (= 3.2.21) - builder (~> 3.0.0) - activerecord (3.2.21) - activemodel (= 3.2.21) - activesupport (= 3.2.21) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.21) - activemodel (= 3.2.21) - activesupport (= 3.2.21) - activesupport (3.2.21) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) + activemodel (4.1.8) + activesupport (= 4.1.8) + builder (~> 3.1) + activerecord (4.1.8) + activemodel (= 4.1.8) + activesupport (= 4.1.8) + arel (~> 5.0.0) + activesupport (4.1.8) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) acts-as-taggable-on (3.4.2) activerecord (>= 3.2, < 5) airbrake (4.1.0) builder multi_json - arel (3.0.3) + arel (5.0.1.20140414130214) ast (2.0.0) astrolabe (1.3.0) parser (>= 2.2.0.pre.3, < 3.0) bcrypt (3.1.9) - builder (3.0.4) + better_errors (2.0.0) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + builder (3.2.2) byebug (3.5.1) columnize (~> 0.8) debugger-linecache (~> 1.2) slop (~> 3.6) - cancan (1.6.10) - cap-recipes (0.3.39) - capistrano (2.15.5) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) - capistrano-ext (1.2.1) - capistrano (>= 1.0.0) - capistrano-platform-resources (0.1.3) - capistrano (< 3) - capistrano-rbenv (1.0.5) - capistrano (< 3) - capistrano-platform-resources (>= 0.1.3) - capistrano_colors (0.5.5) - capones_recipes (1.20.1) - cap-recipes - capistrano (~> 2.0) - capistrano-ext - capistrano_colors + cancancan (1.9.2) + capistrano (3.2.1) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.3) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-rails (1.1.2) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rbenv (2.0.2) + capistrano (~> 3.1) + sshkit (~> 1.3) chunky_png (1.3.3) ckeditor (4.1.1) cocaine @@ -86,14 +77,16 @@ GEM activesupport (>= 3.0) cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) + cocoon (1.2.6) coderay (1.1.0) - coffee-rails (3.2.2) + coffee-rails (4.1.0) coffee-script (>= 2.2.0) - railties (~> 3.2.0) + railties (>= 4.0.0, < 5.0) coffee-script (2.3.0) coffee-script-source execjs coffee-script-source (1.8.0) + colorize (0.7.3) columnize (0.8.9) compass (1.0.1) chunky_png (~> 1.2) @@ -110,6 +103,7 @@ GEM compass-rails (2.0.1) compass (~> 1.0.0) database_cleaner (1.3.0) + debug_inspector (0.0.2) debugger-linecache (1.2.0) devise (3.4.1) bcrypt (~> 3.0) @@ -119,6 +113,7 @@ GEM thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.5) + docile (1.1.5) domain_name (0.5.22) unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) @@ -133,42 +128,46 @@ GEM ffi formtastic (3.1.2) actionpack (>= 3.2.13) - haml (4.0.5) + haml (4.0.6) tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) - has_scope (0.5.1) - highline (1.6.21) + haml-rails (0.5.3) + actionpack (>= 4.0.1) + activesupport (>= 4.0.1) + haml (>= 3.1, < 5.0) + railties (>= 4.0.1) + has_scope (0.6.0.rc) + actionpack (>= 3.2, < 5) + activesupport (>= 3.2, < 5) hike (1.2.3) holidays (1.2.0) http-cookie (1.0.2) domain_name (~> 0.5) i18n (0.6.11) - inherited_resources (1.4.0) - has_scope (~> 0.5.0) - responders (~> 0.9) + inherited_resources (1.5.1) + actionpack (>= 3.2, < 4.2) + has_scope (~> 0.6.0.rc) + railties (>= 3.2, < 4.2) + responders (~> 1.0) innertube (1.1.0) - joiner (0.2.0) - activerecord (>= 3.1.0, < 4.1.0) - journey (1.0.4) + jbuilder (2.2.5) + activesupport (>= 3.0.0, < 5) + multi_json (~> 1.2) + joiner (0.3.4) + activerecord (>= 4.1.0) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.2) + jquery-ui-rails (5.0.3) railties (>= 3.2.16) json (1.8.1) kgio (2.9.2) libv8 (3.16.14.7) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mechanize (2.7.2) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mechanize (2.7.3) domain_name (~> 0.5, >= 0.5.1) - http-cookie (~> 1.0.0) - mime-types (~> 1.17, >= 1.17.2) + http-cookie (~> 1.0) + mime-types (~> 2.0) net-http-digest_auth (~> 1.1, >= 1.1.1) net-http-persistent (~> 2.5, >= 2.5.2) nokogiri (~> 1.4) @@ -176,31 +175,27 @@ GEM webrobots (>= 0.0.9, < 0.2) method_source (0.8.2) middleware (0.1.0) - mime-types (1.25.1) + mime-types (2.4.3) mini_portile (0.6.1) + minitest (5.4.3) multi_json (1.10.1) mysql2 (0.3.17) net-http-digest_auth (1.4) net-http-persistent (2.9.4) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) net-ssh (2.9.1) - net-ssh-gateway (1.2.0) - net-ssh (>= 2.6.5) - nokogiri (1.6.4.1) + nokogiri (1.6.5) mini_portile (~> 0.6.0) ntlm-http (0.1.1) orm_adapter (0.5.0) - paper_trail (2.7.2) - activerecord (~> 3.0) - railties (~> 3.0) + paper_trail (3.0.6) + activerecord (>= 3.0, < 5.0) + activesupport (>= 3.0, < 5.0) parser (2.2.0.pre.8) ast (>= 1.1, < 3.0) slop (~> 3.4, >= 3.4.5) pdf-core (0.4.0) - polyglot (0.3.5) powerpack (0.0.9) prawn (1.3.0) pdf-core (~> 0.4.0) @@ -220,46 +215,38 @@ GEM pry (>= 0.9.10) quiet_assets (1.0.3) railties (>= 3.1, < 5.0) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) + rack (1.5.2) rack-google-analytics (1.2.0) actionpack activesupport - rack-ssl (1.3.4) - rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.21) - actionmailer (= 3.2.21) - actionpack (= 3.2.21) - activerecord (= 3.2.21) - activeresource (= 3.2.21) - activesupport (= 3.2.21) - bundler (~> 1.0) - railties (= 3.2.21) - railties (3.2.21) - actionpack (= 3.2.21) - activesupport (= 3.2.21) - rack-ssl (~> 1.3.2) + rails (4.1.8) + actionmailer (= 4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) + activemodel (= 4.1.8) + activerecord (= 4.1.8) + activesupport (= 4.1.8) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.8) + sprockets-rails (~> 2.0) + railties (4.1.8) + actionpack (= 4.1.8) + activesupport (= 4.1.8) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) + thor (>= 0.18.1, < 2.0) rainbow (2.0.0) raindrops (0.13.0) - rake (10.4.0) + rake (10.4.1) rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - rdoc (3.12.2) + rdoc (4.1.2) json (~> 1.4) ref (1.0.5) - responders (0.9.3) - railties (~> 3.1) - revertible_paper_trail (0.3.3) - paper_trail (~> 2.2) - paper_trail (~> 2.2) - rails (~> 3.0) + responders (1.1.2) + railties (>= 3.2, < 4.2) riddle (1.5.11) rspec-core (3.1.7) rspec-support (~> 3.1.0) @@ -286,10 +273,13 @@ GEM ruby-ole (1.2.11.7) ruby-progressbar (1.7.0) sass (3.4.9) - sass-rails (3.2.6) - railties (~> 3.2.0) + sass-rails (4.0.1) + railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) - tilt (~> 1.3) + sprockets-rails (~> 2.0.0) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) settingslogic (2.0.9) shoulda (3.5.0) shoulda-context (~> 1.0, >= 1.0.1) @@ -302,14 +292,30 @@ GEM activemodel (>= 3.2, < 5) simple-navigation (3.13.0) activesupport (>= 2.3.2) + simplecov (0.9.1) + docile (~> 1.1.0) + multi_json (~> 1.0) + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) slop (3.6.0) spreadsheet (1.0.0) ruby-ole (>= 1.0) - sprockets (2.2.3) + spring (1.2.0) + spring-commands-rspec (1.0.2) + spring (>= 0.9.1) + sprockets (2.11.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + sshkit (1.5.1) + colorize + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref @@ -323,11 +329,9 @@ GEM thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) ttfunk (1.4.0) - tzinfo (0.3.42) + tzinfo (1.2.2) + thread_safe (~> 0.1) uglifier (2.5.3) execjs (>= 0.3.0) json (>= 1.8.0) @@ -338,9 +342,13 @@ GEM kgio (~> 2.6) rack raindrops (~> 0.7) + unicorn-rails (2.2.0) + rack + unicorn warden (1.2.3) rack (>= 1.0) webrobots (0.1.1) + will_paginate (3.0.7) PLATFORMS ruby @@ -348,11 +356,15 @@ PLATFORMS DEPENDENCIES acts-as-taggable-on airbrake - cancan - capistrano (~> 2.15.5) - capistrano-rbenv (~> 1.0) - capones_recipes + better_errors + binding_of_caller + cancancan + capistrano (~> 3.2.0) + capistrano-bundler + capistrano-rails + capistrano-rbenv ckeditor + cocoon coffee-rails compass-rails database_cleaner @@ -364,7 +376,8 @@ DEPENDENCIES has_scope holidays i18n_rails_helpers! - inherited_resources + inherited_resources (~> 1.5.0) + jbuilder jquery-rails jquery-ui-rails mechanize @@ -379,18 +392,21 @@ DEPENDENCIES quiet_assets rack-google-analytics rails - rdoc - revertible_paper_trail rspec-rails rubocop sass-rails + sdoc settingslogic shoulda show_for simple-navigation + simplecov spreadsheet + spring + spring-commands-rspec + sprockets (~> 2.11.0) therubyracer thinking-sphinx uglifier - unicorn - will_paginate! + unicorn-rails + will_paginate diff --git a/INSTALL.textile b/INSTALL.textile index cfe0f0cc..d1a177d2 100644 --- a/INSTALL.textile +++ b/INSTALL.textile @@ -28,7 +28,6 @@ Install current katalog from git repository. We'll use this checkout as working
git clone git@github.com:CyTeam/katalog.git cd katalog -mkdir -p tmp logInstall dependency gems: @@ -51,10 +50,12 @@ cp config/database.yml.example config/database.yml Initialize the database:
-bundle exec rake db:setup +bin/rake db:setup-Setup freetext search +Setup freetext search. You need a version >= 2.1.2. This is not available in +Ubuntu up to Utopic. But you may install the version from Debian Sid directly +from http://packages.debian.org
sudo apt-get install sphinxsearch @@ -63,5 +64,5 @@ sudo apt-get install sphinxsearch Initialize the search index:-bundle exec rake katalog:ts:export_lists ts:rebuild katalog:aspell:update +bin/rake katalog:ts:export_lists ts:rebuild katalog:aspell:updatediff --git a/Rakefile b/Rakefile index 0943b5bc..ba6b733d 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,4 @@ require File.expand_path('../config/application', __FILE__) -require 'rake' -require 'rdoc/task' if Rails.env.development? - -Katalog::Application.load_tasks +Rails.application.load_tasks diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8687194c..d291b1d8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -8,6 +8,7 @@ //= require jquery_ujs //= require jquery-ui //= require ckeditor/init +//= require cocoon //= require_tree . $(document).ready(function() { @@ -27,4 +28,8 @@ $(document).ready(function() { addEditReportBehaviour(); addCsrfTokenToAjaxCalls(); addMainNavigationBehaviour(); + showKeyWords(); + hideKeyWords(); + previewReport(); + initalizeCocoon(); }); diff --git a/app/assets/javascripts/katalog.js b/app/assets/javascripts/katalog.js index 77d309e4..319045cf 100644 --- a/app/assets/javascripts/katalog.js +++ b/app/assets/javascripts/katalog.js @@ -87,9 +87,7 @@ function addRelationAutoCompletionBehaviour() { } }, success: function( data ) { - response( $.map( data, function( object ) { - // Accept both Topic and Dossier objects - var item = object['topic'] || object['dossier']; + response( $.map( data, function( item ) { if (item) { return { label: item['title'], @@ -296,16 +294,19 @@ function addReportColumnMultiselectBehaviour() { itemsCount:'Spalten ausgewählt' }); - $('#report_columns').multiselect(); + $('#report_column_names').multiselect(); } function previewReport() { - var preview = $('#report-preview'); - var form = $('form.report'); - var action = '/reports/preview'; - - $.get(action, form.serializeArray(), function(data){ - preview.html(data); + $('#preview_report').click(function(e){ + e.preventDefault(); + var preview = $('#report-preview'); + var form = $('form.report'); + var action = '/reports/preview'; + + $.get(action, form.serializeArray(), function(data){ + preview.html(data); + }); }); } @@ -319,19 +320,23 @@ function informUserAboutBigPDF(amount){ // Shows the key words in the dossier view. function showKeyWords() { - $('#show-key-words-link').hide(); - $('#hide-key-words-link').show(); - $('span.keywords').show(); - $.post('/user_session.json'); -} + $('#show-key-words-link').click(function(){ + $('#show-key-words-link').hide(); + $('#hide-key-words-link').show(); + $('span.keywords').show(); + $.post('/user_session.json'); + }) +}; // Hides the key words in the dossier view. function hideKeyWords() { - $('#hide-key-words-link').hide(); - $('#show-key-words-link').show(); - $('span.keywords').hide(); - $.post('/user_session.json?hide_keywords=true'); -} + $('#hide-key-words-link').click(function(){ + $('#hide-key-words-link').hide(); + $('#show-key-words-link').show(); + $('span.keywords').hide(); + $.post('/user_session.json?hide_keywords=true'); + }) +}; // Adds the CSRF token to all ajax calls. function addCsrfTokenToAjaxCalls(){ @@ -353,3 +358,10 @@ function addMainNavigationBehaviour() { $(this).parents('li').addClass('selected'); }); } + +// Sets the insertion point for cocoon +function initalizeCocoon() { + $("a#add_new_container"). + data("association-insertion-method", 'append'). + data("association-insertion-node", '#container-list'); +} diff --git a/app/assets/stylesheets/katalog.css b/app/assets/stylesheets/katalog.css index 7ec04cfb..82446c50 100644 --- a/app/assets/stylesheets/katalog.css +++ b/app/assets/stylesheets/katalog.css @@ -11,7 +11,7 @@ font-size: 90%; } -tr.topic.group td { background-color: #96B1CD; } +tr.topic.topic_group td { background-color: #96B1CD; } tr.topic.main td { background-color: #E1E6EC; } tr.topic.geo td { background-color: #C8B7B7; } tr.topic.detail td { background-color: #E9DDAF; } @@ -40,7 +40,7 @@ th.action-links { border: 0; font-size: 85%; } -.index tr.topic.group td { +.index tr.topic.topic_group td { padding-top: 8px; padding-bottom: 8px; border: 0; @@ -53,18 +53,18 @@ th.action-links { } /** Sidebar Topic Index **/ -li.topic.group { +li.topic.topic_group { font-weight: bold; list-style-type: none; list-style-image: none; } -li.topic.group .signature { +li.topic.topic_group .signature { float: left; width: 1.2em; } -li.topic.group a { +li.topic.topic_group a { margin-left: 1.5em; display: block; text-decoration: none; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 87e0f5dd..11d7cba0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class ApplicationController < ActionController::Base protect_from_forgery layout 'application' diff --git a/app/controllers/authorized_controller.rb b/app/controllers/authorized_controller.rb index 21303da5..aef07c42 100644 --- a/app/controllers/authorized_controller.rb +++ b/app/controllers/authorized_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class AuthorizedController < InheritedResources::Base # Authorization authorize_resource diff --git a/app/controllers/batch_edit_dossier_numbers_controller.rb b/app/controllers/batch_edit_dossier_numbers_controller.rb index 35245a74..ac521e6e 100644 --- a/app/controllers/batch_edit_dossier_numbers_controller.rb +++ b/app/controllers/batch_edit_dossier_numbers_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class BatchEditDossierNumbersController < ApplicationController # Responders respond_to :html, :js, :json diff --git a/lib/tasks/.gitkeep b/app/controllers/concerns/.keep similarity index 100% rename from lib/tasks/.gitkeep rename to app/controllers/concerns/.keep diff --git a/app/controllers/container_counting_controller.rb b/app/controllers/container_counting_controller.rb index ccc6833a..e013684e 100644 --- a/app/controllers/container_counting_controller.rb +++ b/app/controllers/container_counting_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class ContainerCountingController < ApplicationController # Filter has_scope :by_container_type, as: :container_type diff --git a/app/controllers/container_types_controller.rb b/app/controllers/container_types_controller.rb index a57e6602..a48c2a07 100644 --- a/app/controllers/container_types_controller.rb +++ b/app/controllers/container_types_controller.rb @@ -1,10 +1,11 @@ -# encoding: UTF-8 - class ContainerTypesController < AuthorizedController - # Authentication - before_filter :authenticate_user!, except: [:index, :show] + before_action :authenticate_user!, except: [:index, :show] + + private - def attributes - %w(title code description) + def container_type_params + params.require(:container_type).permit( + :title, :code, :description + ) end end diff --git a/app/controllers/containers_controller.rb b/app/controllers/containers_controller.rb deleted file mode 100644 index 27bf37d2..00000000 --- a/app/controllers/containers_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: UTF-8 - -class ContainersController < AuthorizedController - # Authentication - before_filter :authenticate_user!, except: [:index, :search, :show] - - # Responders - respond_to :html, :js -end diff --git a/app/controllers/dossier_numbers_controller.rb b/app/controllers/dossier_numbers_controller.rb index 5470f64a..a5d8ba8e 100644 --- a/app/controllers/dossier_numbers_controller.rb +++ b/app/controllers/dossier_numbers_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class DossierNumbersController < AuthorizedController respond_to :json, only: :create diff --git a/app/controllers/dossiers_controller.rb b/app/controllers/dossiers_controller.rb index 8c2b1d9c..96d60a33 100644 --- a/app/controllers/dossiers_controller.rb +++ b/app/controllers/dossiers_controller.rb @@ -1,21 +1,15 @@ -# encoding: UTF-8 class DossiersController < AuthorizedController - # Authentication - before_filter :authenticate_user!, except: [:index, :search, :show, :report, :welcome, :sitemap] + before_action :authenticate_user!, except: [:index, :search, :show, :report, :welcome, :sitemap] - # Responders respond_to :html, :js, :json, :xls, :pdf - # Search has_scope :by_character - # CRUD Actions - # ============ def show # Set query for highlighting and search form prefill @query = params[:search][:text] if params[:search] - @dossier = Dossier.find(params[:id], include: { containers: [:location, :container_type] }) + @dossier = Dossier.find(params[:id]) authorize! :show, @dossier @@ -35,7 +29,6 @@ def show def new @dossier = Dossier.new(params[:dossier]) @dossier.build_default_numbers - @dossier.containers.build(container_type_code: 'DH') new! @@ -63,7 +56,7 @@ def create def welcome redirect_to dossiers_path if user_signed_in? - @groups = Dossier.group + @groups = Dossier.topic_group end def index @@ -208,4 +201,14 @@ def index_excel end end end + + private + + def dossier_params + params.require(:dossier).permit( + :internal, :signature, :title, :description, :keyword_text, + :relation_list, :add_relation, :first_document_year, :dossier_number_list, + containers_attributes: [:id, :period, :container_type_code, :location_code, :_destroy] + ) + end end diff --git a/app/controllers/keywords_controller.rb b/app/controllers/keywords_controller.rb index 4fe69240..bca40487 100644 --- a/app/controllers/keywords_controller.rb +++ b/app/controllers/keywords_controller.rb @@ -1,11 +1,9 @@ -# encoding: UTF-8 - class KeywordsController < InheritedResources::Base # Association optional_belongs_to :dossier # Authentication - before_filter :authenticate_user!, except: [:index, :suggestions, :search, :show] + before_action :authenticate_user!, except: [:index, :suggestions, :search, :show] # Responders respond_to :html, :js, :json diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 0800c44c..2f5dfb58 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -1,10 +1,11 @@ -# encoding: UTF-8 - class LocationsController < AuthorizedController - # Authentication - before_filter :authenticate_user!, except: [:index, :show] + before_action :authenticate_user!, except: [:index, :show] + + private - def attributes - %w(title code address availability preorder) + def location_params + params.require(:location).permit( + :title, :code, :address, :availability, :preorder + ) end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 613cda5b..02f3b6b9 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,8 +1,6 @@ -# encoding: UTF-8 - class ReportsController < AuthorizedController def attributes - %w(title columns public) + %w(title column_names public) end def edit @@ -14,7 +12,16 @@ def show end def preview - @report = Report.new(params[:report]) + @report = Report.new(report_params) render partial: 'show' end + + private + + def report_params + params.require(:report).permit( + :name, :title, :level, :orientation, :years_visible, + :collect_year_count, :public, column_names: [] + ) + end end diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb index 77f326b1..11404306 100644 --- a/app/controllers/reservations_controller.rb +++ b/app/controllers/reservations_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class ReservationsController < AuthorizedController def new @dossier = Dossier.find(params[:dossier_id]) diff --git a/app/controllers/search_replaces_controller.rb b/app/controllers/search_replaces_controller.rb index a3d51164..65e49099 100644 --- a/app/controllers/search_replaces_controller.rb +++ b/app/controllers/search_replaces_controller.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class SearchReplacesController < AuthorizedController def index @search_replace = SearchReplace.new diff --git a/app/controllers/sphinx_admins_controller.rb b/app/controllers/sphinx_admins_controller.rb index 0f32782a..d7759564 100644 --- a/app/controllers/sphinx_admins_controller.rb +++ b/app/controllers/sphinx_admins_controller.rb @@ -1,7 +1,5 @@ -# encoding: UTF-8 - class SphinxAdminsController < AuthorizedController - before_filter :authenticate_user! + before_action :authenticate_user! def exceptions @model = SphinxAdminException diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 490a29e4..94aafba2 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -1,19 +1,6 @@ -# encoding: UTF-8 - class TopicsController < AuthorizedController include DossiersHelper - # Authentication - before_filter :authenticate_user!, except: [:index, :show, :navigation] - - protected - - def collection - @topics ||= end_of_association_chain.paginate(page: params[:page]) - end - - # Actions - - public + before_action :authenticate_user!, except: [:index, :show, :navigation] def update @topic = Topic.find(params[:id]) @@ -43,4 +30,12 @@ def navigation end end end + + private + + def topic_params + params.require(:topic).permit( + :signature, :title, :update_signature + ) + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fa4d8c6c..d7639eb3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,13 +1,6 @@ -# encoding: UTF-8 - -# Users Controller -# -# Provides a user/account management interface. class UsersController < AuthorizedController - # Scopes has_scope :tagged_with - # Actions def update # Preset role_texts to ensure it clears roles. params[:user][:role_texts] ||= [] @@ -32,4 +25,12 @@ def unlock def current redirect_to current_user end + + private + + def user_params + params.require(:user).permit( + :username, :email, :password, :password_confirmation, :role_texts + ) + end end diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 03e9fd2d..1b7b1e34 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -1,9 +1,7 @@ -# encoding: UTF-8 - class VersionsController < AuthorizedController include VersionsHelper # Authentication - before_filter :authenticate_user! + before_action :authenticate_user! def attributes %w(item_type object changed_from changed_at action) @@ -39,11 +37,6 @@ def revert @version = Version.find(params[:id]) @version.revert - if dossier? @version - # TODO: try reactivating this code - # Dossier.restore_relations(@version) - end - redirect_to :back end end diff --git a/app/controllers/visitor_logs_controller.rb b/app/controllers/visitor_logs_controller.rb index f6606902..3feadc20 100644 --- a/app/controllers/visitor_logs_controller.rb +++ b/app/controllers/visitor_logs_controller.rb @@ -1,21 +1,19 @@ -# encoding: UTF-8 - class VisitorLogsController < AuthorizedController - # Authentication - before_filter :authenticate_user! - - def attributes - %w(title user created_at) - end + before_action :authenticate_user! def create - @visitor_log = VisitorLog.new(params[:visitor_log]) - @visitor_log.user = current_user - create! { visitor_logs_path } end def index - @visitor_logs = VisitorLog.order('created_at DESC') + @visitor_logs = VisitorLog.order(created_at: :desc) + end + + private + + def visitor_log_params + params.require(:visitor_log).permit( + :title, :content + ).merge(user: current_user) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 23911483..6ce8ccf8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,31 +1,4 @@ -# encoding: UTF-8 - module ApplicationHelper - # Nested Form - def remove_link_unless_new_record(fields) - unless fields.object.new_record? - out = '' - out << fields.hidden_field(:_destroy) - out << link_to_function(image_tag('icons/delete.png'), "$(this).parents('.#{fields.object.class.name.underscore}').hide();$(this).hide();$(this).prev().attr('value', '1');$(this).next().show();hideUnlessNewRecord($(this).parents('.#{fields.object.class.name.underscore}'));") - out << link_to_function(image_tag('icons/add.png'), "$(this).parents('.#{fields.object.class.name.underscore}').hide();$(this).hide();$(this).prev().prev().attr('value', 'false');$(this).prev().show();showUnlessNewRecord($(this).parents('.#{fields.object.class.name.underscore}'));", style: 'display:none;') - out.html_safe - end - end - - def add_record_link(form, _klass) - record = render('containers/new_form', form: form) - function = " -var new_record_id = new Date().getTime(); -var content = '#{ escape_javascript record }'; -content = content.replace(/\\[\\d+\\]/g, '[' + new_record_id + ']'); -content = content.replace(/_\\d+_/g, '_' + new_record_id + '_'); -$('#container-list').append(content); -addContainerSuggestionBehaviour(); -" - - link_to_function image_tag('icons/add.png'), function, id: 'add_record_link' - end - # Navigation def navigation_item(title, *args) if current_page?(*args) diff --git a/app/helpers/container_types_helper.rb b/app/helpers/container_types_helper.rb deleted file mode 100644 index 2af233ec..00000000 --- a/app/helpers/container_types_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# encoding: UTF-8 - -module ContainerTypesHelper -end diff --git a/app/helpers/dossier_numbers_helper.rb b/app/helpers/dossier_numbers_helper.rb deleted file mode 100644 index 4d64557c..00000000 --- a/app/helpers/dossier_numbers_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# encoding: UTF-8 - -module DossierNumbersHelper -end diff --git a/app/helpers/dossiers_helper.rb b/app/helpers/dossiers_helper.rb index e567eda1..08ef06d4 100644 --- a/app/helpers/dossiers_helper.rb +++ b/app/helpers/dossiers_helper.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module DossiersHelper def link_to_tag_filter(name, options = {}) query = [@query, name].compact.join(' ') @@ -76,12 +74,14 @@ def search_title # Reports # ======= def show_header_for_report(column) - case column - when :document_count - @document_count ? t('katalog.total_count', count: number_with_delimiter(@document_count)) : t_attr(:document_count, Dossier) - else - t_attr(column.to_s, Dossier) - end + column_name = + case column + when :document_count + @document_count ? t('katalog.total_count', count: number_with_delimiter(@document_count)) : t_attr(:document_count, Dossier) + else + t_attr(column.to_s, Dossier) + end + column_name end def show_column_for_report(dossier, column, for_pdf = false) diff --git a/app/helpers/keywords_helper.rb b/app/helpers/keywords_helper.rb deleted file mode 100644 index 3296797a..00000000 --- a/app/helpers/keywords_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# encoding: UTF-8 - -module KeywordsHelper -end diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb deleted file mode 100644 index 81d2829b..00000000 --- a/app/helpers/locations_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# encoding: UTF-8 - -module LocationsHelper -end diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 9a8cd18d..dff4433f 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module ReportsHelper def level_for_select (1..4).map { |level| [t(level, scope: 'katalog.reports.level'), level] } @@ -10,18 +8,15 @@ def orientation_for_select orientations.map { |orientation| [t(orientation, scope: 'katalog.orientation'), orientation] } end - # Build collection for report columns multi select - # - # It adds the selected columns first, in the correct order, then comes the available ones. - def report_columns_for_select(report) + def report_column_names_for_select(report) available_columns = %w(signature title first_document_year keyword_text container_type location document_count) - if report.columns.blank? + if report.column_names.blank? columns = available_columns else - columns = report.columns + (available_columns - report.columns) + columns = report.column_names + (available_columns - report.column_names) end - columns.map { |column| [t_attr(column, Dossier), column] } + columns.reject(&:empty?).map { |column| [t_attr(column, Dossier), column] } end end diff --git a/app/helpers/search_form_helper.rb b/app/helpers/search_form_helper.rb index f0c776d3..04c65603 100644 --- a/app/helpers/search_form_helper.rb +++ b/app/helpers/search_form_helper.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module SearchFormHelper def search_form_for(object_name, options = {}, &block) options[:html] = { method: :get }.update(options[:html] || {}) diff --git a/app/helpers/sphinx_admins_helper.rb b/app/helpers/sphinx_admins_helper.rb index b863b43f..58ea77a4 100644 --- a/app/helpers/sphinx_admins_helper.rb +++ b/app/helpers/sphinx_admins_helper.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module SphinxAdminsHelper def add_new_link link_to_function image_tag('icons/add.png', title: t('crud.new', model: '')), id: 'add_record_link' do |page| diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 1a04eb0f..9a8287aa 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module VersionsHelper def change_type(previous, current) if previous == current diff --git a/app/mailers/reservation_mailer.rb b/app/mailers/reservation_mailer.rb index f9041913..5acdddcf 100644 --- a/app/mailers/reservation_mailer.rb +++ b/app/mailers/reservation_mailer.rb @@ -1,7 +1,5 @@ -# encoding: UTF-8 - class ReservationMailer < ActionMailer::Base - default from: Settings.mail.reservation.sender + default from: Settings.mail.sender, reply_to: Settings.mail.recipient def user_email(reservation) @reservation = reservation @@ -16,8 +14,7 @@ def editor_email(reservation) @reservation = reservation mail( - from: Settings.mail.reservation.internal_sender, - to: Settings.mail.reservation.sender, + to: Settings.mail.recipient, subject: "#{I18n.t('activerecord.attributes.reservation.title')}: #{@reservation.dossier}" ) end diff --git a/app/models/ability.rb b/app/models/ability.rb index fa6f84c7..71e29677 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # Defines abilities # # This class defines the abilities available to User Roles. diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/container.rb b/app/models/container.rb index a180a7a9..d22691b5 100644 --- a/app/models/container.rb +++ b/app/models/container.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class Container < ActiveRecord::Base # change log has_paper_trail ignore: [:created_at, :updated_at], meta: { dossier_id: proc(&:dossier_id) } @@ -10,13 +8,10 @@ class Container < ActiveRecord::Base after_save lambda { dossier.touch } belongs_to :location - attr_accessible :location, :location_code belongs_to :container_type - attr_accessible :container_type, :container_type_code # Validations validates_presence_of :period, :dossier, :location, :container_type - attr_accessible :period # Helpers def to_s diff --git a/app/models/container_type.rb b/app/models/container_type.rb index b7ad80e0..70020b4b 100644 --- a/app/models/container_type.rb +++ b/app/models/container_type.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class represents the different container types. class ContainerType < ActiveRecord::Base # PaperTrail: change log diff --git a/app/models/dossier.rb b/app/models/dossier.rb index dd6f78dd..6af86002 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,12 +1,4 @@ -# encoding: utf-8 - -# This class represents a dossier with many containers. class Dossier < ActiveRecord::Base - attr_accessible :container_type_code, :location_code, :internal, :signature, :title, :description, :keyword_text, :relation_list, :add_relation, :first_document_year, :dossier_number_list, :containers_attributes - - # PaperTrail - # ========== - # We're using papertrail to track changes has_paper_trail ignore: [:created_at, :updated_at, :search_key, :delta], meta: { container_ids: proc { |dossier| dossier.container_ids.join(',') }, number_ids: proc { |dossier| dossier.number_ids.join(',') }, @@ -27,15 +19,15 @@ def save_temp_tags validates :title, presence: true, allow_blank: false validates_format_of :first_document_year, with: /[12][0-9]{3}/, allow_blank: true - default_scope order: 'sort_key ASC' + default_scope -> { order(sort_key: :asc) } # Type Scopes - scope :dossier, where(type: nil) - scope :topic, where('type IS NOT NULL') - scope :group, topic.where('char_length(signature) = 1') - scope :main, topic.where('char_length(signature) = 2') - scope :geo, topic.where('char_length(signature) = 4') - scope :detail, topic.where('char_length(signature) = 8') + scope :dossier, -> { where(type: nil) } + scope :topic, -> { where(type: Topic) } + scope :topic_group, -> { topic.where('char_length(signature) = 1') } + scope :main, -> { topic.where('char_length(signature) = 2') } + scope :geo, -> { topic.where('char_length(signature) = 4') } + scope :detail, -> { topic.where('char_length(signature) = 8') } # Scopes scope :by_level, lambda { |level| where('char_length(dossiers.signature) <= ?', level_to_prefix_length(level)) } @@ -235,7 +227,9 @@ def waiting_list end # Keep relations intact on renames - before_save do + before_save :update_relations + + def update_relations # No action needed for new records return if new_record? @@ -534,8 +528,8 @@ def alphabetic? end def tooltip - html_output = "#{I18n.translate('katalog.dossier_count_per_year')}
" unless numbers.present.empty? - numbers.present.each do |number| + html_output = "#{I18n.translate('katalog.dossier_count_per_year')}
" unless numbers.documents_present.empty? + numbers.documents_present.each do |number| html_output += "#{number.amount}
" end @@ -548,9 +542,6 @@ def tooltip # Sphinx Freetext Search include Dossiers::Sphinx - # Paper Trail - include Dossiers::PaperTrail - # Text helper include ActionView::Helpers::TextHelper diff --git a/app/models/dossier_number.rb b/app/models/dossier_number.rb index ddf08634..5452c5b6 100644 --- a/app/models/dossier_number.rb +++ b/app/models/dossier_number.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class holds the information form date to to date how much dossiers exists. class DossierNumber < ActiveRecord::Base # PaperTrails: change log @@ -14,8 +12,8 @@ class DossierNumber < ActiveRecord::Base validate :presence_of_from_or_to # Scopes - default_scope order('`to`') - scope :present, where('amount > 0') + default_scope -> { order(:to) } + scope :documents_present, -> { where('amount > 0') } scope :by_period, lambda {|value| from, to = from_s(value) diff --git a/app/models/dossiers/export_to_xls.rb b/app/models/dossiers/export_to_xls.rb index e030be1b..391f571b 100644 --- a/app/models/dossiers/export_to_xls.rb +++ b/app/models/dossiers/export_to_xls.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # Export to Excel # =============== require 'spreadsheet' diff --git a/app/models/dossiers/paper_trail.rb b/app/models/dossiers/paper_trail.rb deleted file mode 100644 index 08881b73..00000000 --- a/app/models/dossiers/paper_trail.rb +++ /dev/null @@ -1,32 +0,0 @@ -# encoding: UTF-8 - -module Dossiers - module PaperTrail - extend ActiveSupport::Concern - - module ClassMethods - def restore_relations(version) - related_object_ids = version.container_ids.split(',').map(&:to_i) + version.number_ids.split(',').map(&:to_i) - - related_object_ids.each do |id| - sub_version = Version.find_by_item_id(id) - sub_object = sub_version.reify - sub_original = (sub_version.event == 'destroy' ? nil : sub_version.item_type.constantize.find(sub_version.item_id)) - - if sub_original - sub_original = sub_object - sub_original.dossier_id = version.item_id - sub_original.save - else - sub_object.dossier_id = version.item_id - sub_object.save - end - end - - dossier = Dossier.find(version.item_id) - dossier.keyword_list = version.keywords - dossier.save! - end - end - end -end diff --git a/app/models/dossiers/sphinx.rb b/app/models/dossiers/sphinx.rb index e2bbe9d6..6b14629f 100644 --- a/app/models/dossiers/sphinx.rb +++ b/app/models/dossiers/sphinx.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module Dossiers module Sphinx extend ActiveSupport::Concern diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 7a273ed3..ee3add4a 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class is a sub class of ActAsTaggableOn and provides the information about the dossier keywords. class Keyword < ActsAsTaggableOn::Tag # PaperTrail: change log @@ -7,14 +5,17 @@ class Keyword < ActsAsTaggableOn::Tag # Scopes scope :by_character, lambda { |value| where("name LIKE CONCAT(?, '%')", value) } - scope :characters, select('DISTINCT substring(upper(name), 1, 1) AS letter').having("letter BETWEEN 'A' AND 'Z'") - default_scope joins(:taggings).where('taggings.context' => 'keywords').order("case when name regexp '^[[:alpha:]]' then 0 when name regexp '^[0-9]' then 1 else 2 end, name").order('name') + scope :characters, -> { select('DISTINCT substring(upper(name), 1, 1) AS letter').having("letter BETWEEN 'A' AND 'Z'") } + default_scope -> { + joins(:taggings).where('taggings.context' => 'keywords').order("case when name regexp '^[[:alpha:]]' then 0 when name regexp '^[0-9]' then 1 else 2 end, name").order(:name) + } # The list of all characters. def self.character_list characters.map(&:letter) end - scope :filter_tags, - select('tags.*, COUNT(*) AS count').joins('JOIN dossiers ON dossiers.id = taggings.taggable_id').having('COUNT(*) >= 2').group('tags.id').order('COUNT(*)').limit(12) + scope :filter_tags, -> { + select('tags.*, COUNT(*) AS count').joins('JOIN dossiers ON dossiers.id = taggings.taggable_id').having('COUNT(*) >= 2').group('tags.id').order('COUNT(*)').limit(12) + } end diff --git a/app/models/location.rb b/app/models/location.rb index 54c91c5b..54ddf1c1 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class represents the different locations where a container can be stored. class Location < ActiveRecord::Base # Associations diff --git a/app/models/report.rb b/app/models/report.rb index eac7b7c1..d59b5989 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,14 +1,8 @@ -# encoding: UTF-8 - -# This class defines different views on the dossiers. class Report < ActiveRecord::Base - # Serializes the column attribute. - serialize :columns + serialize :column_names - # Validations - validates :name, presence: true, uniqueness: true - validates :columns, presence: true - validates :title, presence: true + validates :name, :title, :column_names, presence: true + validates :name, uniqueness: true before_save :default_collect_year_count @@ -16,10 +10,6 @@ def default_collect_year_count self.collect_year_count = 1 if collect_year_count.blank? && years_visible? end - def columns - self[:columns].map(&:presence).compact - end - def to_s "#{self.class}: #{name}" end diff --git a/app/models/reservation.rb b/app/models/reservation.rb index 7248bc0e..a0bd22fc 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class Reservation < ActiveRecord::Base belongs_to :dossier diff --git a/app/models/role.rb b/app/models/role.rb index 58d824e8..d9a28a92 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class Role < ActiveRecord::Base # PaperTrail: change log has_paper_trail ignore: [:created_at, :updated_at] diff --git a/app/models/search_replace.rb b/app/models/search_replace.rb index c266bd88..3c8b6fc8 100644 --- a/app/models/search_replace.rb +++ b/app/models/search_replace.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class is a sub class of FormtasticFauxModel. # It is used to do global search and replace actions. class SearchReplace < FormtasticFauxModel diff --git a/app/models/sphinx_admin.rb b/app/models/sphinx_admin.rb index 927cdca3..6f4da045 100644 --- a/app/models/sphinx_admin.rb +++ b/app/models/sphinx_admin.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class is a parent class of SphinxAdminException and SphinxAdminWordForm. # It creates the sphinx config files in the directory config/sphinx. # Before sphinx search can be started these files should be created. @@ -11,7 +9,7 @@ class SphinxAdmin < ActiveRecord::Base has_paper_trail ignore: [:created_at, :updated_at] - default_scope order: 'sphinx_admins.from ASC' + default_scope -> { order('sphinx_admins.from ASC') } # The default folder for the config files. FOLDER = Rails.root.join('config', 'sphinx') diff --git a/app/models/sphinx_admin_exception.rb b/app/models/sphinx_admin_exception.rb index f60e2326..21c88630 100644 --- a/app/models/sphinx_admin_exception.rb +++ b/app/models/sphinx_admin_exception.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class holds the specific values for the sphinx exceptions config. class SphinxAdminException < SphinxAdmin # The file name for the sphinx exceptions. diff --git a/app/models/sphinx_admin_word_form.rb b/app/models/sphinx_admin_word_form.rb index 44b3b0d4..22773e38 100644 --- a/app/models/sphinx_admin_word_form.rb +++ b/app/models/sphinx_admin_word_form.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class holds the specific values for the sphinx word forms config. class SphinxAdminWordForm < SphinxAdmin # The file name for the word forms. diff --git a/app/models/tag.rb b/app/models/tag.rb index 843d645d..31f43566 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class is a sub class of ActAsTaggableOn and provides the information about the dossier keywords. class Tag < ActsAsTaggableOn::Tag # PaperTrail: change log @@ -7,8 +5,8 @@ class Tag < ActsAsTaggableOn::Tag # Scopes scope :by_character, lambda { |value| where("name LIKE CONCAT(?, '%')", value) } - scope :characters, select('DISTINCT substring(upper(name), 1, 1) AS letter').having("letter BETWEEN 'A' AND 'Z'") - default_scope joins(:taggings).where('taggings.context' => 'tags') + scope :characters, -> { select('DISTINCT substring(upper(name), 1, 1) AS letter').having("letter BETWEEN 'A' AND 'Z'") } + default_scope -> { joins(:taggings).where('taggings.context' => 'tags') } # The list of all characters. def self.character_list @@ -18,6 +16,7 @@ def self.character_list # Dossier scopes scope :by_signature, lambda { |value| where("dossiers.signature LIKE CONCAT(?, '%')", value) } - scope :filter_tags, - select('tags.*, COUNT(*) AS count').joins('JOIN dossiers ON dossiers.id = taggings.taggable_id').group('tags.id').order('COUNT(*) DESC').limit(36) + scope :filter_tags, -> { + select('tags.*, COUNT(*) AS count').joins('JOIN dossiers ON dossiers.id = taggings.taggable_id').group('tags.id').order('COUNT(*) DESC').limit(36) + } end diff --git a/app/models/topic.rb b/app/models/topic.rb index 8192fb28..af2707a9 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - # This class is a subclass of Dossier, which contains many dossiers. # It's a kind of parent for dossiers with a title and type. class Topic < Dossier @@ -27,7 +25,7 @@ def topic_type case signature.length when 1 - :group + :topic_group when 2 :main when 4 @@ -46,10 +44,10 @@ def topic_type def children_topic_type return if topic_type.nil? case topic_type - when :group then :main - when :main then :geo - when :geo then :detail - when :detail then :dossier + when :topic_group then :main + when :main then :geo + when :geo then :detail + when :detail then :dossier end end diff --git a/app/models/user.rb b/app/models/user.rb index a1e29c52..f8c65d89 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class holds all the user information's. class User < ActiveRecord::Base # PaperTrail: changencrypted_passworde log @@ -20,19 +18,10 @@ class User < ActiveRecord::Base # * Code snippet from: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address attr_accessor :login - # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me - - # Added username and login as accessible attributes for a login with username or email. - # - # * Code snippet from: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address - attr_accessible :username, :login - # Authorization roles has_and_belongs_to_many :roles, autosave: true scope :by_role, lambda { |role| include(:roles).where(name: role) } validates_presence_of :role_texts - attr_accessible :role_texts # Validate the presence and uniqueness of the username validates_presence_of :username diff --git a/app/models/version.rb b/app/models/version.rb new file mode 100644 index 00000000..4594e60f --- /dev/null +++ b/app/models/version.rb @@ -0,0 +1,48 @@ +class Version < ActiveRecord::Base + include PaperTrail::VersionConcern + + def revert + case event + when 'create' + # Do nothing if item already destroyed again + return unless item + + item.destroy + when 'update' + reify.save + when 'destroy' + reify.save + end + end + + def active_item + # Take current item or reify latest version + item || versions.last.reify + end + + def current_item + return nil if event == 'destroy' + + if self.next + self.next.reify + else + # Use active item as it should exist + item + end + end + + def previous_item + case event + when 'create' + nil + when 'update' + current_item.previous_version + when 'destroy' + reify + end + end + + def versions + sibling_versions + end +end diff --git a/app/models/visitor_log.rb b/app/models/visitor_log.rb index db1f119c..24dfad27 100644 --- a/app/models/visitor_log.rb +++ b/app/models/visitor_log.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # This class is a simple log for authenticated users. class VisitorLog < ActiveRecord::Base # Associations of the visitor log. diff --git a/app/prawn/prawn_layout.rb b/app/prawn/prawn_layout.rb index e3a35024..7b74f710 100644 --- a/app/prawn/prawn_layout.rb +++ b/app/prawn/prawn_layout.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - class PrawnLayout < Prawn::Document def initialize(opts = {}) super @@ -31,7 +29,7 @@ def row_styling(item, row) row.map do |cell| case item.topic_type - when :group + when :topic_group cell.background_color = '96B1CD' cell.padding_top = 3 cell.padding_bottom = 3 @@ -54,7 +52,7 @@ def h1(title) if title # User multi byte handling for proper upcasing of umlaute # Draws the title of the report - text title.mb_chars.upcase, size: 16 + text title.to_s.mb_chars.upcase, size: 16 # Adds space after the title move_down(5) diff --git a/app/prawn/report_layout.rb b/app/prawn/report_layout.rb index 312ec2fe..c7a31af1 100644 --- a/app/prawn/report_layout.rb +++ b/app/prawn/report_layout.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - require 'prawn/measurement_extensions' class ReportLayout < PrawnLayout @@ -8,7 +6,7 @@ class ReportLayout < PrawnLayout # Creates the table headers for a report. def headers(report) - column_headers = report[:columns].collect do |column| + column_headers = report[:column_names].collect do |column| make_cell(head_cell(column)) end diff --git a/app/views/containers/_form.html.haml b/app/views/containers/_form.html.haml deleted file mode 100644 index d22f1265..00000000 --- a/app/views/containers/_form.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%tr.container - %td.container_period - = container.text_field :period, :style => 'width: 98%' - = container.semantic_errors :period - %td.type_code - = container.text_field :container_type_code, :size => '2', :class => 'container_type_code_auto_completion' - = container.semantic_errors :container_type - %td.location_code - = container.text_field :location_code, :size => '2', :class => 'container_location_code_auto_completion' - = container.semantic_errors :location - %td.remove_link - = remove_link_unless_new_record(container) diff --git a/app/views/containers/_list_header.html.haml b/app/views/containers/_list_header.html.haml index d7894cd3..87f27630 100644 --- a/app/views/containers/_list_header.html.haml +++ b/app/views/containers/_list_header.html.haml @@ -3,4 +3,5 @@ %th{:style => "width: 4em"}= t_attr(:container_type, Container) %th{:style => "width: 2em"}= t_attr(:location, Container) - if defined?(form_helper) - %th.action-links= add_record_link(form_helper, Container) + %th.action-links + = link_to_add_association image_tag('icons/add.png'), form_helper, :containers, id: 'add_new_container' diff --git a/app/views/containers/_new.html.haml b/app/views/containers/_new.html.haml deleted file mode 100644 index a0146210..00000000 --- a/app/views/containers/_new.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -= fields_for @container do |f| - = render 'containers/form', :container => f diff --git a/app/views/containers/_new_form.html.haml b/app/views/containers/_new_form.html.haml deleted file mode 100644 index 609deb72..00000000 --- a/app/views/containers/_new_form.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -= form.fields_for(:containers, Container.new) do |container| - = render 'containers/form', :container => container diff --git a/app/views/containers/new.js.rjs b/app/views/containers/new.js.rjs deleted file mode 100644 index f4916616..00000000 --- a/app/views/containers/new.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page['#container-list'].append(render(:partial => 'new')) \ No newline at end of file diff --git a/app/views/dossiers/_container_fields.html.haml b/app/views/dossiers/_container_fields.html.haml new file mode 100644 index 00000000..cf5d339f --- /dev/null +++ b/app/views/dossiers/_container_fields.html.haml @@ -0,0 +1,14 @@ +%tr.nested-fields.container + %td.container_period + = f.text_field :period, :style => 'width: 98%' + = f.semantic_errors :period + %td.type_code + = f.text_field :container_type_code, :size => '2', :class => 'container_type_code_auto_completion' + = f.semantic_errors :container_type + %td.location_code + = f.text_field :location_code, :size => '2', :class => 'container_location_code_auto_completion' + = f.semantic_errors :location + %td.remove_link + = link_to_remove_association image_tag('icons/delete.png') , f + :javascript + addContainerSuggestionBehaviour() diff --git a/app/views/dossiers/_form.html.haml b/app/views/dossiers/_form.html.haml index 8aaaf247..39f1304a 100644 --- a/app/views/dossiers/_form.html.haml +++ b/app/views/dossiers/_form.html.haml @@ -1,16 +1,16 @@ -= semantic_form_for(@dossier) do |f| += semantic_form_for resource do |f| = f.inputs do = f.semantic_errors :containers = f.input :internal = f.input :signature, :input_html => {:size => '12'} = f.input :title, :input_html => {:style => 'width: 100%'} = f.input :description, :as => :ckeditor, :input_html => {:class => 'autogrow', :rows => 5, :ckeditor => { :width => '74%' }} - ~ f.input :keyword_text, :as => :text, :input_html => {:class => 'autogrow', :rows => @dossier.keyword_list.size + 1} + ~ f.input :keyword_text, :as => :text, :input_html => {:class => 'autogrow', :rows => resource.keyword_list.size + 1} - ~ f.input :relation_list, :as => :text, :input_html => {:class => 'autogrow', :rows => @dossier.relations.size + 1} + ~ f.input :relation_list, :as => :text, :input_html => {:class => 'autogrow', :rows => resource.relations.size + 1} = f.input :add_relation, :placeholder => true, :input_html => {:style => 'width: 74%'} = f.input :first_document_year, :input_html => {:size => '6', :autocomplete => :off} - ~ f.input :dossier_number_list, :as => :text, :input_html => {:class => 'autogrow', :rows => @dossier.numbers.size + 1} + ~ f.input :dossier_number_list, :as => :text, :input_html => {:class => 'autogrow', :rows => resource.numbers.size + 1} :javascript var type_codes = #{ContainerType.all.map {|e| e.code }.to_json}; @@ -18,8 +18,10 @@ %table#container-list.ce_table{:style => "width: 100%"} = render 'containers/list_header', :form_helper => f - = f.semantic_fields_for :containers do |container| - = render 'containers/form', :container => container + #containers + = f.semantic_fields_for :containers do |container| + #containers_list + = render 'container_fields', :f => container = f.actions do = f.action(:submit) diff --git a/app/views/dossiers/report.html.haml b/app/views/dossiers/report.html.haml index 3e2ad551..fab161c3 100644 --- a/app/views/dossiers/report.html.haml +++ b/app/views/dossiers/report.html.haml @@ -7,10 +7,10 @@ #dossiers.ce_table.block{:class => @report[:orientation] } %table %tr.header - - @report[:columns].each do |attr| + - @report[:column_names].each do |attr| %th{:class => attr.to_s}= show_header_for_report(attr) - if @report.years_visible? - Dossier.years(@report[:collect_year_count], @report[:name]).each do |year| %th.year= year - + = render :partial => 'reports/dossier', :collection => @dossiers diff --git a/app/views/dossiers/report.pdf.prawn b/app/views/dossiers/report.pdf.prawn index cb1c1fc2..0d5d51dd 100644 --- a/app/views/dossiers/report.pdf.prawn +++ b/app/views/dossiers/report.pdf.prawn @@ -8,7 +8,8 @@ prawn_document(:page_size => 'A4', # Gets the table data. items = @dossiers.map do |item| - columns = @report[:columns].collect do |column| + + column_names = @report[:column_names].collect do |column| pdf.make_cell(:content => show_column_for_report(item, column, true), :inline_format => true) end @@ -16,16 +17,16 @@ prawn_document(:page_size => 'A4', years = item.years_counts(@report[:collect_year_count], @report[:name]).collect do |year| pdf.make_cell(:content => number_with_delimiter(year[:count]), :align => :right) end - row = columns + years + row = column_names + years else - row = columns + row = column_names end pdf.row_styling(item, row) end # Use local variable as instance vars aren't accessible - columns = @report[:columns] + column_names = @report[:column_names] first_count = 0 headers.each do |header| @@ -60,13 +61,13 @@ prawn_document(:page_size => 'A4', columns(0..1).align = :left columns(0).align = :left # Right align document count - columns(columns.index(:document_count)).align = :right + columns(column_names.index('document_count')).align = :right if column_names.index('document_count').present? # Styles for year columns - year_columns = columns(columns.size..headers.first.size) + year_columns = columns(column_names.size..headers.first.size) year_columns.align = :right - # year_columns.width = 45 + # year_columns.width = 45 # Columns width - #column(0).width = 50 + # column(0).width = 50 end # Footer diff --git a/app/views/dossiers/show.html.haml b/app/views/dossiers/show.html.haml index c148e98e..4dc99266 100644 --- a/app/views/dossiers/show.html.haml +++ b/app/views/dossiers/show.html.haml @@ -46,7 +46,7 @@ %ul %li= link_to t_attr(:preorder_link), new_dossier_reservation_path(@dossier) - - split_decades(@dossier.numbers.present).each do |decade| + - split_decades(@dossier.numbers.documents_present).each do |decade| #document_counts.ce_table %table.document_counts %tr diff --git a/app/views/dossiers/show.pdf.prawn b/app/views/dossiers/show.pdf.prawn index 25314436..aba3e6b5 100644 --- a/app/views/dossiers/show.pdf.prawn +++ b/app/views/dossiers/show.pdf.prawn @@ -41,7 +41,7 @@ prawn_document(:page_size => 'A4', :filename => "#{@dossier.to_s}.pdf", :rendere pdf.text t_attr(:dossier_number_list), :size => 12 years = @dossier.years_counts(1) - split_decades(@dossier.numbers.present).each do |decade| + split_decades(@dossier.numbers.documents_present).each do |decade| header = decade.inject([]) do |out, year| out << year.period.to_s diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index bf9e167f..59771487 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -31,7 +31,7 @@ #mainmenu.mod_navigation.block %a.invisible{:href => "#skipNavigation3"} = t('katalog.application.skip_navigation') - = render_navigation(:context => :main, :expand_all => true) + = render_navigation(expand_all: true) %a#skipNavigation3.invisible{:name => "skipNavigation3"} #right diff --git a/app/views/reports/_dossier.html.haml b/app/views/reports/_dossier.html.haml index c1f4cc41..06e6922c 100644 --- a/app/views/reports/_dossier.html.haml +++ b/app/views/reports/_dossier.html.haml @@ -1,5 +1,5 @@ %tr[dossier]{:class => [cycle('odd', 'even'), (dossier.topic_type if dossier.is_a?(Topic))]} - - @report.columns.each do |attr| + - @report.column_names.each do |attr| %td{:class => attr.to_s}= show_column_for_report(dossier, attr) - if @report.years_visible? - dossier.years_counts(@report[:collect_year_count], @report[:name]).each do |count| diff --git a/app/views/reports/_form.html.haml b/app/views/reports/_form.html.haml index 565251b0..2be21c2b 100644 --- a/app/views/reports/_form.html.haml +++ b/app/views/reports/_form.html.haml @@ -5,20 +5,20 @@ = f.input :title = f.input :level, :as => :select, :collection => level_for_select = f.input :orientation, :as => :select, :collection => orientation_for_select, :include_blank => false - = f.input :columns, :as => :select, :collection => report_columns_for_select(@report), :multiple => :multiple, :include_blank => false, :hint => false + = f.input :column_names, :as => :select, :collection => report_column_names_for_select(@report), :multiple => :multiple, :include_blank => false, :hint => false = f.input :years_visible = f.input :collect_year_count, :hint => true = f.input :public - + = f.actions do = f.action(:submit) .contextual - .icon.icon-update= link_to_function t_action('refresh'), 'previewReport()' + .icon.icon-update= link_to t_action('refresh'), '#', id: 'preview_report' %h3#report-preview-title = t('crud.preview') - + #report-preview - - if @report.columns - = render 'reports/show' \ No newline at end of file + - if @report.column_names + = render 'reports/show' diff --git a/app/views/reports/_item.html.haml b/app/views/reports/_item.html.haml index 373917d3..832a08ac 100644 --- a/app/views/reports/_item.html.haml +++ b/app/views/reports/_item.html.haml @@ -2,9 +2,10 @@ %td = item.title %td - - item.columns.each do |column| - = t_attr(column, Dossier) - %br + - item.column_names.each do |column_name| + - if column_name.present? + = t_attr(column_name, Dossier) + %br %td - if item.public? = t_attr('public') diff --git a/app/views/reports/_show.html.haml b/app/views/reports/_show.html.haml index b5514896..e937afbe 100644 --- a/app/views/reports/_show.html.haml +++ b/app/views/reports/_show.html.haml @@ -2,15 +2,15 @@ #dossiers.ce_table.block{:class => @report[:orientation] } %table %tr.header - - if @report.columns - - @report.columns.each do |attr| + - if @report.column_names + - @report.column_names.each do |attr| %th{:class => attr.to_s}= show_header_for_report(attr) - years = Dossier.years(@report[:collect_year_count], @report[:name]) if @report.years_visible? - if years - years.each do |year| %th.year= year - - if @report[:columns] - - default_topics = [Topic.group.first, Topic.main.first, Topic.geo.first, Topic.detail.first, Dossier.dossier.first] + - if @report[:column_names] + - default_topics = [Topic.topic_group.first, Topic.main.first, Topic.geo.first, Topic.detail.first, Dossier.dossier.first] - topics = @report[:level] ? default_topics[0..@report[:level]-1] : default_topics = render :partial => 'reports/dossier', :collection => topics diff --git a/app/views/reservation_mailer/user_email.html.haml b/app/views/reservation_mailer/user_email.html.haml index b1ccd509..d156673d 100644 --- a/app/views/reservation_mailer/user_email.html.haml +++ b/app/views/reservation_mailer/user_email.html.haml @@ -1,3 +1,3 @@ %p Liebe/r #{@reservation.first_name} #{@reservation.last_name} %p Vielen Dank für Ihre Reservation. Sie können das Dossier #{@reservation.dossier}, #{@reservation.dossier_years} ab #{@reservation.pickup} 10.00 Uhr bei doku-zug.ch konsultieren. -%p Mit freundlichen Grüssen Team doku-zug.ch +%p Mit freundlichen Grüssen Team doku-zug.ch diff --git a/app/views/shared/_page_actions.html.haml b/app/views/shared/_page_actions.html.haml index 360ca2d8..3c500500 100644 --- a/app/views/shared/_page_actions.html.haml +++ b/app/views/shared/_page_actions.html.haml @@ -17,5 +17,5 @@ %li= link_to(t_action(:container_excel), url_for(params.merge(:format => :xls, :per_page => 'all', :excel_format => 'containers'))) - if controller_name == 'dossiers' && params[:search] && params[:search][:text] - = link_to_function t('katalog.show_keywords'), 'showKeyWords()', :id => 'show-key-words-link', :class => 'icon icon-plus-text', :title => t('katalog.show_keywords'), :style => (session[:hide_keywords] == true ? '' : 'display:none;') - = link_to_function t('katalog.hide_keywords'), 'hideKeyWords()', :id => 'hide-key-words-link', :class => 'icon icon-minus-text', :title => t('katalog.hide_keywords'), :style => (session[:hide_keywords] == true ? 'display:none;' : '') + = link_to t('katalog.show_keywords'), '#', :id => 'show-key-words-link', :class => 'icon icon-plus-text', :title => t('katalog.show_keywords'), :style => (session[:hide_keywords] == true ? '' : 'display:none;') + = link_to t('katalog.hide_keywords'), '#', :id => 'hide-key-words-link', :class => 'icon icon-minus-text', :title => t('katalog.hide_keywords'), :style => (session[:hide_keywords] == true ? 'display:none;' : '') diff --git a/app/views/shared/_topic_index.html.haml b/app/views/shared/_topic_index.html.haml index f920059d..57ddda3e 100644 --- a/app/views/shared/_topic_index.html.haml +++ b/app/views/shared/_topic_index.html.haml @@ -1,4 +1,4 @@ .ce_text#topic_index_scroller %p.topic_index %ul#topic_index - = render :partial => 'shared/topic', :collection => Topic.group.all + = render :partial => 'shared/topic', :collection => Topic.topic_group.all diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 00000000..7feb6a30 --- /dev/null +++ b/bin/rails @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..8017a027 --- /dev/null +++ b/bin/rake @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/spring b/bin/spring new file mode 100755 index 00000000..7f24d96f --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast +# It gets overwritten when you run the `spring binstub` command + +unless defined?(Spring) + require "rubygems" + require "bundler" + + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) + ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = "" + Gem.paths = ENV + + gem "spring", match[1] + require "spring/binstub" + end +end diff --git a/config.ru b/config.ru index 7f611e3d..5bc2a619 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run Katalog::Application +run Rails.application diff --git a/config/application.rb b/config/application.rb index 2937d6ad..4ecb39e0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,15 +1,17 @@ -# encoding: UTF-8 - require File.expand_path('../boot', __FILE__) -require 'rails/all' +# Pick the frameworks you want: +require 'active_model/railtie' +require 'active_record/railtie' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'action_view/railtie' +require 'sprockets/railtie' +# require "rails/test_unit/railtie" -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(assets: %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module Katalog class Application < Rails::Application @@ -17,50 +19,23 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # Add additional load paths for your own custom dirs - config.autoload_paths += ["#{config.root}/lib", "#{config.root}/app/models/ckeditor", "#{config.root}/app/prawn"] - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. config.time_zone = 'Bern' - config.i18n.enforce_available_locales = true - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - config.i18n.fallbacks = [:'de-CH', :de] + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = 'de-CH' + config.i18n.fallbacks = [:'de-CH', :de] - # Configure generators values. Many other options are available, be sure to check the documentation. - # config.generators do |g| - # g.orm :active_record - # g.template_engine :erb - # g.test_framework :test_unit, :fixture => true - # end - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = 'utf-8' - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.1' + # Custom directories with classes and modules you want to be autoloadable. + config.autoload_paths += %W(#{config.root}/lib) - # List of assets to precompile - config.assets.precompile += %w( ie6.css katalog_internal.css print.css) - config.assets.precompile += Ckeditor.assets + # Add fonts folder to assets path + config.assets.paths << Rails.root.join('app', 'assets', 'fonts') + config.assets.paths << Rails.root.join('app', 'assets', 'icons') - # Allow target in links, used in description - config.action_view.sanitized_allowed_attributes = ['target'] + # Use sass files for stylesheets + config.sass.preferred_syntax = :sass end end diff --git a/config/application.yml.example b/config/application.yml.example index dc5a5a95..fabc90ac 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -6,10 +6,7 @@ defaults: &defaults airbrake: api_key: mail: - reservation: - recipient: to@example.com - sender: from@example.com - internal_sender: internal_from@example.com + sender: info@example.com development: <<: *defaults diff --git a/config/boot.rb b/config/boot.rb index f3d8a22e..5e5f0c1f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,15 +1,4 @@ -# encoding: UTF-8 - -require 'rubygems' - # Set up gems listed in the Gemfile. -gemfile = File.expand_path('../../Gemfile', __FILE__) -begin - ENV['BUNDLE_GEMFILE'] = gemfile - require 'bundler' - Bundler.setup -rescue Bundler::GemNotFound => e - STDERR.puts e.message - STDERR.puts 'Try running `bundle install`.' - exit! -end if File.exist?(gemfile) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 00000000..29b22345 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,53 @@ +# MySQL. Versions 5.0+ are recommended. +# +# Install the MYSQL driver +# gem install mysql2 +# +# Ensure the MySQL gem is defined in your Gemfile +# gem 'mysql2' +# +# And be sure to use new-style password hashing: +# http://dev.mysql.com/doc/refman/5.0/en/old-client.html +# +default: &default + adapter: mysql2 + encoding: utf8 + pool: 5 + username: root + password: + +development: + <<: *default + database: katalog_development + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: katalog_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: katalog_production + username: katalog + password: <%= ENV['KATALOG_DATABASE_PASSWORD'] %> diff --git a/config/database.yml.example b/config/database.yml.example deleted file mode 100644 index 76153020..00000000 --- a/config/database.yml.example +++ /dev/null @@ -1,41 +0,0 @@ -# Database configuration -# ====================== -# This file can be use as a template for the database.yml file. -# -# We're currently not supporting SQLite as we're using Sphinx for -# freetext search. -# -# You need to setup the databases and adapt this file: -# -# 1. create the database and grant access -# 2. update host, username and password settings in the 'Common -# settings' section - -# Common settings -# =============== -# MySQL -mysql: &mysql - adapter: mysql2 - encoding: utf8 - pool: 5 - timeout: 5000 - host: localhost - -# Environments -# ============ -development: - <<: *mysql - database: katalog_development - username: katalog - password: - -test: - <<: *mysql - database: katalog_test - username: root - -production: - <<: *mysql - database: katalog_production - username: katalog - password: diff --git a/config/deploy.rb b/config/deploy.rb index 97d0e46d..8569e68f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # Application set :application, 'katalog' set :repository, 'https://github.com/CyTeam/katalog.git' diff --git a/config/deploy/database.yml.erb b/config/deploy/database.yml.erb deleted file mode 100644 index 78cc192d..00000000 --- a/config/deploy/database.yml.erb +++ /dev/null @@ -1,33 +0,0 @@ -# Database configuration -# ====================== -# This file can be use as a template for the database.yml file. -# -# If you're using the SQLite3 file-based database, all you have -# to do is copy this file to database.yml. -# -# While you may use the SQLite3 database, it has some issues -# with date handling. It's sometimes giving strange amounts -# in account views for opening balance etc. -# -# For production environments MySQL is a better fit. In this -# case you need to setup the databases and adapt this file: -# -# 1. create the database and grant access -# 3. set username and password and possibly host settings in -# the environment config. - -# Common settings -# =============== -# MySQL -mysql: &mysql - adapter: mysql2 - encoding: utf8 - -# Environments -# ============ -<%= rails_env %>: - <<: *mysql - host: '<%= db_host %>' - database: '<%= db_database %>' - username: '<%= db_username %>' - password: '<%= db_password %>' diff --git a/config/environment.rb b/config/environment.rb index 74ada250..ee8d90dc 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,7 +1,5 @@ -# encoding: UTF-8 - -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application -Katalog::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 966783f3..ddf0e90c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,43 +1,37 @@ -# encoding: UTF-8 - -Katalog::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true - config.action_controller.perform_caching = true + config.action_controller.perform_caching = false - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Print deprecation notices to the Rails logger + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - - # Do not compress assets - config.assets.compress = false + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Expands the lines which load the assets + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. config.assets.debug = true - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true - # Mail configuration - config.action_mailer.default_url_options = { host: 'localhost:3000' } - config.action_mailer.delivery_method = :sendmail + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/fallback.rb b/config/environments/fallback.rb deleted file mode 100644 index 854b657e..00000000 --- a/config/environments/fallback.rb +++ /dev/null @@ -1,67 +0,0 @@ -# encoding: UTF-8 - -Katalog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The production environment is meant for finished, "live" apps. - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false - - # Compress JavaScripts and CSS - config.assets.compress = true - - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false - - # Generate digests for assets URLs - config.assets.digest = true - - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and javascripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify - - # Mail configuration - config.action_mailer.default_url_options = { host: 'doku-zug.cyt.ch' } - config.action_mailer.delivery_method = :sendmail -end diff --git a/config/environments/production.rb b/config/environments/production.rb index 854b657e..40c6589c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,67 +1,82 @@ -# encoding: UTF-8 +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. -Katalog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The production environment is meant for finished, "live" apps. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = false - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Don't fallback to assets pipeline if a precompiled asset is missed + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs + # Generate digests for assets URLs. config.assets.digest = true - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - # config.log_level = :debug + # Set to :debug to see everything in the log. + config.log_level = :info - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] - # Use a different cache store in production + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and javascripts from an asset server + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) + # Mail configuration + config.action_mailer.default_url_options = { host: 'katalog.doku-zug.ch' } + config.action_mailer.delivery_method = :sendmail - # Disable delivery errors, bad email addresses will be ignored + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Mail configuration - config.action_mailer.default_url_options = { host: 'doku-zug.cyt.ch' } - config.action_mailer.delivery_method = :sendmail + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/staging.rb b/config/environments/staging.rb deleted file mode 100644 index da5d8c0d..00000000 --- a/config/environments/staging.rb +++ /dev/null @@ -1,61 +0,0 @@ -# encoding: UTF-8 - -Katalog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.action_controller.perform_caching = true - - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false - - # Compress JavaScripts and CSS - config.assets.compress = true - - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false - - # Generate digests for assets URLs - config.assets.digest = true - - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and javascripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify -end diff --git a/config/environments/test.rb b/config/environments/test.rb index bea25502..053f5b66 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,40 +1,39 @@ -# encoding: UTF-8 - -Katalog::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that + # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Print deprecation notices to the stderr + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb index 2d143a99..ea7dd142 100644 --- a/config/initializers/acts_as_taggable_on.rb +++ b/config/initializers/acts_as_taggable_on.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # Use newline as delimiter ActsAsTaggableOn.delimiter = "\n" ActsAsTaggableOn.strict_case_match = true diff --git a/config/initializers/acts_as_taggable_on_papertrail_patch.rb b/config/initializers/acts_as_taggable_on_papertrail_patch.rb new file mode 100644 index 00000000..6e525760 --- /dev/null +++ b/config/initializers/acts_as_taggable_on_papertrail_patch.rb @@ -0,0 +1,61 @@ +# Make acts-as-taggable-on work again with papertrail +# Changed the line with the PATCH statement +module PaperTrail + module VersionConcern + extend ::ActiveSupport::Concern + def reify(options = {}) + return nil if object.nil? + + without_identity_map do + options[:has_one] = 3 if options[:has_one] == true + options.reverse_merge! :has_one => false + + attrs = self.class.object_col_is_json? ? object : PaperTrail.serializer.load(object) + + # Normally a polymorphic belongs_to relationship allows us + # to get the object we belong to by calling, in this case, + # `item`. However this returns nil if `item` has been + # destroyed, and we need to be able to retrieve destroyed + # objects. + # + # In this situation we constantize the `item_type` to get hold of + # the class...except when the stored object's attributes + # include a `type` key. If this is the case, the object + # we belong to is using single table inheritance and the + # `item_type` will be the base class, not the actual subclass. + # If `type` is present but empty, the class is the base class. + + if item && options[:dup] != true + model = item + # Look for attributes that exist in the model and not in this version. These attributes should be set to nil. + (model.attribute_names - attrs.keys).each { |k| attrs[k] = nil } + else + inheritance_column_name = item_type.constantize.inheritance_column + class_name = attrs[inheritance_column_name].blank? ? item_type : attrs[inheritance_column_name] + klass = class_name.constantize + model = klass.new + end + + model.class.unserialize_attributes_for_paper_trail attrs + + # Set all the attributes in this version on the model + attrs.each do |k, v| + if model.has_attribute?(k) + # PATCH use send for keyword_list assignment + model.send("#{k}=", v) + else + logger.warn "Attribute #{k} does not exist on #{item_type} (Version id: #{id})." + end + end + + model.send "#{model.class.version_association_name}=", self + + unless options[:has_one] == false + reify_has_ones model, options[:has_one] + end + + model + end + end + end +end diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb deleted file mode 100644 index 5de2ce87..00000000 --- a/config/initializers/airbrake.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Airbrake configuration -begin - if Object.const_defined?(Airbrake) && Settings['airbrake'] - Airbrake.configure do |config| - config.api_key = Settings.airbrake.api_key - end - end -rescue -end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..21912428 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +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( ie6.css katalog_internal.css print.css ) +Rails.application.config.assets.precompile += Ckeditor.assets diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index b0ae6ea4..59385cdf 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/ckeditor.rb b/config/initializers/ckeditor.rb deleted file mode 100644 index 3b40b096..00000000 --- a/config/initializers/ckeditor.rb +++ /dev/null @@ -1,56 +0,0 @@ -# encoding: UTF-8 - -# Use this hook to configure ckeditor -if Object.const_defined?('Ckeditor') - Ckeditor.setup do |_config| - # The file_post_name allows you to set the value name used to post the file. - # This is not related to the file name. The default value is 'data'. - # For maximum compatibility it is recommended that the default value is used. - # config.swf_file_post_name = "data" - - # A text description that is displayed to the user in the File Browser dialog. - # config.swf_file_types_description = "Files" - - # The file_types setting accepts a semi-colon separated list of file extensions - # that are allowed to be selected by the user. Use '*.*' to allow all file types. - # config.swf_file_types = "*.doc;*.wpd;*.pdf;*.swf;*.xls" - - # The file_size_limit setting defines the maximum allowed size of a file to be uploaded. - # This setting accepts a value and unit. Valid units are B, KB, MB and GB. - # If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited. - # Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server. - # config.swf_file_size_limit = "10 MB" - - # Defines the number of files allowed to be uploaded by SWFUpload. - # This setting also sets the upper bound of the file_queue_limit setting. - # Once the user has uploaded or queued the maximum number of files she will - # no longer be able to queue additional files. The value of 0 (zero) is interpreted as unlimited. - # Only successful uploads (uploads the trigger the uploadSuccess event) are counted toward the upload limit. - # The setStats function can be used to modify the number of successful uploads. - # Note: This value is not tracked across pages and is reset when a page is refreshed. - # File quotas should be managed by the web server. - # config.swf_file_upload_limit = 5 - - # The same as for downloads files, only to upload images - # config.swf_image_file_types_description = "Images" - # config.swf_image_file_types = "*.jpg;*.jpeg;*.png;*.gif" - # config.swf_image_file_size_limit = "5 MB" - # config.swf_image_file_upload_limit = 10 - - # Path for view all uploaded files - # config.file_manager_uri = "/ckeditor/files" - - # Path for upload files process - # config.file_manager_upload_uri = "/ckeditor/create/file" - - # Path for view all uploaded images - # config.file_manager_image_uri = "/ckeditor/images" - - # Path for upload images process - # config.file_manager_image_upload_uri = "/ckeditor/create/image" - - # Model's names witch processing in ckeditor_controller - # config.file_manager_image_model = "Ckeditor::Picture" - # config.file_manager_file_model = "Ckeditor::AttachmentFile" - end -end diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7a06a89f --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/config/initializers/date.rb b/config/initializers/date.rb deleted file mode 100644 index aa752150..00000000 --- a/config/initializers/date.rb +++ /dev/null @@ -1,11 +0,0 @@ -# encoding: UTF-8 - -# Monkey patch from https://rails.lighthouseapp.com/projects/8994/tickets/340-yaml-activerecord-serialize-and-date-formats-problem -# is used for paper trail -class Date # reopen Date class - def to_yaml(opts = {}) # modeled after yaml/rubytypes.rb in std library - YAML.quick_emit(self, opts) do |out| - out.scalar('tag:yaml.org,2002:timestamp', to_s(:db), :plain) - end - end -end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 6f6c1d7e..44bd4ef1 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,72 +1,159 @@ -# encoding: UTF-8 - -# Use this hook to configure devise mailer, warden hooks and so forth. The first -# four configuration values can also be set straight in your models. +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + config.secret_key = 'b1c990981d991f801849fbdf90dcbd4e658442ab475f836e170fa870eb00ca6ba3cdc54ef968711984bf5ff109408ff49060091574893788e7addc773391f889' + # ==> Mailer Configuration - # Configure the e-mail address which will be shown in DeviseMailer. - config.mailer_sender = Settings.mail.reservation.sender + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = Settings.mail.sender # Configure the class responsible to send e-mails. - # config.mailer = "Devise::Mailer" + # config.mailer = 'Devise::Mailer' # ==> ORM configuration - # Load and configure the ORM. Supports :active_record (default), :mongoid - # (bson_ext recommended) and :data_mapper (experimental). + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. require 'devise/orm/active_record' # ==> Configuration for any authentication mechanism - # Configure which keys are used when authenticating an user. By default is + # Configure which keys are used when authenticating a user. The default is # just :email. You can configure it to use [:username, :subdomain], so for - # authenticating an user, both parameters are required. Remember that those + # authenticating a user, both parameters are required. Remember that those # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. - # config.authentication_keys = [ :email ] + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. config.authentication_keys = [:login] + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. # config.params_authenticatable = true - # Tell if authentication through HTTP Basic Auth is enabled. True by default. - # config.http_authenticatable = true + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true - # The realm used in Http Basic Authentication + # The realm used in Http Basic Authentication. 'Application' by default. config.http_authentication_realm = 'doku-zug.ch Katalog' + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. - config.stretches = 10 + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # encryptor), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. config.pepper = '8a70a9054cc3496f8dc038f60442b91935c57ed4b62018f835649dc156313da65cb01d27cccabf4ec39183df55d44f2cc067ad993964873b123c68299707d5ac' - config.secret_key = 'b1c990981d991f801849fbdf90dcbd4e658442ab475f836e170fa870eb00ca6ba3cdc54ef968711984bf5ff109408ff49060091574893788e7addc773391f889' - # ==> Configuration for :confirmable - # The time you want to give your user to confirm his account. During this time - # he will be able to access your application without confirming. Default is nil. - # When confirm_within is zero, the user won't be able to sign in without confirming. - # You can use this to let your user access some features of your application - # without confirming the account, but blocking it after a certain period - # (ie 2 days). - # config.confirm_within = 2.days + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + # ==> Configuration for :validatable - # Range for password length - # config.password_length = 6..20 + # Range for password length. + config.password_length = 8..128 - # Regex to use to validate the email address - # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this - # time the user will be asked for credentials again. - # config.timeout_in = 10.minutes + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # If true, expires auth token on session timeout. + # config.expire_auth_token_on_timeout = false # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. @@ -74,6 +161,9 @@ # :none = No lock strategy. You should handle locking by yourself. # config.lock_strategy = :failed_attempts + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email # :time = Re-enables login after a certain amount of time (see :unlock_in below) @@ -88,47 +178,82 @@ # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour - # ==> Configuration for :token_authenticatable - # Defines name of the authentication token params key - # config.token_authentication_key = :auth_token + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # config.encryptor = :sha512 # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for - # "sessions/users/new". It's turned off by default because it's slower if you + # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. - # config.scoped_views = true - - # By default, devise detects the role accessed based on the url. So whenever - # accessing "/users/sign_in", it knows you are accessing an User. This makes - # routes as "/sign_in" not possible, unless you tell Devise to use the default - # scope, setting true below. - # Note that devise does not generate default routes. You also have to - # specify them in config/routes.rb - # config.use_default_scope = true - - # Configure the default scope used by Devise. By default it's the first devise - # role declared in your routes. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). # config.default_scope = :user + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + # ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. + # # If you have any extra navigational formats, like :iphone or :mobile, you - # should add them to the navigational formats lists. Default is [:html] - # config.navigational_formats = [:html, :iphone] + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' # ==> Warden configuration - # If you want to use other strategies, that are not (yet) supported by Devise, - # you can configure them inside the config.warden block. The example below - # allows you to setup OAuth, using http://github.com/roman/warden_oauth + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| - # manager.oauth(:twitter) do |twitter| - # twitter.consumer_secret =- # twitter.consumer_key = - # twitter.options :site => 'http://twitter.com' - # end - # manager.default_strategies(:scope => :user).unshift :twitter_oauth + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using omniauth, Devise cannot automatically set Omniauth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' end diff --git a/config/initializers/email.rb b/config/initializers/email.rb deleted file mode 100644 index e3d2cbd3..00000000 --- a/config/initializers/email.rb +++ /dev/null @@ -1,3 +0,0 @@ -ActionMailer::Base.delivery_method = :sendmail -RESERVATION_EMAIL_RECIPIENT = Settings.mail.reservation.recipient -RESERVATION_EMAIL_SENDER = Settings.mail.reservation.sender diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index 86f92f38..59b1f3e6 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -1,56 +1,108 @@ -# encoding: UTF-8 - -# Set the default text field size when input is a string. Default is 50. -# Formtastic::SemanticFormBuilder.default_text_field_size = 50 +# Set the default text field size when input is a string. Default is nil. +# Formtastic::FormBuilder.default_text_field_size = 50 # Set the default text area height when input is a text. Default is 20. -# Formtastic::SemanticFormBuilder.default_text_area_height = 5 +# Formtastic::FormBuilder.default_text_area_height = 5 + +# Set the default text area width when input is a text. Default is nil. +# Formtastic::FormBuilder.default_text_area_width = 50 # Should all fields be considered "required" by default? -# Defaults to true, see ValidationReflection notes below. +# Defaults to true. Formtastic::FormBuilder.all_fields_required_by_default = false # Should select fields have a blank option/prompt by default? # Defaults to true. -# Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true +# Formtastic::FormBuilder.include_blank_for_select_by_default = true # Set the string that will be appended to the labels/fieldsets which are required # It accepts string or procs and the default is a localized version of # '*'. In other words, if you configure formtastic.required # in your locale, it will replace the abbr title properly. But if you don't want to use # abbr tag, you can simply give a string as below -# Formtastic::SemanticFormBuilder.required_string = "(required)" +# Formtastic::FormBuilder.required_string = "(required)" # Set the string that will be appended to the labels/fieldsets which are optional # Defaults to an empty string ("") and also accepts procs (see required_string above) -# Formtastic::SemanticFormBuilder.optional_string = "(optional)" +# Formtastic::FormBuilder.optional_string = "(optional)" # Set the way inline errors will be displayed. -# Defaults to :sentence, valid options are :sentence, :list and :none -# Formtastic::SemanticFormBuilder.inline_errors = :sentence +# Defaults to :sentence, valid options are :sentence, :list, :first and :none +# Formtastic::FormBuilder.inline_errors = :sentence +# Formtastic uses the following classes as default for hints, inline_errors and error list + +# If you override the class here, please ensure to override it in your stylesheets as well +# Formtastic::FormBuilder.default_hint_class = "inline-hints" +# Formtastic::FormBuilder.default_inline_error_class = "inline-errors" +# Formtastic::FormBuilder.default_error_list_class = "errors" # Set the method to call on label text to transform or format it for human-friendly -# reading when formtastic is user without object. Defaults to :humanize. -# Formtastic::SemanticFormBuilder.label_str_method = :humanize +# reading when formtastic is used without object. Defaults to :humanize. +# Formtastic::FormBuilder.label_str_method = :humanize # Set the array of methods to try calling on parent objects in :select and :radio inputs # for the text inside each @