From 688680d5488e385ca35cd7887de240224224c62d Mon Sep 17 00:00:00 2001 From: Matus Kmit Date: Wed, 9 Apr 2014 17:09:03 +0200 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit bb4ab3d34745dc9e399dadddc1fddf7999322e48 Author: Matus Kmit Date: Wed Apr 9 16:54:31 2014 +0200 [BUGFIX] asset_path for logo on splash screen commit d62f50d5f9f8c0cc8c4c188bc61b0b893c572fff Author: Matus Kmit Date: Wed Apr 9 15:58:57 2014 +0200 [DOMINA] updated feature_tasks.yml commit 5f19a4fe81b623df847df4db6f1367bdbc0ab7f9 Author: Ramón Cahenzli Date: Wed Apr 9 15:34:13 2014 +0200 Make sure the tmp directory exists. commit 5782e46a5e12e0b3a6027155f036ee25ae4c523c Author: nadjaweisskopf Date: Wed Apr 9 15:09:59 2014 +0200 [#69177404] Software-Inventarliste commit 35bb973f31a9bb81b78725148907a575f9dd9b0d Author: nadjaweisskopf Date: Wed Apr 9 14:51:26 2014 +0200 [#69176406] SW-erstellen commit 25e959cde5ee15ecc280bbf4a52572d701a1921e Author: Matus Kmit Date: Tue Apr 8 16:39:55 2014 +0200 [FIX] remove duplicate ids from ajax params commit f9059de80ec40dd6d41ffaf1dd197792400c8a5b Author: Matus Kmit Date: Tue Apr 8 15:36:57 2014 +0200 [TEST] remove binding.pry commit b37af10311085ce738e120cc10bc348f31d00fad Author: Matus Kmit Date: Tue Apr 8 14:45:00 2014 +0200 [DOMINA] updated diverse_features.yml commit 157b9395badb308212c7e1784337d38f1eb2e372 Author: Matus Kmit Date: Tue Apr 8 14:40:32 2014 +0200 [FIX] localize suspended_until only if present commit c3f377cdbd66790a1d2c7a3247ec3c2ec621cb79 Author: Matus Kmit Date: Tue Apr 8 13:33:46 2014 +0200 [DOMINA] add space in commands commit c5bdea743fe6b76d3f312a404053834701f2e0c8 Author: Matus Kmit Date: Tue Apr 8 13:32:35 2014 +0200 [RAKE FIX] generate structure with views with db drop create and migrate commit 404e3f881b66b06e8a79c7a509999d4799c1042d Author: Matus Kmit Date: Tue Apr 8 12:03:19 2014 +0200 update structure_with_views.sql commit d47d1ffaa718781beb8e92c6d1c4a888fa69431e Author: Matus Kmit Date: Tue Apr 8 11:30:55 2014 +0200 [FIX] asset_path for logo commit a007d531dc73e9d5575b1e2afdd6830fdbf56b76 Author: Ramón Cahenzli Date: Tue Apr 8 10:45:54 2014 +0200 Give a temp dir that makes sense. commit 1c33f3c0051c64df90d241c59bfa6e514638278e Author: Matus Kmit Date: Mon Apr 7 17:05:02 2014 +0200 [#68170636] hslu auth controller: don't give access rights to all pools automatically commit f08bfe227bc7c0eb0eb6fc77953f70ebcd6cbce0 Author: Matus Kmit Date: Mon Apr 7 17:03:07 2014 +0200 fix date format for suspended until commit 586057b9495bdd09571845f1674589597d5abfb1 Author: Matus Kmit Date: Mon Apr 7 16:44:15 2014 +0200 fix translation for automatic access commit a7ba0a5f2e7a0d72269fb7d057c304af4528efbb Author: Matus Kmit Date: Mon Apr 7 16:40:37 2014 +0200 [#68170636] rspec test for ldap controller commit c206f811f2676c4ee4bd077e492348523b4a802c Author: Matus Kmit Date: Mon Apr 7 14:14:46 2014 +0200 [#64817854] show settings instance address in contract commit 485347e9946075072c7d653735145a5696f16882 Author: Matus Kmit Date: Sun Apr 6 23:23:26 2014 +0200 #68170636 fix wrong indentation commit 01d4f7bb8f48395886c0eab98f686ed65512852c Author: Matus Kmit Date: Sun Apr 6 22:59:14 2014 +0200 #68170636 merging fs_automatic_access_ip for demo commit 6d302f1399b184a91164a742dae4decefeed9337 Author: Matus Kmit Date: Fri Apr 4 16:43:01 2014 +0200 [DOMINA] make a new commit in order to bypass the unique execution id constraint commit 7fde00ab66acebdbdd43305edbf18716886a3d21 Author: Matus Kmit Date: Fri Apr 4 16:32:20 2014 +0200 [FEATURE #62691666] automatic suspension for late take backs commit ab3010f0514d7c7698094a5ec015859b3e0b8e73 Author: Matus Kmit Date: Wed Apr 2 16:31:38 2014 +0200 [DOMINA] updated rspec_tasks.yml commit cdd9eaf5285f0ba7278efeb72e1e04fdfbfe0528 Author: Matus Kmit Date: Wed Apr 2 14:57:39 2014 +0200 remove binding.pry commit b6fb261fe78ccfd89850e7ef5de6e589a5e469c2 Author: Matus Kmit Date: Wed Apr 2 14:38:55 2014 +0200 [#33044661] test implemented commit 58413aa84e19c98efd27e9b02a406475c8c3ae52 Author: Matus Kmit Date: Wed Apr 2 14:13:07 2014 +0200 [#33044661] remove trailing comma and white space from user address in contract commit 4353fbfe4404efaac890c9c5eb5542e452dd9247 Author: Franco Sellitto Date: Wed Apr 2 12:25:28 2014 +0200 upgrading to Rails 4.0.4, upgrading gems and fixing ci Squashed commit of the following: commit a6749d983cd5ddcaf96b953b60c08d0a2cab74f8 Author: Franco Sellitto Date: Wed Apr 2 12:24:54 2014 +0200 [FIX CI] commit 8e975bba8ed0c25d6e89c51dd7b7f69f8a228ad6 Author: Franco Sellitto Date: Tue Apr 1 16:54:09 2014 +0200 [FIX CI] capybara dom commit d753fe6a80dc8915975219539762e3ba64b8ddfa Author: Franco Sellitto Date: Tue Apr 1 16:49:26 2014 +0200 [FIX CI] jump to the next availability change date commit 3a5b6f86afa86ba414057f2d2726aae190cbb6d2 Author: Franco Sellitto Date: Tue Apr 1 14:43:40 2014 +0200 downgrade font-awesome-rails gem and removing thin gem commit 482086dfb19e790ad51eedb5399aae308ed57ec3 Author: Franco Sellitto Date: Mon Mar 31 18:39:36 2014 +0200 downgrade jquery-rails gem commit d3e74d5cfae2284cefdc82fad1e79e2991cc4c17 Author: Franco Sellitto Date: Mon Mar 31 18:31:47 2014 +0200 removing deprecation warning commit ce99fabd9fb8117d2eb91263f8aac3d358bd76a0 Author: Franco Sellitto Date: Mon Mar 31 18:21:15 2014 +0200 downgrade jquery-rails gem commit fcccfc2a55887ada9ecbc45fe1f67dfde5e558eb Author: Franco Sellitto Date: Mon Mar 31 18:13:34 2014 +0200 downgrade paperclip gem commit 15f904f469a9473770d76adbdea5c85387b0f5a3 Author: Franco Sellitto Date: Mon Mar 31 18:03:14 2014 +0200 upgrading to Rails 4.0.4 and upgrading gems commit bc256c2a587db194dc12304b0edc40c9aed4d5b2 Author: Franco Sellitto Date: Mon Mar 31 17:24:31 2014 +0200 [BUGFIX] upgrading to Rails 4: asset precompile for simile timeline commit 331cfff107041b8c49154cbc9b9da4df692ce9f7 Author: Matus Kmit Date: Mon Mar 31 15:37:09 2014 +0200 Revert "[BUGFIX] proper precompilation of timeline assets" This reverts commit 2455ff9b4b80e1e0c6f5c1eb410ba947cad94ede. commit 2455ff9b4b80e1e0c6f5c1eb410ba947cad94ede Author: Matus Kmit Date: Mon Mar 31 15:09:01 2014 +0200 [BUGFIX] proper precompilation of timeline assets commit 4ea6831c728568c72fcbbc36b056b5f60c6b27d9 Author: Ramón Cahenzli Date: Thu Mar 27 16:34:42 2014 +0100 Making LDAP config path configurable again. commit 3ae9a5b93882d8aefda081bd80e5d9ddcd3d4992 Author: Ramón Cahenzli Date: Thu Mar 27 10:40:42 2014 +0100 More solid error messages, hardcoding LDAP config file location. commit 4263332404f2dbe21677653f8b702ce516478981 Author: Ramón Cahenzli Date: Wed Mar 26 15:22:41 2014 +0100 Add secret key base. commit c18400ccf246f3f0028979b9a8d1c6ac0ebad8a7 Author: Ramón Cahenzli Date: Wed Mar 26 14:53:45 2014 +0100 Cleaning up some dead code. commit 4e240be793fe4fe39bfa7b1a2fdd24508205827c Author: Ramón Cahenzli Date: Wed Mar 26 14:50:16 2014 +0100 Working generic LDAP adapter. commit 743a6a63066738ede00a8282ef8eaa882a53189e Author: Ramón Cahenzli Date: Wed Mar 26 13:56:28 2014 +0100 Generic LDAP controller works, TODO: admin group membership. commit 8acd71dedc6140bb19f9612c60e26322577534ca Author: Ramón Cahenzli Date: Tue Mar 25 17:32:11 2014 +0100 Forgot that file. commit feab77bb3a0553e15b8365428dbc16f84ec778b8 Author: Ramón Cahenzli Date: Tue Mar 25 17:14:40 2014 +0100 No need to list port twice. commit 6fe1d8c6d83570454b7e6e028ffaf75ed798da72 Author: Ramón Cahenzli Date: Tue Mar 25 17:06:57 2014 +0100 LDAP, wheeee. commit 41c5b1db4ee8468d888bbc9bcc682da00d4b817e Author: Matus Kmit Date: Fri Mar 28 16:48:34 2014 +0100 [TEST] make model factory use better Faker names commit 63db7c05c6108efc43649ebec4d6684af6512516 Author: Ramón Cahenzli Date: Fri Mar 28 11:05:19 2014 +0100 Drop Faker in production. commit f5a16e475b0d5f82b1b61802f422877c145e90c8 Author: Ramón Cahenzli Date: Fri Mar 28 10:13:43 2014 +0100 Removing deprecation warning about i18n. commit 0d35e42091bd1ce2bc9e447a9db019065e94a8ed Author: Ramón Cahenzli Date: Thu Mar 27 17:49:53 2014 +0100 Deploy using Ruby 2.1.0 in production. commit 30605a9278a29d013468a3809df634d8c2e1453c Author: Matus Kmit Date: Thu Mar 27 15:45:36 2014 +0100 [FIX CI] features/examples/geraetepark_grundinformationen3.feature:30 @upcoming commit d120ba0bfbf626f3ad01f8ae6446fa17f2dccf2a Author: Ramón Cahenzli Date: Thu Mar 27 15:42:10 2014 +0100 Config linking: Damn, you so stupid. commit a743f9523e328cc86bf222e37c7255d88a234044 Author: Matus Kmit Date: Thu Mar 27 13:32:33 2014 +0100 [DEPRECATION] update secret token commit e642a1d71880717621b8f43d101272656808973b Author: Matus Kmit Date: Thu Mar 27 12:44:51 2014 +0100 [FIX CI] comment out not yet implemented steps commit 10824a475c4cc3c59a1b547224592d5334dc0438 Author: Matus Kmit Date: Thu Mar 27 12:18:28 2014 +0100 [DEPRECATION] act-as-dag gem from github with rails4 patches commit ce8c7eb075c86821d15fe74a5287f31890e4bab9 Author: Matus Kmit Date: Thu Mar 27 10:32:09 2014 +0100 [DEPRECATION] change count(distinct: true) to distinct.count commit 2bc1807501e53ec954576a7b84acd97ba102ef49 Author: Matus Kmit Date: Thu Mar 27 10:08:36 2014 +0100 [DEPRACATION] default scope uses block instead of lambda commit 8c055b91e15c1f4f375fa2509223f9283b1c3855 Author: Matus Kmit Date: Wed Mar 26 18:04:27 2014 +0100 [#64817854] partial test implementation commit dbae923181f256fbc4554c7b67e6edd92fde6697 Author: Ramón Cahenzli Date: Wed Mar 26 15:48:22 2014 +0100 That option shouldn't be necessary anymore. commit b990cb148db26ac2c8fad0e5bf42915c1e037304 Author: Matus Kmit Date: Wed Mar 26 14:11:54 2014 +0100 [#68186532] adjusted error message --- Gemfile | 37 +- Gemfile.lock | 157 ++--- LICENSE | 2 +- .../contracts_index_controller.coffee | 4 +- app/assets/stylesheets/application.sass | 2 +- .../hslu_authentication_controller.rb | 4 - .../ldap_authentication_controller.rb | 231 +++++-- .../shibboleth_authentication_controller.rb | 11 +- .../authenticator/zhdk_controller.rb | 13 +- app/controllers/manage/users_controller.rb | 17 +- app/models/access_right.rb | 2 + app/models/contract.rb | 2 +- app/models/inventory_pool.rb | 1 + app/models/language.rb | 2 +- app/models/location.rb | 2 +- app/models/user.rb | 51 +- app/models/visit.rb | 1 + app/views/application/_logo.html.haml | 4 +- app/views/application/_topbar.html.haml | 4 +- app/views/documents/_customer.html.haml | 2 +- app/views/documents/_inventory_pool.html.haml | 4 +- .../manage/inventory_pools/_form.html.haml | 22 + .../manage/users/_access_details.html.haml | 3 +- config/LDAP.yml.example | 41 +- config/application.rb | 7 + config/deploy/demo-new.rb | 1 + config/deploy/production.rb | 4 +- config/deploy/recipes/bundle_install.rb | 2 +- config/deploy/recipes/link_config.rb | 12 +- config/deploy/staging.rb | 3 +- config/initializers/secret_token.rb | 1 + ...automatic_suspension_to_inventory_pools.rb | 6 + ..._add_automatic_access_to_inventory_pool.rb | 15 + db/structure.sql | 562 +++++------------- db/structure_with_views.sql | 7 +- domina/execution/feature_tasks.yml | 12 +- .../execution/features/diverse_features.yml | 106 +++- domina/execution/rspec_tasks.yml | 4 + domina/lib/domina/database.rb | 6 +- factories/inventory_pool_factory.rb | 3 +- factories/model_factory.rb | 8 +- features/automatische_sperrung.feature | 11 - features/examples/Software-erfassen.feature | 34 ++ .../examples/benutzerverwaltung10.feature | 4 +- .../examples/benutzerverwaltung11.feature | 2 +- .../examples/benutzerverwaltung12.feature | 2 +- .../examples/benutzerverwaltung13.feature | 2 +- .../examples/benutzerverwaltung14.feature | 2 +- features/examples/benutzerverwaltung4.feature | 4 +- features/examples/benutzerverwaltung5.feature | 8 +- features/examples/benutzerverwaltung6.feature | 2 +- features/examples/benutzerverwaltung7.feature | 2 +- features/examples/benutzerverwaltung8.feature | 4 +- features/examples/benutzerverwaltung9.feature | 2 +- .../geraetepark_grundinformationen.feature | 45 +- .../geraetepark_grundinformationen3.feature | 6 +- features/examples/inventar.feature | 1 + features/examples/vertrag6.feature | 10 +- features/personas/petra.rb | 2 +- features/personas/pius.rb | 23 +- features/personas/ramon.rb | 4 +- .../automatischer_email_versand_steps.rb.rb | 4 +- .../examples/ausleihe_steps.rb | 1 + .../examples/benutzerverwaltung_steps.rb | 10 +- .../examples/bestellungen_steps.rb | 4 +- .../geraetepark_grundinformationen_steps.rb | 112 ++++ .../examples/gruppen_steps.rb | 2 +- .../examples/inventar_steps.rb | 10 +- .../examples/passwort_steps.rb | 81 +-- .../examples/probleme_steps.rb | 8 +- .../examples/vertrag_steps.rb | 26 + features/step_definitions/login_steps.rb | 4 + .../manage/acknowledge/add_item_steps.rb | 5 +- .../manage/delegation_steps.rb | 5 + .../manage/linegroup/selection_steps.rb | 2 +- .../step_definitions/technical/user_steps.rb | 27 + features/technical/user/suspend.feature | 12 + lib/authenticated_system.rb | 2 +- lib/tasks/app/test.rake | 1 + lib/tasks/leihs.rake | 14 +- locale/de_CH/leihs.po | 19 +- locale/leihs.pot | 17 +- spec/LDAP_generic.yml | 15 + spec/{LDAP.yml => LDAP_hslu.yml} | 4 +- spec/controllers/hslu_ldap_controller_spec.rb | 2 +- spec/controllers/ldap_controller_spec.rb | 79 +++ spec/ldif/generic.ldif | 78 +++ 87 files changed, 1235 insertions(+), 857 deletions(-) create mode 100644 db/migrate/20140328105448_add_automatic_suspension_to_inventory_pools.rb create mode 100644 db/migrate/20140402135726_add_automatic_access_to_inventory_pool.rb delete mode 100644 features/automatische_sperrung.feature create mode 100644 features/examples/Software-erfassen.feature create mode 100644 features/step_definitions/technical/user_steps.rb create mode 100644 features/technical/user/suspend.feature create mode 100644 spec/LDAP_generic.yml rename spec/{LDAP.yml => LDAP_hslu.yml} (89%) create mode 100644 spec/controllers/ldap_controller_spec.rb create mode 100644 spec/ldif/generic.ldif diff --git a/Gemfile b/Gemfile index 0c79f991c2..66d42c8ed3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,10 @@ source 'http://rubygems.org' -gem 'rails', '4.0.3' +gem 'rails', '4.0.4' - -gem 'active_hash', '~> 0.9' +gem 'active_hash', '~> 1.3' gem 'activerecord-jdbcmysql-adapter', :platform => :jruby -gem 'acts-as-dag', '~> 3.0' # TOOD use instead ?? gem 'dagnabit', '2.2.6' +gem 'acts-as-dag', :git => 'https://github.com/jheiss/acts-as-dag.git', :branch => 'rails4' # TOOD use instead ?? gem 'dagnabit', '2.2.6' gem 'barby', '~> 0.5.0' gem 'better_errors', :group => :development gem 'binding_of_caller', :group => :development @@ -13,6 +12,8 @@ gem 'capistrano', '~> 2.15', :group => :development gem 'capistrano-ext', :group => :development gem 'rvm-capistrano', :group => :development +gem "jasminerice", :git => 'https://github.com/bradphelan/jasminerice.git', :group => [:test, :development] # needed for implement coffeescript, fixtures and asset pipeline serverd css into jasmine +gem "rack_session_access", "~> 0.1.1", group: :test gem 'capybara', '~> 2.2', :group => [:test, :development] gem 'capybara-screenshot', :group => [:test, :development] gem 'chunky_png', '~> 1.2' @@ -23,35 +24,35 @@ gem 'compass-rails', '~> 1.1' gem 'cucumber-rails', '~> 1.3', :group => [:test, :development], :require => false gem 'database_cleaner', :group => [:test, :development] gem 'execjs' -gem 'factory_girl', '~> 4.1' # factories also in production mode to seed our demo data on the demo server -gem 'factory_girl_rails', '~> 4.1' -gem 'faker' -gem 'font-awesome-rails', '~> 3.2.1' +gem 'factory_girl', '~> 4.1', :groups => [:test, :development] +gem 'factory_girl_rails', '~> 4.1', :groups => [:test, :development] +gem 'faker', :groups => [:test, :development] +gem 'font-awesome-rails', '~> 3.2.1' # NOTE in order to upgrade to '~> 4.0', use .fa css class instead of .icon gem 'geocoder', '~> 1.1' -gem 'gettext_i18n_rails', '~> 0.8' -gem 'guard-jasmine', '~> 1.11', :group => [:test, :development] +gem 'gettext_i18n_rails', '~> 1.0' +gem 'guard-jasmine', '~> 1.19', :group => [:test, :development] gem 'haml', '~> 3.1' gem 'haml_assets', '~> 0.2' -gem "jasminerice", :git => 'https://github.com/bradphelan/jasminerice.git', :group => [:test, :development] # needed for implement coffeescript, fixtures and asset pipeline serverd css into jasmine -gem 'jquery-rails', '2.1.3' # '~> 2.1' FIXME the version 2.1.4 clashes with underscore-rails 1.4.2.1 +gem 'jquery-rails', '2.1.3' # '~> 2.1' FIXME the version 2.1.4 clashes with underscore-rails 1.4.2.1 + # NOTE in order to upgrate to '~> 3.1', first adapt the code removing the .live() functions gem 'jquery-tmpl-rails', '~> 1.1' gem 'jruby-openssl', :platform => :jruby gem 'json', '~> 1.8' gem 'jsrender-rails', '~> 1.2', :git => 'https://github.com/spape/jsrender-rails.git', :branch => 'own_template_prefix' +gem 'ladle', :group => :test gem 'launchy', '~> 2.1', :group => [:test, :development] gem 'meta_request', :group => :development gem 'mini_magick', '~> 3.4' gem 'mysql2', '~> 0.3.11', :platform => :mri -gem 'net-ldap', '0.2.2', :require => 'net/ldap' # Never upgrade beyond 0.2.2, ruby-net-ldap has broken in many unpredictable ways. Wait for 1.0.0 before upgrading, at least 0.2.2 works. +#gem 'net-ldap', '0.2.2', :require => 'net/ldap' # Never upgrade beyond 0.2.2, ruby-net-ldap has broken in many unpredictable ways. Wait for 1.0.0 before upgrading, at least 0.2.2 works. +gem 'net-ldap', :require => 'net/ldap' gem 'newrelic_rpm', '~> 3.5', :group => [:profiling, :development] -gem 'paperclip', '~> 3.5' +gem 'paperclip', '~> 3.5' # NOTE in order to upgrate to '~> 4.0', first adapt the code to avoid the Paperclip::Errors::MissingRequiredValidatorError gem 'phantomjs', '~> 1.9.7', :group => [:test, :development] # headless webdriver (UI & JS tests) gem 'poltergeist' +gem 'protected_attributes', '~> 1.0' gem 'pry', :group => [:test, :development] gem 'pry-debugger', :group => :development gem 'pry-rails', :group => [:test, :development] -gem 'protected_attributes', '~> 1.0' -gem "rack_session_access", "~> 0.1.1", group: :test gem 'rails_autolink', '~> 1.0' gem 'rake' # So that cronjobs work -- otherwise they can't find rake gem 'redcarpet', :group => [:test, :development] # This isn't being pulled in by yard, but it's required @@ -65,12 +66,10 @@ gem 'selenium-webdriver', :group => [:test, :development] gem 'simplecov', :require => false, :group => :test gem 'therubyracer', :platform => :mri gem 'therubyrhino', :platform => :jruby -gem 'thin', :group => :development, :platform => :mri # web server (Webrick do not support keep-alive connections) gem 'timecop', '~> 0.7', :group => [:test, :development] gem 'trinidad', :group => :development, :platform => :jruby # web server (Webrick do not support keep-alive connections) gem 'uglifier', '~> 2.4' -gem 'underscore-rails', '~> 1.4' +gem 'underscore-rails', '~> 1.6' gem 'uuidtools', '~> 2.1' # needed for creating unique ids during tests (factories) gem 'will_paginate', '~> 3.0' gem 'yard', :group => [:test, :development] - diff --git a/Gemfile.lock b/Gemfile.lock index b3461f95a3..bd2ef1d491 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,15 @@ GIT jasminerice (0.1.0) coffee-rails +GIT + remote: https://github.com/jheiss/acts-as-dag.git + revision: d7cdd8bde5d5fd6ea04e124486e646df62531a1d + branch: rails4 + specs: + acts-as-dag (3.0.0) + activemodel + activerecord + GIT remote: https://github.com/spape/jsrender-rails.git revision: 952103bb94511e4ea06f6024f79d02a719430163 @@ -16,38 +25,35 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (4.0.3) - actionpack (= 4.0.3) + actionmailer (4.0.4) + actionpack (= 4.0.4) mail (~> 2.5.4) - actionpack (4.0.3) - activesupport (= 4.0.3) + actionpack (4.0.4) + activesupport (= 4.0.4) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - active_hash (0.10.0) + active_hash (1.3.0) activesupport (>= 2.2.2) - activemodel (4.0.3) - activesupport (= 4.0.3) + activemodel (4.0.4) + activesupport (= 4.0.4) builder (~> 3.1.0) - activerecord (4.0.3) - activemodel (= 4.0.3) + activerecord (4.0.4) + activemodel (= 4.0.4) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.3) + activesupport (= 4.0.4) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.3) - i18n (~> 0.6, >= 0.6.4) + activesupport (4.0.4) + i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - acts-as-dag (3.0.0) - activemodel - activerecord - addressable (2.3.5) + addressable (2.3.6) arel (4.0.2) - atomic (1.1.15) + atomic (1.1.16) barby (0.5.1) better_errors (1.1.0) coderay (>= 1.0.0) @@ -78,13 +84,13 @@ GEM celluloid-io (0.15.0) celluloid (>= 0.15.0) nio4r (>= 0.5.0) - childprocess (0.5.1) + childprocess (0.5.2) ffi (~> 1.0, >= 1.0.11) chunky_png (1.3.0) climate_control (0.0.3) activesupport (>= 3.0) cliver (0.3.2) - cocaine (0.5.3) + cocaine (0.5.4) climate_control (>= 0.0.3, < 1.0) coderay (1.1.0) coffee-filter (0.1.3) @@ -98,24 +104,24 @@ GEM execjs coffee-script-source (1.7.0) columnize (0.3.6) - compass (0.12.3) + compass (0.12.4) chunky_png (~> 1.2) fssm (>= 0.2.7) - sass (= 3.2.14) - compass-rails (1.1.3) + sass (~> 3.2.17) + compass-rails (1.1.7) compass (>= 0.12.2) - cucumber (1.3.11) + sprockets (<= 2.11.0) + cucumber (1.3.14) builder (>= 2.1.2) diff-lcs (>= 1.1.3) gherkin (~> 2.12) multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.0.2) + multi_test (>= 0.1.1) cucumber-rails (1.4.0) capybara (>= 1.1.2) cucumber (>= 1.2.0) nokogiri (>= 1.5.0) rails (>= 3.0.0) - daemons (1.1.9) database_cleaner (1.2.0) debug_inspector (0.0.2) debugger (1.6.6) @@ -127,14 +133,13 @@ GEM diff-lcs (1.2.5) docile (1.1.3) erubis (2.7.0) - eventmachine (1.0.3) execjs (2.0.2) factory_girl (4.4.0) activesupport (>= 3.0.0) factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) - faker (1.2.0) + faker (1.3.0) i18n (~> 0.5) fast_gettext (0.8.1) ffi (1.9.3) @@ -143,17 +148,17 @@ GEM formatador (0.2.4) fssm (0.2.10) geocoder (1.1.9) - gettext_i18n_rails (0.10.1) + gettext_i18n_rails (1.0.3) fast_gettext (>= 0.4.8) gherkin (2.12.2) multi_json (~> 1.3) - guard (2.5.1) + guard (2.6.0) formatador (>= 0.2.4) - listen (~> 2.6) + listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) - guard-jasmine (1.19.0) + guard-jasmine (1.19.1) childprocess guard (>= 2.0.0) multi_json @@ -172,15 +177,17 @@ GEM jquery-tmpl-rails (1.1.0) rails (>= 3.1.0) json (1.8.1) + ladle (0.2.0) + open4 (~> 1.0.0) launchy (2.4.2) addressable (~> 2.3) libv8 (3.16.14.3) - listen (2.7.0) + listen (2.7.1) celluloid (>= 0.15.2) celluloid-io (>= 0.15.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - lumberjack (1.0.4) + lumberjack (1.0.5) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -192,12 +199,12 @@ GEM mime-types (1.25.1) mini_magick (3.7.0) subexec (~> 0.2.1) - mini_portile (0.5.2) + mini_portile (0.5.3) minitest (4.7.5) - multi_json (1.9.0) - multi_test (0.0.3) + multi_json (1.9.2) + multi_test (0.1.1) mysql2 (0.3.15) - net-ldap (0.2.2) + net-ldap (0.5.1) net-scp (1.1.2) net-ssh (>= 2.6.5) net-sftp (2.1.2) @@ -205,10 +212,11 @@ GEM net-ssh (2.8.0) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) - newrelic_rpm (3.7.3.199) + newrelic_rpm (3.7.3.204) nio4r (1.0.0) nokogiri (1.6.1) mini_portile (~> 0.5.0) + open4 (1.0.1) paperclip (3.5.4) activemodel (>= 3.0.0) activesupport (>= 3.0.0) @@ -221,7 +229,7 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) polyglot (0.3.4) - protected_attributes (1.0.5) + protected_attributes (1.0.7) activemodel (>= 4.0.1, < 5.0) pry (0.9.12.6) coderay (~> 1.0) @@ -240,22 +248,22 @@ GEM rack_session_access (0.1.1) builder (>= 2.0.0) rack (>= 1.0.0) - rails (4.0.3) - actionmailer (= 4.0.3) - actionpack (= 4.0.3) - activerecord (= 4.0.3) - activesupport (= 4.0.3) + rails (4.0.4) + actionmailer (= 4.0.4) + actionpack (= 4.0.4) + activerecord (= 4.0.4) + activesupport (= 4.0.4) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.3) + railties (= 4.0.4) sprockets-rails (~> 2.0.0) rails_autolink (1.1.5) rails (> 3.1) - railties (4.0.3) - actionpack (= 4.0.3) - activesupport (= 4.0.3) + railties (4.0.4) + actionpack (= 4.0.4) + activesupport (= 4.0.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.1) + rake (10.2.2) rb-fsevent (0.9.4) rb-inotify (0.9.3) ffi (>= 0.5.0) @@ -272,7 +280,7 @@ GEM rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) - rspec-rails (2.14.1) + rspec-rails (2.14.2) actionpack (>= 3.0) activemodel (>= 3.0) activesupport (>= 3.0) @@ -280,28 +288,29 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - ruby_parser (3.4.1) + ruby_parser (3.5.0) sexp_processor (~> 4.1) - rubyzip (1.1.0) + rubyzip (1.1.2) rvm-capistrano (1.5.1) capistrano (~> 2.15.4) - sass (3.2.14) - sass-rails (4.0.1) + sass (3.2.18) + sass-rails (4.0.2) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0.0) - selenium-webdriver (2.40.0) + selenium-webdriver (2.41.0) childprocess (>= 0.5.0) multi_json (~> 1.0) rubyzip (~> 1.0) websocket (~> 1.0.4) - sexp_processor (4.4.1) + sexp_processor (4.4.3) simplecov (0.8.2) docile (~> 1.1.0) multi_json simplecov-html (~> 0.8.0) simplecov-html (0.8.0) - slop (3.4.7) + slop (3.5.0) sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) @@ -316,12 +325,8 @@ GEM therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref - thin (1.6.2) - daemons (>= 1.0.9) - eventmachine (>= 1.0.0) - rack (>= 1.0.0) - thor (0.18.1) - thread_safe (0.2.0) + thor (0.19.1) + thread_safe (0.3.1) atomic (>= 1.1.7, < 2) tilt (1.4.1) timecop (0.7.1) @@ -329,26 +334,26 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.38) - uglifier (2.4.0) + tzinfo (0.3.39) + uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) - underscore-rails (1.5.2) + underscore-rails (1.6.0) uuidtools (2.1.4) websocket (1.0.7) websocket-driver (0.3.2) will_paginate (3.0.5) xpath (2.0.0) nokogiri (~> 1.3) - yard (0.8.7.3) + yard (0.8.7.4) PLATFORMS ruby DEPENDENCIES - active_hash (~> 0.9) + active_hash (~> 1.3) activerecord-jdbcmysql-adapter - acts-as-dag (~> 3.0) + acts-as-dag! barby (~> 0.5.0) better_errors binding_of_caller @@ -369,8 +374,8 @@ DEPENDENCIES faker font-awesome-rails (~> 3.2.1) geocoder (~> 1.1) - gettext_i18n_rails (~> 0.8) - guard-jasmine (~> 1.11) + gettext_i18n_rails (~> 1.0) + guard-jasmine (~> 1.19) haml (~> 3.1) haml_assets (~> 0.2) jasminerice! @@ -379,11 +384,12 @@ DEPENDENCIES jruby-openssl json (~> 1.8) jsrender-rails (~> 1.2)! + ladle launchy (~> 2.1) meta_request mini_magick (~> 3.4) mysql2 (~> 0.3.11) - net-ldap (= 0.2.2) + net-ldap newrelic_rpm (~> 3.5) paperclip (~> 3.5) phantomjs (~> 1.9.7) @@ -393,7 +399,7 @@ DEPENDENCIES pry-debugger pry-rails rack_session_access (~> 0.1.1) - rails (= 4.0.3) + rails (= 4.0.4) rails_autolink (~> 1.0) rake redcarpet @@ -408,11 +414,10 @@ DEPENDENCIES simplecov therubyracer therubyrhino - thin timecop (~> 0.7) trinidad uglifier (~> 2.4) - underscore-rails (~> 1.4) + underscore-rails (~> 1.6) uuidtools (~> 2.1) will_paginate (~> 3.0) yard diff --git a/LICENSE b/LICENSE index 5f79370147..d923298951 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. diff --git a/app/assets/javascripts/manage/controllers/contracts_index_controller.coffee b/app/assets/javascripts/manage/controllers/contracts_index_controller.coffee index 6952dd8d83..e98d7ceeb0 100644 --- a/app/assets/javascripts/manage/controllers/contracts_index_controller.coffee +++ b/app/assets/javascripts/manage/controllers/contracts_index_controller.coffee @@ -56,7 +56,7 @@ class window.App.ContractsIndexController extends Spine.Controller return {done: (c)=>c()} unless ids.length App.User.ajaxFetch data: $.param - ids: ids + ids: _.uniq(ids) all: true .done (data)=> users = (App.User.find datum.id for datum in data) @@ -70,7 +70,7 @@ class window.App.ContractsIndexController extends Spine.Controller _(ids).each_slice 300, (slice)=> App.Purpose.ajaxFetch data: $.param - purpose_ids: slice + purpose_ids: _.uniq(slice) .done done render: (target, data, page)=> diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index f513fc3367..3884e59697 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -6,7 +6,7 @@ // FONT-AWESOME -@import "font-awesome" +@import font-awesome // VENDOR diff --git a/app/controllers/authenticator/hslu_authentication_controller.rb b/app/controllers/authenticator/hslu_authentication_controller.rb index 94d0fe352d..590928d926 100644 --- a/app/controllers/authenticator/hslu_authentication_controller.rb +++ b/app/controllers/authenticator/hslu_authentication_controller.rb @@ -60,10 +60,6 @@ def create_user(login, email, firstname, lastname) user = User.new(:login => login, :email => "#{email}", :firstname => "#{firstname}", :lastname => "#{lastname}") user.authentication_system = AuthenticationSystem.where(:class_name => 'HsluAuthentication').first if user.save - # Assign any default roles you want - InventoryPool.all.each do |ip| - user.access_rights.create(:inventory_pool => ip, :role => :customer) - end return user else logger = Rails.logger diff --git a/app/controllers/authenticator/ldap_authentication_controller.rb b/app/controllers/authenticator/ldap_authentication_controller.rb index e9fa83cccc..a1df476670 100644 --- a/app/controllers/authenticator/ldap_authentication_controller.rb +++ b/app/controllers/authenticator/ldap_authentication_controller.rb @@ -1,77 +1,200 @@ -#require 'net/ldap' - +class LdapHelper + attr_reader :unique_id_field + attr_reader :base_dn + attr_reader :ldap_config + attr_reader :host + attr_reader :port + attr_reader :search_field + + def initialize + begin + if Setting::LDAP_CONFIG + @ldap_config = YAML::load_file(Setting::LDAP_CONFIG) + else + @ldap_config = YAML::load_file(File.join(Rails.root, "config", "LDAP.yml")) + end + rescue Exception => e + raise "Could not load LDAP configuration file #{File.join(Rails.root, "config", "LDAP.yml")}: #{e}" + end + @base_dn = @ldap_config[Rails.env]["base_dn"] + @search_field = @ldap_config[Rails.env]["search_field"] + @host = @ldap_config[Rails.env]["host"] + @port = @ldap_config[Rails.env]["port"].to_i || 636 + if @ldap_config[Rails.env]["encryption"] == "none" + @encryption = nil + else + @encryption = @ldap_config[Rails.env]["encryption"].to_sym || :simple_tls + end + @method = :simple + @master_bind_dn = @ldap_config[Rails.env]["master_bind_dn"] + @master_bind_pw = @ldap_config[Rails.env]["master_bind_pw"] + @unique_id_field = @ldap_config[Rails.env]["unique_id_field"] + @video_displayname = @ldap_config[Rails.env]["video_displayname"] + raise "'master_bind_dn' and 'master_bind_pw' must be set in LDAP configuration file" if (@master_bind_dn.blank? or @master_bind_pw.blank?) + raise "'unique_id_field' in LDAP configuration file must point to an LDAP field that allows unique identification of a user" if @unique_id_field.blank? + end + + def bind(username = @master_bind_dn, password = @master_bind_pw) + ldap = Net::LDAP.new :host => @host, + :port => @port, + :encryption => @encryption, + :base => @base_dn, + :auth => { + :method=> @method, + :username => username, + :password => password + } + + if ldap.bind + return ldap + else + logger = Rails.logger + logger.error "ERROR: Can't bind to LDAP server #{@host} as user '#{username}'. Wrong bind credentials or encryption parameters?" + return false + end + end +end + class Authenticator::LdapAuthenticationController < Authenticator::AuthenticatorController - layout 'layouts/manage/general' - + def validate_configuration + logger = Rails.logger + begin + # This thing will complain with an exception if something is wrong about our configuration + helper = LdapHelper.new + rescue Exception => e + flash[:error] = _("You will not be able to log in because this leihs server is not configured correctly. Contact your leihs system administrator.") + logger.error("ERROR: LDAP is not configured correctly: #{e}") + end + end + def login_form_path "/authenticator/ldap/login" end - + + # @param login [String] The login of the user you want to create + # @param email [String] The email address of the user you want to create + def create_user(login, email, firstname, lastname) + user = User.new(:login => login, :email => "#{email}", :firstname => "#{firstname}", :lastname => "#{lastname}") + user.authentication_system = AuthenticationSystem.where(:class_name => 'HsluAuthentication').first + if user.save + return user + elsif + logger = Rails.logger + logger.error "ERROR: Could not create user with login #{login}: #{user.errors.full_messages}" + return false + end + end + + # @param user [User] The (local, database) user whose data you want to update + # @param user_data [Net::LDAP::Entry] The LDAP entry (it could also just be a hash of hashes and arrays that looks like a Net::LDAP::Entry) of that user + def update_user(user, user_data) + logger = Rails.logger + ldaphelper = LdapHelper.new + # Make sure to set "user_image_url" in "/manage/settings" in leihs 3.0 for user images to appear, based + # on the unique ID. Example for the format: + # http://www.hslu.ch/portrait/{:id}.jpg + # {:id} will be interpolated with user.unique_id there. + user.unique_id = user_data[ldaphelper.unique_id_field.to_s].first.to_s + user.firstname = user_data["givenname"].first.to_s + user.lastname = user_data["sn"].first.to_s + user.phone = user_data["telephonenumber"].first.to_s unless user_data["telephonenumber"].blank? + user.language = Language.default_language if user.language.blank? + + user.address = user_data["streetaddress"].first.to_s unless user_data["streetaddress"].blank? + user.city = user_data["l"].first.to_s unless user_data["l"].blank? + user.country = user_data["c"].first.to_s unless user_data["c"].blank? + user.zip = user_data["postalcode"].first.to_s unless user_data["postalcode"].blank? + + admin_dn = ldaphelper.ldap_config[Rails.env]["admin_dn"] + unless admin_dn.blank? + in_admin_group = false + begin + admin_group_filter = Net::LDAP::Filter.eq("member", user_data.dn) + ldap = ldaphelper.bind + if ( + ldap.search(:base => admin_dn, :filter => admin_group_filter).count >= 1 or + (user_data["memberof"] and user_data["memberof"].include?(admin_dn)) + ) + in_admin_group = true + end + rescue Exception => e + logger.error "ERROR: Could not upgrade user #{user.unique_id} to an admin due to exception: #{e}" + end + + if in_admin_group == true + if user.access_rights.active.empty? or !user.access_rights.active.collect(&:role).include?(:admin) + user.access_rights.create(:role => :admin) + end + end + end + + end + + + def create_and_login_from_ldap_user(ldap_user, username, password) + email = ldap_user.mail.first.to_s if ldap_user.mail + email ||= "#{user}@localhost" + bind_dn = ldap_user.dn + firstname = ldap_user.givenname + lastname = ldap_user.sn + ldaphelper = LdapHelper.new + if ldaphelper.bind(bind_dn, password) + u = User.find_by_unique_id(ldap_user[ldaphelper.unique_id_field.to_s]) + if not u + u = create_user(username, email, firstname, lastname) + end + + unless u == false + update_user(u, ldap_user) + if u.save + self.current_user = u + redirect_back_or_default("/") + else + logger.error(u.errors.full_messages.to_s) + flash[:error] = _("Could not update user '#{username}' with new LDAP information. Contact your leihs system administrator.") + end + else + flash[:error] = _("Could not create new user for '#{username}' from LDAP source. Contact your leihs system administrator.") + end + else + flash[:error] = _("Invalid username/password") + end + end + def login super + @preferred_language = Language.preferred(request.env["HTTP_ACCEPT_LANGUAGE"]) + if request.post? - user = params[:login][:user] + username = params[:login][:username] password = params[:login][:password] - if user == "" || password == "" + if username == "" || password == "" flash[:notice] = _("Empty Username and/or Password") else - bind_dn = LDAP_CONFIG[Rails.env]["bind_dn"] - bind_pwd = LDAP_CONFIG[Rails.env]["bind_pwd"] - ldap = Net::LDAP.new :host => LDAP_CONFIG[Rails.env]["host"], - :port => LDAP_CONFIG[Rails.env]["port"].to_i, - :encryption => LDAP_CONFIG[Rails.env]["encryption"].to_sym, - :base => LDAP_CONFIG[Rails.env]["base"], - :auth=>{:method=>:simple, :username => bind_dn, :password => bind_pwd } - + ldaphelper = LdapHelper.new begin - if ldap.bind - users = ldap.search(:base => LDAP_CONFIG[Rails.env]["base"], :filter => Net::LDAP::Filter.eq(LDAP_CONFIG[Rails.env]["search_field"], "#{user}")) + ldap = ldaphelper.bind + + if ldap + users = ldap.search(:base => ldaphelper.base_dn, :filter => Net::LDAP::Filter.eq(ldaphelper.search_field, "#{username}")) if users.size == 1 - email = users.first.mail if users.first.mail - email ||= "#{user}@hkb.bfh.ch" - bind_dn = users.first.dn - firstname = users.first.givenname - lastname = users.first.sn - ldap = Net::LDAP.new :host => LDAP_CONFIG[Rails.env]["host"], - :port => LDAP_CONFIG[Rails.env]["port"].to_i, - :encryption => LDAP_CONFIG[Rails.env]["encryption"].to_sym, - :base => LDAP_CONFIG[Rails.env]["base"], - :auth=>{:method=>:simple, :username => bind_dn, :password => password } - if ldap.bind - - u = User.find_by_login(user) - - if not u - u = User.create(:login => user, :email => "#{email}", :firstname => "#{firstname}", :lastname => "#{lastname}") - InventoryPool.all.each do |ip| - u.access_rights.create(:inventory_pool_id => ip, :role => :customer) - end - end - u.firstname = users.first["givenname"].to_s - u.lastname = users.first["sn"].to_s - u.phone = users.first["telephonenumber"].to_s unless users.first["telephonenumber"].blank? - - u.save - self.current_user = u - redirect_back_or_default("/") - return true - else - flash[:notice] = _("Invalid username/password") - end + create_and_login_from_ldap_user(users.first, username, password) else - flash[:notice] = _("User unknown") if users.size == 0 - flash[:notice] = _("Too many users found") if users.size > 0 + flash[:error] = _("User unknown") if users.size == 0 + flash[:error] = _("Too many users found") if users.size > 0 end else - flash[:notice] = _("Invalid technical user - contact your leihs admin") - redirect_to :action => 'login' + flash[:error] = _("Invalid technical user - contact your leihs admin") end rescue Net::LDAP::LdapError - flash[:notice] = _("Couldn't connect to LDAP: #{LDAP_CONFIG[:host]}:#{LDAP_CONFIG[:port]}") + flash[:error] = _("Couldn't connect to LDAP server: #{ldaphelper.host}:#{ldaphelper.port}") end end + else + validate_configuration end - end + end + end diff --git a/app/controllers/authenticator/shibboleth_authentication_controller.rb b/app/controllers/authenticator/shibboleth_authentication_controller.rb index d021025447..6cf51f5b16 100644 --- a/app/controllers/authenticator/shibboleth_authentication_controller.rb +++ b/app/controllers/authenticator/shibboleth_authentication_controller.rb @@ -11,7 +11,6 @@ class Authenticator::ShibbolethAuthenticationController < Authenticator::AuthenticatorController - DEFAULT_INVENTORY_POOLS = ["ITZ-Ausleihe", "AV-Ausleihe"] SUPER_USERS = ["e157339@zhdk.ch", "e159123@zhdk.ch", "e10262@zhdk.ch", "e162205@zhdk.ch", "e171014@zhdk.ch"] #Jerome, Franco, Ramon, Tomáš AUTHENTICATION_SYSTEM_CLASS_NAME = "ShibbolethAuthentication" @@ -68,15 +67,7 @@ def create_or_update_user user.lastname = "#{ENV['surname']}" user.login = "#{user.firstname} #{user.lastname}" user.authentication_system = AuthenticationSystem.where(:class_name => AUTHENTICATION_SYSTEM_CLASS_NAME).first - if user.new_record? - user.save - ips = InventoryPool.where(:name => DEFAULT_INVENTORY_POOLS) - ips.each do |ip| - user.access_rights.create(:role => :customer, :inventory_pool => ip) - end - else - user.save - end + user.save if SUPER_USERS.include?(user.unique_id) user.access_rights.create(:role => :admin, :inventory_pool => nil) diff --git a/app/controllers/authenticator/zhdk_controller.rb b/app/controllers/authenticator/zhdk_controller.rb index c81e08e622..a85dd0351a 100644 --- a/app/controllers/authenticator/zhdk_controller.rb +++ b/app/controllers/authenticator/zhdk_controller.rb @@ -6,7 +6,6 @@ class Authenticator::ZhdkController < Authenticator::AuthenticatorController AUTHENTICATION_URL = 'http://www.zhdk.ch/?auth/leihs2' APPLICATION_IDENT = '7f6d33ca2ad44359c826e2337d9315b1' - DEFAULT_INVENTORY_POOLS = ["ITZ-Ausleihe", "AV-Ausleihe", "Veranstaltungstechnik"] SUPER_USERS = ["e157339|zhdk", "e159123|zhdk", "e10262|zhdk", "e162205|zhdk", "e171014|zhdk"] #Jerome, Franco, Ramon, Tomáš AUTHENTICATION_SYSTEM_CLASS_NAME = "Zhdk" @@ -55,16 +54,8 @@ def create_or_update_user(xml) user.city = "#{xml["authresponse"]["person"]["place"]}" user.authentication_system = AuthenticationSystem.where(:class_name => AUTHENTICATION_SYSTEM_CLASS_NAME).first user.extended_info = xml["authresponse"]["person"] - if user.new_record? - user.save - ips = InventoryPool.where(:name => DEFAULT_INVENTORY_POOLS) - ips.each do |ip| - user.access_rights.create(:role => :customer, :inventory_pool => ip) - end - else - user.save - end - + user.save + if SUPER_USERS.include?(user.unique_id) user.access_rights.create(:role => :admin, :inventory_pool => nil) end diff --git a/app/controllers/manage/users_controller.rb b/app/controllers/manage/users_controller.rb index d16996479a..2fb78d81a5 100644 --- a/app/controllers/manage/users_controller.rb +++ b/app/controllers/manage/users_controller.rb @@ -126,7 +126,10 @@ def create_in_inventory_pool @user.update_attributes!(authentication_system_id: AuthenticationSystem.find_by_class_name(DatabaseAuthentication.name).id) end - @user.access_rights.create!(inventory_pool: @current_inventory_pool, role: params[:access_right][:role]) unless params[:access_right][:role].to_sym == :no_access + unless params[:access_right][:role].to_sym == :no_access + ar = @user.access_right_for(@current_inventory_pool) || @user.access_rights.build(inventory_pool: @current_inventory_pool) + ar.update_attributes! role: params[:access_right][:role] + end respond_to do |format| format.html do @@ -293,18 +296,6 @@ def remove_group(group_id = params[:group_id]) redirect_to :action => 'groups' end - def remind - if @user.remind(current_user) - respond_to do |format| - format.json { render :json => true, :status => 200 } - end - else - respond_to do |format| - format.json { render :text => @user.errors, :status => 500 } - end - end - end - def get_accessible_roles_for_current_user accessible_roles = [[_("No access"), :no_access], [_("Customer"), :customer]] unless @delegation_type diff --git a/app/models/access_right.rb b/app/models/access_right.rb index fac9179dd0..5acf6cf5ff 100644 --- a/app/models/access_right.rb +++ b/app/models/access_right.rb @@ -10,6 +10,8 @@ class AccessRight < ActiveRecord::Base ROLES_HIERARCHY = [:customer, :group_manager, :lending_manager, :inventory_manager] AVAILABLE_ROLES = ROLES_HIERARCHY + [:admin] + AUTOMATIC_SUSPENSION_DATE = Date.new(2099, 1, 1) + def role read_attribute(:role).to_sym end diff --git a/app/models/contract.rb b/app/models/contract.rb index 2a75642e33..a81bb8cdd5 100644 --- a/app/models/contract.rb +++ b/app/models/contract.rb @@ -139,7 +139,7 @@ def self.filter(params, user = nil, inventory_pool = nil) contracts = contracts.where(Contract.arel_table[:created_at].lt(params[:range][:end_date])) if params[:range] and params[:range][:end_date] contracts = contracts.order(Contract.arel_table[:created_at].desc) # computing total_entries with count(distinct: true) explicitly, because default contracts.count used by paginate plugin seems to override the DISTINCT option and thus returns wrong result. See https://stackoverflow.com/questions/7939719/will-paginate-generates-wrong-number-of-page-links - contracts = contracts.paginate(:page => params[:page]||1, :per_page => [(params[:per_page].try(&:to_i) || 20), 100].min, :total_entries => contracts.count(distinct: true)) unless params[:paginate] == "false" + contracts = contracts.paginate(:page => params[:page]||1, :per_page => [(params[:per_page].try(&:to_i) || 20), 100].min, :total_entries => contracts.distinct.count) unless params[:paginate] == "false" contracts end diff --git a/app/models/inventory_pool.rb b/app/models/inventory_pool.rb index 66351172f7..c6d90be3b8 100644 --- a/app/models/inventory_pool.rb +++ b/app/models/inventory_pool.rb @@ -68,6 +68,7 @@ def array_for_model_and_groups(model, groups) ####################################################################### validates_presence_of :name, :shortname, :email + validates_presence_of :automatic_suspension_reason, if: :automatic_suspension? validates_uniqueness_of :name diff --git a/app/models/language.rb b/app/models/language.rb index d667e74ce1..70e18584d9 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,6 +1,6 @@ class Language < ActiveRecord::Base - default_scope -> {order(:name)} + default_scope { order(:name) } scope :active_languages, -> {where(:active => true)} validates_uniqueness_of :default, :if => Proc.new { |l| l.default } diff --git a/app/models/location.rb b/app/models/location.rb index ce64a61a21..e664df838b 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -29,7 +29,7 @@ def to_s ################################################################# - default_scope -> {includes(:building)} + default_scope { includes(:building) } ################################################################# diff --git a/app/models/user.rb b/app/models/user.rb index 027e4ac358..f638a2eda0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,7 +67,7 @@ def start_screen(path = nil) has_and_belongs_to_many :groups do #tmp#2#, :finder_sql => 'SELECT * FROM `groups` INNER JOIN `groups_users` ON `groups`.id = `groups_users`.group_id OR groups.inventory_pool_id IS NULL WHERE (`groups_users`.user_id = #{id})' def with_general - all + [Group::GENERAL_GROUP_ID] + to_a + [Group::GENERAL_GROUP_ID] end end @@ -77,6 +77,13 @@ def with_general self.language ||= Language.default_language end + after_create do + ips = InventoryPool.where(automatic_access: true) + ips.each do |ip| + access_rights.create(:role => :customer, :inventory_pool => ip) + end + end + ################################################ SEARCHABLE_FIELDS = %w(login firstname lastname badge_id) @@ -234,15 +241,23 @@ def get_approved_contract(inventory_pool) #################################################################### - def self.remind_all - User.all.each do |u| - u.remind + def self.remind_and_suspend_all + Visit.take_back_overdue.each do |visit| + visit.user.remind + visit.user.suspend end end + def suspend + visits_to_suspend = visits.take_back_overdue.select {|visit| visit.inventory_pool.automatic_suspension? } + visits_to_suspend.each do |visit| + access_right_for(visit.inventory_pool).update_attributes suspended_until: AccessRight::AUTOMATIC_SUSPENSION_DATE, + suspended_reason: visit.inventory_pool.automatic_suspension_reason + end + end def remind(reminder_user = self) - visits_to_remind = to_remind + visits_to_remind = visits.take_back_overdue unless visits_to_remind.empty? begin Notification.remind_user(self, visits_to_remind) @@ -267,10 +282,6 @@ def remind(reminder_user = self) end end - def to_remind? - not to_remind.empty? - end - def self.send_deadline_soon_reminder_to_everybody User.all.each do |u| u.send_deadline_soon_reminder @@ -278,12 +289,12 @@ def self.send_deadline_soon_reminder_to_everybody end def send_deadline_soon_reminder(reminder_user = self) - visits_to_remind = deadline_soon - unless visits_to_remind.empty? + visits_to_remind_deadline_soon = visits.take_back.where("date = ADDDATE(CURDATE(), 1)") + unless visits_to_remind_deadline_soon.empty? begin - Notification.deadline_soon_reminder(self, visits_to_remind) - histories.create(:text => _("Deadline soon reminder sent for %{q} items on contracts %{c}") % { :q => visits_to_remind.sum(:quantity), - :c => visits_to_remind.flat_map(&:contract_lines).collect(&:contract_id).uniq.join(',') }, + Notification.deadline_soon_reminder(self, visits_to_remind_deadline_soon) + histories.create(:text => _("Deadline soon reminder sent for %{q} items on contracts %{c}") % { :q => visits_to_remind_deadline_soon.sum(:quantity), + :c => visits_to_remind_deadline_soon.flat_map(&:contract_lines).collect(&:contract_id).uniq.join(',') }, :user_id => reminder_user, :type_const => History::REMIND) puts "Deadline soon: #{self.name}" @@ -335,17 +346,5 @@ def timeout? end end - ############################################ - - private - - def to_remind - visits.take_back.where("date < CURDATE()") - end - - def deadline_soon - visits.take_back.where("date = ADDDATE(CURDATE(), 1)") - end - end diff --git a/app/models/visit.rb b/app/models/visit.rb index f3f04f0004..34ee469bcf 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -47,6 +47,7 @@ def self.destroy_all scope :hand_over, lambda { where(:status => :approved) } scope :take_back, lambda { where(:status => :signed) } + scope :take_back_overdue, lambda { take_back.where("date < CURDATE()") } ####################################################### diff --git a/app/views/application/_logo.html.haml b/app/views/application/_logo.html.haml index cf2594f5c7..c1a86df9bc 100644 --- a/app/views/application/_logo.html.haml +++ b/app/views/application/_logo.html.haml @@ -2,6 +2,6 @@ .table .table-row .table-cell.vertical-align-middle - %img{:src => Setting::LOGO_URL} + %img{:src => asset_path(Setting::LOGO_URL)} - else - leihs \ No newline at end of file + leihs diff --git a/app/views/application/_topbar.html.haml b/app/views/application/_topbar.html.haml index da1fb4e807..1db017c4e7 100644 --- a/app/views/application/_topbar.html.haml +++ b/app/views/application/_topbar.html.haml @@ -7,6 +7,6 @@ .table .table-row .table-cell.vertical-align-middle - %img{:src => Setting::LOGO_URL} + %img{:src => asset_path(Setting::LOGO_URL)} - else - leihs \ No newline at end of file + leihs diff --git a/app/views/documents/_customer.html.haml b/app/views/documents/_customer.html.haml index 46aadeaf2f..ee14f7fff1 100644 --- a/app/views/documents/_customer.html.haml +++ b/app/views/documents/_customer.html.haml @@ -5,5 +5,5 @@ - if @contract.delegated_user %br %span.name= contact_person - %span.street= contact_person.address + %span.street= contact_person.address.chomp(", ") %span.plz_city= "%s %s" % [contact_person.zip, contact_person.city] diff --git a/app/views/documents/_inventory_pool.html.haml b/app/views/documents/_inventory_pool.html.haml index 81d6a5ae43..5592e7fd1a 100644 --- a/app/views/documents/_inventory_pool.html.haml +++ b/app/views/documents/_inventory_pool.html.haml @@ -1,6 +1,4 @@ .inventory_pool %label= _("Lender") %span.name= @contract.inventory_pool.name - - if @contract.inventory_pool.address - %span.street= @contract.inventory_pool.address.street - %span.plz_city= "%s-%s %s" % [@contract.inventory_pool.address.country_code, @contract.inventory_pool.address.zip_code, @contract.inventory_pool.address.city] + = simple_format Setting::CONTRACT_LENDING_PARTY_STRING, {}, wrapper_tag: :span diff --git a/app/views/manage/inventory_pools/_form.html.haml b/app/views/manage/inventory_pools/_form.html.haml index 061d38b0e5..2f8c3ec859 100644 --- a/app/views/manage/inventory_pools/_form.html.haml +++ b/app/views/manage/inventory_pools/_form.html.haml @@ -59,6 +59,28 @@ .col1of2.text-align-center %input{type: "checkbox", name: "inventory_pool[print_contracts]", checked: @inventory_pool.print_contracts} + .row.padding-inset-s.emboss.margin-bottom-xxs + .col1of2 + %strong.font-size-m= _("Automatic suspension") + %div.padding-top-xs + = _("Users who don't bring back the items on the required date are suspended from next day on.") + .col1of2.text-align-center + %input{type: "checkbox", name: "inventory_pool[automatic_suspension]", checked: @inventory_pool.automatic_suspension} + + .row.padding-inset-s.emboss.margin-bottom-xxs + .col1of2 + %strong.font-size-m= _("Automatic suspension reason") + .col1of2.text-align-right + %textarea{type: "text", name: "inventory_pool[automatic_suspension_reason]", rows: 6}= @inventory_pool.automatic_suspension_reason + + .row.padding-inset-s.emboss.margin-bottom-xxs + .col1of2 + %strong.font-size-m= _("Automatic access") + %div.padding-top-xs + = _("New users will get customer access automatically.") + .col1of2.text-align-center + %input{type: "checkbox", name: "inventory_pool[automatic_access]", checked: @inventory_pool.automatic_access} + .col1of2.padding-left-xs %h2.headline-m.padding-left-s= _("Workdays") diff --git a/app/views/manage/users/_access_details.html.haml b/app/views/manage/users/_access_details.html.haml index 76ee496b11..ded543f351 100644 --- a/app/views/manage/users/_access_details.html.haml +++ b/app/views/manage/users/_access_details.html.haml @@ -16,7 +16,8 @@ .col1of2 %strong.font-size-m= _("Suspended until") .col1of2.text-align-right - %input{type: "text", name: "access_right[suspended_until]", value: @access_right.try(:suspended_until), :"data-suspended-until-input" => true, autocomplete: :off} + - suspended_until = @access_right.try :suspended_until + %input{type: "text", name: "access_right[suspended_until]", value: ( l suspended_until if suspended_until ), :"data-suspended-until-input" => true, autocomplete: :off} #suspended-reason.row.padding-inset-s.emboss.margin-bottom-xxs{class: ("hidden" unless @access_right.try(:suspended_until))} .col1of2 diff --git a/config/LDAP.yml.example b/config/LDAP.yml.example index b3bfa707f2..fa721d1522 100644 --- a/config/LDAP.yml.example +++ b/config/LDAP.yml.example @@ -1,42 +1,13 @@ -# configuration for the LDAP server -# host: where to reach the DRb server (used by application processes to contact the server) -# port: which port the server should listen on - production: host: hostname - port: port_number + port: 636 encryption: simple_tls - base: dc=xyz,dc=abcc,dc=ch log_file: log/ldap_server.log log_level: warn - search_field: samaccountname - unique_id_field: pager - master_bind_dn: CN=ldapsearch,OU=Service Accounts,OU=Accounts,OU=_ZHdK manuell,DC=vera,DC=hgka,DC=ch - master_bind_pw: ------------------ - -#test: -test: - host: hostname - port: port_number - encryption: simple_tls - base: dc=xyz,dc=abcc,dc=ch + master_bind_dn: CN=blah,OU=diblah,DC=example,DC=org + master_bind_pw: 12345 + base_dn: OU=user,DC=example,DC=org + admin_dn: CN=admin,DC=example,DC=org + unique_id_field: uid log_file: log/ldap_server.log - log_level: warn - search_field: samaccountname - unique_id_field: pager - master_bind_dn: CN=ldapsearch,OU=Service Accounts,OU=Accounts,OU=_ZHdK manuell,DC=vera,DC=hgka,DC=ch - master_bind_pw: ------------------ - - -#dev: -development: - host: hostname - port: port_number - encryption: simple_tls - base: dc=xyz,dc=abcc,dc=ch - log_file: log/ldap_server.log - log_level: warn search_field: samaccountname - unique_id_field: pager - master_bind_dn: CN=ldapsearch,OU=Service Accounts,OU=Accounts,OU=_ZHdK manuell,DC=vera,DC=hgka,DC=ch - master_bind_pw: ------------------ diff --git a/config/application.rb b/config/application.rb index 44ff34aa65..8936cad1fb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -27,6 +27,13 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + # + config.i18n.enforce_available_locales = false + # The *correct* way to do this is this: + #config.i18n.enforce_available_locales = true + #config.i18n.available_locales = [:de_CH, :en_GB, :en_US, :es, :gsw_CH] + # But the Faker gem is currently broken and does not accept properly spelled locales like 'en_US', it tries + # to look for 'en' and that breaks. If Faker is ever fixed, we can uncomment the above lines. # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" diff --git a/config/deploy/demo-new.rb b/config/deploy/demo-new.rb index 4b44ae8620..96ed8d27c6 100644 --- a/config/deploy/demo-new.rb +++ b/config/deploy/demo-new.rb @@ -21,6 +21,7 @@ default_run_options[:shell] = false set :deploy_to, "/home/leihs/#{application}" +set :secret_token, "/home/leihs/#{application}/secret_token.rb" role :app, "leihs@rails.zhdk.ch" role :web, "leihs@rails.zhdk.ch" diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 45bb7c75a1..8a63922b66 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require "rvm/capistrano" # Load RVM's capistrano plugin. set :rvm_type, :system -set :rvm_ruby_string, '1.9.3-p448' # Or whatever env you want it to run in. +set :rvm_ruby_string, '2.1.0' # Or whatever env you want it to run in. set :rvm_path, "/usr/local/rvm" require "bundler/capistrano" @@ -13,8 +13,8 @@ set :deploy_via, :remote_cache set :db_config, "/home/leihs/#{application}/database.yml" -#set :app_config, "/home/leihs/#{application}/application.rb" set :ldap_config, "/home/leihs/#{application}/LDAP.yml" +set :secret_token, "/home/leihs/#{application}/secret_token.rb" set :use_sudo, false set :rails_env, "production" diff --git a/config/deploy/recipes/bundle_install.rb b/config/deploy/recipes/bundle_install.rb index 39e8a245e4..1b4552d620 100644 --- a/config/deploy/recipes/bundle_install.rb +++ b/config/deploy/recipes/bundle_install.rb @@ -2,5 +2,5 @@ # to the previous release, which has the wrong Gemfile. This fixes that, but of course means we cannot use # the built-in bundler support. task :bundle_install do - run "cd #{release_path} && bundle install --gemfile '#{release_path}/Gemfile' --path '#{deploy_to}/#{shared_dir}/bundle' --deployment --without development test" + run "cd #{release_path} && bundle install --path '#{deploy_to}/#{shared_dir}/bundle' --deployment --without development test" end diff --git a/config/deploy/recipes/link_config.rb b/config/deploy/recipes/link_config.rb index 9b7e824c83..134d9e7de2 100644 --- a/config/deploy/recipes/link_config.rb +++ b/config/deploy/recipes/link_config.rb @@ -1,14 +1,14 @@ task :link_config do - if File.exist?("#{release_path}/config/LDAP.yml") - run "rm #{release_path}/config/LDAP.yml" - run "ln -s #{ldap_config} #{release_path}/config/LDAP.yml" + if exists?(:ldap_config) + run "if [[ -f #{ldap_config} ]]; then ln -sf #{ldap_config} #{release_path}/config/LDAP.yml; fi" end - run "rm -f #{release_path}/config/database.yml" -# run "rm -f #{release_path}/config/application.rb" + if exists?(:secret_token) + run "if [[ -f #{ldap_config} ]]; then ln -sf #{secret_token} #{release_path}/config/initializers/secret_token.rb; fi" + end + run "rm -f #{release_path}/config/database.yml" run "ln -s #{db_config} #{release_path}/config/database.yml" -# run "ln -s #{app_config} #{release_path}/config/application.rb" # So we can check from outside which revision is deployed on that instance # Note: Must use a .txt suffix so that Passengers knows to deliver this diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 63c0372a99..ef6b41e903 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -15,8 +15,9 @@ set :deploy_via, :remote_cache set :db_config, "/home/leihs/#{application}/database.yml" -#set :app_config, "/home/leihs/#{application}/application.rb" set :ldap_config, "/home/leihs/#{application}/LDAP.yml" +set :secret_token, "/home/leihs/#{application}/secret_token.rb" + set :use_sudo, false set :rails_env, "production" diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 090bb967df..7ea4205d37 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -5,3 +5,4 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Leihs::Application.config.secret_token = 'c06439c677c5bbcecf39085670340f8b99f02af5ec5a45af7c700ed18c6f5985989e832af6749599e5d5885e093d5c382c351d59791aff690532c2f41896e37f' +Leihs::Application.config.secret_key_base = 'bdb8c561528d1343a658373562c9fe22924ef451e526de20cb61a2e4bf9dc7eb3affcd9dd4d8bd34218d4d8883e93d7fc6c85c873bfb16305aaf1f8a4fb843d6' diff --git a/db/migrate/20140328105448_add_automatic_suspension_to_inventory_pools.rb b/db/migrate/20140328105448_add_automatic_suspension_to_inventory_pools.rb new file mode 100644 index 0000000000..c2b697b791 --- /dev/null +++ b/db/migrate/20140328105448_add_automatic_suspension_to_inventory_pools.rb @@ -0,0 +1,6 @@ +class AddAutomaticSuspensionToInventoryPools < ActiveRecord::Migration + def change + add_column :inventory_pools, :automatic_suspension, :boolean, null: false, default: false + add_column :inventory_pools, :automatic_suspension_reason, :text + end +end diff --git a/db/migrate/20140402135726_add_automatic_access_to_inventory_pool.rb b/db/migrate/20140402135726_add_automatic_access_to_inventory_pool.rb new file mode 100644 index 0000000000..2a37899bc6 --- /dev/null +++ b/db/migrate/20140402135726_add_automatic_access_to_inventory_pool.rb @@ -0,0 +1,15 @@ +class AddAutomaticAccessToInventoryPool < ActiveRecord::Migration + def change + add_column :inventory_pools, :automatic_access, :boolean + + # the ZHdK authentication controller is not giving access rights anymore + # then we flag ips and the access rights are created in the after_create hook in user model + if AuthenticationSystem.default_system.first.try(:name) == "ZHDK Authentication" + zhdk_default_inventory_pools = ["ITZ-Ausleihe", "AV-Ausleihe", "Veranstaltungstechnik"] + ips = InventoryPool.where(:name => zhdk_default_inventory_pools) + ips.each do |ip| + ip.update_attributes automatic_access: true + end + end + end +end diff --git a/db/structure.sql b/db/structure.sql index b27cf32617..9aa6a8143d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,6 +1,6 @@ -- MySQL dump 10.13 Distrib 5.5.35, for debian-linux-gnu (i686) -- --- Host: localhost Database: leihs2_dev +-- Host: localhost Database: leihs2_test -- ------------------------------------------------------ -- Server version 5.5.35-0+wheezy1 @@ -26,19 +26,19 @@ CREATE TABLE `access_rights` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) DEFAULT NULL, `inventory_pool_id` int(11) DEFAULT NULL, - `created_at` datetime DEFAULT NULL, - `updated_at` datetime DEFAULT NULL, `suspended_until` date DEFAULT NULL, `deleted_at` date DEFAULT NULL, - `suspended_reason` text, - `role` enum('customer','group_manager','lending_manager','inventory_manager','admin') NOT NULL, + `created_at` datetime DEFAULT NULL, + `updated_at` datetime DEFAULT NULL, + `suspended_reason` text COLLATE utf8_unicode_ci, + `role` enum('customer','group_manager','lending_manager','inventory_manager','admin') COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), - KEY `index_access_rights_on_inventory_pool_id` (`inventory_pool_id`), KEY `index_access_rights_on_suspended_until` (`suspended_until`), KEY `index_access_rights_on_deleted_at` (`deleted_at`), + KEY `index_access_rights_on_inventory_pool_id` (`inventory_pool_id`), KEY `index_on_user_id_and_inventory_pool_id_and_deleted_at` (`user_id`,`inventory_pool_id`,`deleted_at`), KEY `index_access_rights_on_role` (`role`) -) ENGINE=InnoDB AUTO_INCREMENT=41792 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51,11 +51,11 @@ DROP TABLE IF EXISTS `accessories`; CREATE TABLE `accessories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model_id` int(11) DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `quantity` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_accessories_on_model_id` (`model_id`) -) ENGINE=InnoDB AUTO_INCREMENT=623 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -70,7 +70,7 @@ CREATE TABLE `accessories_inventory_pools` ( `inventory_pool_id` int(11) DEFAULT NULL, UNIQUE KEY `index_accessories_inventory_pools` (`accessory_id`,`inventory_pool_id`), KEY `index_accessories_inventory_pools_on_inventory_pool_id` (`inventory_pool_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -82,15 +82,15 @@ DROP TABLE IF EXISTS `addresses`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addresses` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `street` varchar(255) DEFAULT NULL, - `zip_code` varchar(255) DEFAULT NULL, - `city` varchar(255) DEFAULT NULL, - `country_code` varchar(255) DEFAULT NULL, + `street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `zip_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `country_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `latitude` float DEFAULT NULL, `longitude` float DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_addresses_on_street_and_zip_code_and_city_and_country_code` (`street`,`zip_code`,`city`,`country_code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -104,44 +104,12 @@ CREATE TABLE `attachments` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model_id` int(11) DEFAULT NULL, `is_main` tinyint(1) DEFAULT '0', - `content_type` varchar(255) DEFAULT NULL, - `filename` varchar(255) DEFAULT NULL, + `content_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `filename` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `size` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_attachments_on_model_id` (`model_id`) -) ENGINE=InnoDB AUTO_INCREMENT=717 DEFAULT CHARSET=utf8 CHECKSUM=1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `audits` --- - -DROP TABLE IF EXISTS `audits`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `audits` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `thread_id` bigint(20) DEFAULT NULL, - `auditable_id` int(11) DEFAULT NULL, - `auditable_type` varchar(255) DEFAULT NULL, - `associated_id` int(11) DEFAULT NULL, - `associated_type` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `user_type` varchar(255) DEFAULT NULL, - `username` varchar(255) DEFAULT NULL, - `action` varchar(255) DEFAULT NULL, - `audited_changes` text, - `version` int(11) DEFAULT '0', - `comment` varchar(255) DEFAULT NULL, - `remote_address` varchar(255) DEFAULT NULL, - `created_at` datetime DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `index_audits_on_thread_id` (`thread_id`), - KEY `auditable_index` (`auditable_id`,`auditable_type`), - KEY `associated_index` (`associated_id`,`associated_type`), - KEY `user_index` (`user_id`,`user_type`), - KEY `index_audits_on_created_at` (`created_at`) -) ENGINE=InnoDB AUTO_INCREMENT=26226 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -153,12 +121,12 @@ DROP TABLE IF EXISTS `authentication_systems`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `authentication_systems` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - `class_name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `class_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `is_default` tinyint(1) DEFAULT '0', `is_active` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -170,10 +138,10 @@ DROP TABLE IF EXISTS `buildings`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `buildings` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - `code` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -186,28 +154,28 @@ DROP TABLE IF EXISTS `contract_lines`; CREATE TABLE `contract_lines` ( `id` int(11) NOT NULL AUTO_INCREMENT, `contract_id` int(11) DEFAULT NULL, + `type` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'ItemLine', `item_id` int(11) DEFAULT NULL, `model_id` int(11) DEFAULT NULL, `quantity` int(11) DEFAULT '1', `start_date` date DEFAULT NULL, `end_date` date DEFAULT NULL, `returned_date` date DEFAULT NULL, + `option_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, - `option_id` int(11) DEFAULT NULL, - `type` varchar(255) NOT NULL DEFAULT 'ItemLine', `purpose_id` int(11) DEFAULT NULL, `returned_to_user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_contract_lines_on_start_date` (`start_date`), KEY `index_contract_lines_on_end_date` (`end_date`), KEY `index_contract_lines_on_option_id` (`option_id`), - KEY `index_contract_lines_on_contract_id` (`contract_id`), - KEY `index_contract_lines_on_item_id` (`item_id`), - KEY `index_contract_lines_on_model_id` (`model_id`), + KEY `fk_contract_lines_contract_id` (`contract_id`), + KEY `fk_contract_lines_item_id` (`item_id`), + KEY `fk_contract_lines_model_id` (`model_id`), KEY `index_contract_lines_on_returned_date_and_contract_id` (`returned_date`,`contract_id`), KEY `index_contract_lines_on_type_and_contract_id` (`type`,`contract_id`) -) ENGINE=InnoDB AUTO_INCREMENT=314553 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -221,17 +189,17 @@ CREATE TABLE `contracts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) DEFAULT NULL, `inventory_pool_id` int(11) DEFAULT NULL, + `note` text COLLATE utf8_unicode_ci, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, - `note` text, `handed_over_by_user_id` int(11) DEFAULT NULL, - `status` enum('unsubmitted','submitted','rejected','approved','signed','closed') NOT NULL, + `status` enum('unsubmitted','submitted','rejected','approved','signed','closed') COLLATE utf8_unicode_ci NOT NULL, `delegated_user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `index_contracts_on_user_id` (`user_id`), KEY `index_contracts_on_inventory_pool_id` (`inventory_pool_id`), + KEY `index_contracts_on_user_id` (`user_id`), KEY `index_contracts_on_status` (`status`) -) ENGINE=InnoDB AUTO_INCREMENT=71249 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -243,14 +211,14 @@ DROP TABLE IF EXISTS `database_authentications`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `database_authentications` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `login` varchar(255) DEFAULT NULL, - `crypted_password` varchar(40) DEFAULT NULL, - `salt` varchar(40) DEFAULT NULL, + `login` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `crypted_password` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, + `salt` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -277,7 +245,7 @@ DROP TABLE IF EXISTS `groups`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `groups` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `inventory_pool_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, @@ -285,7 +253,7 @@ CREATE TABLE `groups` ( PRIMARY KEY (`id`), KEY `index_groups_on_inventory_pool_id` (`inventory_pool_id`), KEY `index_groups_on_is_verification_required` (`is_verification_required`) -) ENGINE=InnoDB AUTO_INCREMENT=157 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -300,7 +268,7 @@ CREATE TABLE `groups_users` ( `group_id` int(11) DEFAULT NULL, UNIQUE KEY `index_groups_users_on_user_id_and_group_id` (`user_id`,`group_id`), KEY `index_groups_users_on_group_id` (`group_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -312,17 +280,17 @@ DROP TABLE IF EXISTS `histories`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `histories` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `text` varchar(255) DEFAULT '', + `text` varchar(255) COLLATE utf8_unicode_ci DEFAULT '', `type_const` int(11) DEFAULT NULL, `created_at` datetime NOT NULL, `target_id` int(11) NOT NULL, - `target_type` varchar(255) NOT NULL, + `target_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `index_histories_on_user_id` (`user_id`), KEY `index_histories_on_target_type_and_target_id` (`target_type`,`target_id`), - KEY `index_histories_on_type_const` (`type_const`) -) ENGINE=InnoDB AUTO_INCREMENT=906116 DEFAULT CHARSET=utf8 CHECKSUM=1; + KEY `index_histories_on_type_const` (`type_const`), + KEY `index_histories_on_user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -337,11 +305,11 @@ CREATE TABLE `holidays` ( `inventory_pool_id` int(11) DEFAULT NULL, `start_date` date DEFAULT NULL, `end_date` date DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_holidays_on_inventory_pool_id` (`inventory_pool_id`), KEY `index_holidays_on_start_date_and_end_date` (`start_date`,`end_date`) -) ENGINE=InnoDB AUTO_INCREMENT=419 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -355,16 +323,16 @@ CREATE TABLE `images` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model_id` int(11) DEFAULT NULL, `is_main` tinyint(1) DEFAULT '0', - `content_type` varchar(255) DEFAULT NULL, - `filename` varchar(255) DEFAULT NULL, + `content_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `filename` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `size` int(11) DEFAULT NULL, `height` int(11) DEFAULT NULL, `width` int(11) DEFAULT NULL, `parent_id` int(11) DEFAULT NULL, - `thumbnail` varchar(255) DEFAULT NULL, + `thumbnail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_images_on_model_id` (`model_id`) -) ENGINE=InnoDB AUTO_INCREMENT=6539 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -376,22 +344,25 @@ DROP TABLE IF EXISTS `inventory_pools`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inventory_pools` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - `description` text, - `contact_details` varchar(255) DEFAULT NULL, - `contract_description` varchar(255) DEFAULT NULL, - `contract_url` varchar(255) DEFAULT NULL, - `logo_url` varchar(255) DEFAULT NULL, - `default_contract_note` text, - `shortname` varchar(255) DEFAULT NULL, - `email` varchar(255) DEFAULT NULL, - `color` text, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` text COLLATE utf8_unicode_ci, + `contact_details` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `contract_description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `contract_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `logo_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `default_contract_note` text COLLATE utf8_unicode_ci, + `shortname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `color` text COLLATE utf8_unicode_ci, `print_contracts` tinyint(1) DEFAULT '1', - `opening_hours` text, + `opening_hours` text COLLATE utf8_unicode_ci, `address_id` int(11) DEFAULT NULL, + `automatic_suspension` tinyint(1) NOT NULL DEFAULT '0', + `automatic_suspension_reason` text COLLATE utf8_unicode_ci, + `automatic_access` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_inventory_pools_on_name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=171 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -406,7 +377,7 @@ CREATE TABLE `inventory_pools_model_groups` ( `model_group_id` int(11) DEFAULT NULL, KEY `index_inventory_pools_model_groups_on_inventory_pool_id` (`inventory_pool_id`), KEY `index_inventory_pools_model_groups_on_model_group_id` (`model_group_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -418,97 +389,45 @@ DROP TABLE IF EXISTS `items`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `items` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `inventory_code` varchar(255) DEFAULT NULL, - `serial_number` varchar(255) DEFAULT NULL, + `inventory_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `serial_number` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `model_id` int(11) DEFAULT NULL, `location_id` int(11) DEFAULT NULL, `supplier_id` int(11) DEFAULT NULL, `owner_id` int(11) DEFAULT NULL, `parent_id` int(11) DEFAULT NULL, - `invoice_number` varchar(255) DEFAULT NULL, + `invoice_number` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `invoice_date` date DEFAULT NULL, `last_check` date DEFAULT NULL, `retired` date DEFAULT NULL, - `retired_reason` varchar(255) DEFAULT NULL, + `retired_reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `price` decimal(8,2) DEFAULT NULL, `is_broken` tinyint(1) DEFAULT '0', `is_incomplete` tinyint(1) DEFAULT '0', `is_borrowable` tinyint(1) DEFAULT '0', - `created_at` datetime DEFAULT NULL, - `updated_at` datetime DEFAULT NULL, `needs_permission` tinyint(1) DEFAULT '0', `inventory_pool_id` int(11) DEFAULT NULL, `is_inventory_relevant` tinyint(1) DEFAULT '0', - `responsible` varchar(255) DEFAULT NULL, - `insurance_number` varchar(255) DEFAULT NULL, - `note` text, - `name` text, - `user_name` varchar(255) DEFAULT NULL, - `properties` varchar(2048) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `index_items_on_inventory_code` (`inventory_code`), - KEY `index_items_on_is_broken` (`is_broken`), - KEY `index_items_on_is_incomplete` (`is_incomplete`), - KEY `index_items_on_is_borrowable` (`is_borrowable`), - KEY `index_items_on_location_id` (`location_id`), - KEY `index_items_on_owner_id` (`owner_id`), - KEY `index_items_on_inventory_pool_id` (`inventory_pool_id`), - KEY `index_items_on_retired` (`retired`), - KEY `index_items_on_parent_id_and_retired` (`parent_id`,`retired`), - KEY `index_items_on_model_id_and_retired_and_inventory_pool_id` (`model_id`,`retired`,`inventory_pool_id`) -) ENGINE=InnoDB AUTO_INCREMENT=34877 DEFAULT CHARSET=utf8 CHECKSUM=1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `items_backup` --- - -DROP TABLE IF EXISTS `items_backup`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `items_backup` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `inventory_code` varchar(255) DEFAULT NULL, - `serial_number` varchar(255) DEFAULT NULL, - `model_id` int(11) DEFAULT NULL, - `location_id` int(11) DEFAULT NULL, - `supplier_id` int(11) DEFAULT NULL, - `owner_id` int(11) DEFAULT NULL, - `parent_id` int(11) DEFAULT NULL, - `invoice_number` varchar(255) DEFAULT NULL, - `invoice_date` date DEFAULT NULL, - `last_check` date DEFAULT NULL, - `retired` date DEFAULT NULL, - `retired_reason` varchar(255) DEFAULT NULL, - `price` decimal(8,2) DEFAULT NULL, - `is_broken` tinyint(1) DEFAULT '0', - `is_incomplete` tinyint(1) DEFAULT '0', - `is_borrowable` tinyint(1) DEFAULT '0', + `responsible` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `insurance_number` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `note` text COLLATE utf8_unicode_ci, + `name` text COLLATE utf8_unicode_ci, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, - `needs_permission` tinyint(1) DEFAULT '0', - `inventory_pool_id` int(11) DEFAULT NULL, - `is_inventory_relevant` tinyint(1) DEFAULT '0', - `responsible` varchar(255) DEFAULT NULL, - `insurance_number` varchar(255) DEFAULT NULL, - `note` text, - `name` text, - `delta` tinyint(1) DEFAULT '1', - `user_name` varchar(255) DEFAULT NULL, - `properties` varchar(2048) DEFAULT NULL, + `user_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `properties` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_items_on_inventory_code` (`inventory_code`), + KEY `index_items_on_inventory_pool_id` (`inventory_pool_id`), + KEY `index_items_on_retired` (`retired`), + KEY `index_items_on_is_borrowable` (`is_borrowable`), KEY `index_items_on_is_broken` (`is_broken`), KEY `index_items_on_is_incomplete` (`is_incomplete`), - KEY `index_items_on_is_borrowable` (`is_borrowable`), KEY `index_items_on_location_id` (`location_id`), KEY `index_items_on_owner_id` (`owner_id`), - KEY `index_items_on_inventory_pool_id` (`inventory_pool_id`), - KEY `index_items_on_retired` (`retired`), - KEY `index_items_on_delta` (`delta`), KEY `index_items_on_parent_id_and_retired` (`parent_id`,`retired`), KEY `index_items_on_model_id_and_retired_and_inventory_pool_id` (`model_id`,`retired`,`inventory_pool_id`) -) ENGINE=InnoDB AUTO_INCREMENT=18806 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -520,14 +439,14 @@ DROP TABLE IF EXISTS `languages`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `languages` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - `locale_name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `locale_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `default` tinyint(1) DEFAULT NULL, `active` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_languages_on_name` (`name`), KEY `index_languages_on_active_and_default` (`active`,`default`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -539,12 +458,12 @@ DROP TABLE IF EXISTS `locations`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `locations` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `room` varchar(255) DEFAULT NULL, - `shelf` varchar(255) DEFAULT NULL, + `room` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `shelf` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `building_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_locations_on_building_id` (`building_id`) -) ENGINE=InnoDB AUTO_INCREMENT=5583 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -560,12 +479,12 @@ CREATE TABLE `model_group_links` ( `descendant_id` int(11) DEFAULT NULL, `direct` tinyint(1) DEFAULT NULL, `count` int(11) DEFAULT NULL, - `label` varchar(255) DEFAULT NULL, + `label` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_model_group_links_on_ancestor_id` (`ancestor_id`), KEY `index_model_group_links_on_direct` (`direct`), KEY `index_on_descendant_id_and_ancestor_id_and_direct` (`descendant_id`,`ancestor_id`,`direct`) -) ENGINE=InnoDB AUTO_INCREMENT=1871 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -577,29 +496,13 @@ DROP TABLE IF EXISTS `model_groups`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `model_groups` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(255) DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, + `type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_model_groups_on_type` (`type`) -) ENGINE=InnoDB AUTO_INCREMENT=721 DEFAULT CHARSET=utf8 CHECKSUM=1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `model_groups_parents_backup` --- - -DROP TABLE IF EXISTS `model_groups_parents_backup`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `model_groups_parents_backup` ( - `model_group_id` int(11) DEFAULT NULL, - `parent_id` int(11) DEFAULT NULL, - `label` varchar(255) DEFAULT NULL, - KEY `index_model_groups_parents_on_model_group_id` (`model_group_id`), - KEY `index_model_groups_parents_on_parent_id` (`parent_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -617,7 +520,7 @@ CREATE TABLE `model_links` ( PRIMARY KEY (`id`), KEY `index_model_links_on_model_id_and_model_group_id` (`model_id`,`model_group_id`), KEY `index_model_links_on_model_group_id_and_model_id` (`model_group_id`,`model_id`) -) ENGINE=InnoDB AUTO_INCREMENT=18023 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -629,21 +532,21 @@ DROP TABLE IF EXISTS `models`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `models` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `manufacturer` varchar(255) DEFAULT NULL, - `description` text, - `internal_description` text, - `info_url` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `manufacturer` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` text COLLATE utf8_unicode_ci, + `internal_description` text COLLATE utf8_unicode_ci, + `info_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `rental_price` decimal(8,2) DEFAULT NULL, `maintenance_period` int(11) DEFAULT '0', `is_package` tinyint(1) DEFAULT '0', + `technical_detail` text COLLATE utf8_unicode_ci, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, - `technical_detail` text, - `hand_over_note` text, + `hand_over_note` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `index_models_on_is_package` (`is_package`) -) ENGINE=InnoDB AUTO_INCREMENT=12817 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -656,9 +559,9 @@ DROP TABLE IF EXISTS `models_compatibles`; CREATE TABLE `models_compatibles` ( `model_id` int(11) DEFAULT NULL, `compatible_id` int(11) DEFAULT NULL, - KEY `index_models_compatibles_on_model_id` (`model_id`), - KEY `index_models_compatibles_on_compatible_id` (`compatible_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; + KEY `index_models_compatibles_on_compatible_id` (`compatible_id`), + KEY `index_models_compatibles_on_model_id` (`model_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -671,11 +574,11 @@ DROP TABLE IF EXISTS `notifications`; CREATE TABLE `notifications` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) DEFAULT NULL, - `title` varchar(255) DEFAULT '', + `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT '', `created_at` datetime NOT NULL, PRIMARY KEY (`id`), KEY `index_notifications_on_user_id` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=223374 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -689,7 +592,7 @@ CREATE TABLE `numerators` ( `id` int(11) NOT NULL AUTO_INCREMENT, `item` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -702,12 +605,12 @@ DROP TABLE IF EXISTS `options`; CREATE TABLE `options` ( `id` int(11) NOT NULL AUTO_INCREMENT, `inventory_pool_id` int(11) DEFAULT NULL, - `inventory_code` varchar(255) DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, + `inventory_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `price` decimal(8,2) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_options_on_inventory_pool_id` (`inventory_pool_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2723 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -725,7 +628,7 @@ CREATE TABLE `partitions` ( `quantity` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_partitions_on_model_id_and_inventory_pool_id_and_group_id` (`model_id`,`inventory_pool_id`,`group_id`) -) ENGINE=InnoDB AUTO_INCREMENT=5093 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -754,11 +657,11 @@ DROP TABLE IF EXISTS `properties`; CREATE TABLE `properties` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model_id` int(11) DEFAULT NULL, - `key` varchar(255) DEFAULT NULL, - `value` varchar(255) DEFAULT NULL, + `key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_properties_on_model_id` (`model_id`) -) ENGINE=InnoDB AUTO_INCREMENT=12795 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -770,9 +673,9 @@ DROP TABLE IF EXISTS `purposes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `purposes` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` text, + `description` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=81300 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -805,9 +708,9 @@ DROP TABLE IF EXISTS `schema_migrations`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `schema_migrations` ( - `version` varchar(255) NOT NULL, + `version` varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY `unique_schema_migrations` (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -819,29 +722,30 @@ DROP TABLE IF EXISTS `settings`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `settings` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `smtp_address` varchar(255) DEFAULT NULL, + `smtp_address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `smtp_port` int(11) DEFAULT NULL, - `smtp_domain` varchar(255) DEFAULT NULL, - `local_currency_string` varchar(255) DEFAULT NULL, - `contract_terms` text, - `contract_lending_party_string` text, - `email_signature` varchar(255) DEFAULT NULL, - `default_email` varchar(255) DEFAULT NULL, + `smtp_domain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `local_currency_string` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `contract_terms` text COLLATE utf8_unicode_ci, + `contract_lending_party_string` text COLLATE utf8_unicode_ci, + `email_signature` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `default_email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `deliver_order_notifications` tinyint(1) DEFAULT NULL, - `user_image_url` varchar(255) DEFAULT NULL, - `logo_url` varchar(255) DEFAULT NULL, - `mail_delivery_method` varchar(255) DEFAULT NULL, - `smtp_username` varchar(255) DEFAULT NULL, - `smtp_password` varchar(255) DEFAULT NULL, + `user_image_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `ldap_config` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `logo_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `mail_delivery_method` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `smtp_username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `smtp_password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `smtp_enable_starttls_auto` tinyint(1) NOT NULL DEFAULT '0', - `smtp_openssl_verify_mode` varchar(255) NOT NULL DEFAULT 'none', - `time_zone` varchar(255) NOT NULL DEFAULT 'Bern', + `smtp_openssl_verify_mode` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'none', + `time_zone` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Bern', `disable_manage_section` tinyint(1) NOT NULL DEFAULT '0', - `disable_manage_section_message` text, + `disable_manage_section_message` text COLLATE utf8_unicode_ci, `disable_borrow_section` tinyint(1) NOT NULL DEFAULT '0', - `disable_borrow_section_message` text, + `disable_borrow_section_message` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -853,11 +757,11 @@ DROP TABLE IF EXISTS `suppliers`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `suppliers` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=507 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -869,27 +773,27 @@ DROP TABLE IF EXISTS `users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `login` varchar(255) DEFAULT NULL, - `firstname` varchar(255) DEFAULT NULL, - `lastname` varchar(255) DEFAULT NULL, - `phone` varchar(255) DEFAULT NULL, + `login` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `firstname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `authentication_system_id` int(11) DEFAULT '1', - `unique_id` varchar(255) DEFAULT NULL, - `email` varchar(255) DEFAULT NULL, + `unique_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `badge_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `zip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `country` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `language_id` int(11) DEFAULT NULL, + `extended_info` text COLLATE utf8_unicode_ci, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, - `badge_id` varchar(255) DEFAULT NULL, - `address` varchar(255) DEFAULT NULL, - `city` varchar(255) DEFAULT NULL, - `zip` varchar(255) DEFAULT NULL, - `country` varchar(255) DEFAULT NULL, - `language_id` int(11) DEFAULT NULL, - `extended_info` text, - `settings` varchar(1024) DEFAULT NULL, + `settings` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `delegator_user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_users_on_authentication_system_id` (`authentication_system_id`) -) ENGINE=InnoDB AUTO_INCREMENT=9124 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -950,7 +854,7 @@ CREATE TABLE `workdays` ( `sunday` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`), KEY `index_workdays_on_inventory_pool_id` (`inventory_pool_id`) -) ENGINE=InnoDB AUTO_INCREMENT=391 DEFAULT CHARSET=utf8 CHECKSUM=1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1038,123 +942,7 @@ CREATE TABLE `workdays` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2014-03-21 12:06:27 -INSERT INTO schema_migrations (version) VALUES ('20080401000001'); - -INSERT INTO schema_migrations (version) VALUES ('20080401000101'); - -INSERT INTO schema_migrations (version) VALUES ('20080402000003'); - -INSERT INTO schema_migrations (version) VALUES ('20080403000009'); - -INSERT INTO schema_migrations (version) VALUES ('20080404000001'); - -INSERT INTO schema_migrations (version) VALUES ('20080404000002'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000001'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000002'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000003'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000004'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000005'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000011'); - -INSERT INTO schema_migrations (version) VALUES ('20080601000012'); - -INSERT INTO schema_migrations (version) VALUES ('20080602000010'); - -INSERT INTO schema_migrations (version) VALUES ('20080603000001'); - -INSERT INTO schema_migrations (version) VALUES ('20080701000102'); - -INSERT INTO schema_migrations (version) VALUES ('20080707081422'); - -INSERT INTO schema_migrations (version) VALUES ('20080805103302'); - -INSERT INTO schema_migrations (version) VALUES ('20080929144756'); - -INSERT INTO schema_migrations (version) VALUES ('20081006150959'); - -INSERT INTO schema_migrations (version) VALUES ('20081007122945'); - -INSERT INTO schema_migrations (version) VALUES ('20090106104142'); - -INSERT INTO schema_migrations (version) VALUES ('20090210170000'); - -INSERT INTO schema_migrations (version) VALUES ('20090320104643'); - -INSERT INTO schema_migrations (version) VALUES ('20090421140116'); - -INSERT INTO schema_migrations (version) VALUES ('20090429075140'); - -INSERT INTO schema_migrations (version) VALUES ('20090514095032'); - -INSERT INTO schema_migrations (version) VALUES ('20090518113240'); - -INSERT INTO schema_migrations (version) VALUES ('20090528122706'); - -INSERT INTO schema_migrations (version) VALUES ('20090619111757'); - -INSERT INTO schema_migrations (version) VALUES ('20090709150345'); - -INSERT INTO schema_migrations (version) VALUES ('20090710124733'); - -INSERT INTO schema_migrations (version) VALUES ('20090715063454'); - -INSERT INTO schema_migrations (version) VALUES ('20090724114431'); - -INSERT INTO schema_migrations (version) VALUES ('20090806120926'); - -INSERT INTO schema_migrations (version) VALUES ('20090813215900'); - -INSERT INTO schema_migrations (version) VALUES ('20090814075139'); - -INSERT INTO schema_migrations (version) VALUES ('20090820145000'); - -INSERT INTO schema_migrations (version) VALUES ('20090917155340'); - -INSERT INTO schema_migrations (version) VALUES ('20090924141539'); - -INSERT INTO schema_migrations (version) VALUES ('20090925135507'); - -INSERT INTO schema_migrations (version) VALUES ('20090930114610'); - -INSERT INTO schema_migrations (version) VALUES ('20091022123204'); - -INSERT INTO schema_migrations (version) VALUES ('20091112145800'); - -INSERT INTO schema_migrations (version) VALUES ('20091211105020'); - -INSERT INTO schema_migrations (version) VALUES ('20091211131416'); - -INSERT INTO schema_migrations (version) VALUES ('20091217121910'); - -INSERT INTO schema_migrations (version) VALUES ('20091217150952'); - -INSERT INTO schema_migrations (version) VALUES ('20100105181436'); - -INSERT INTO schema_migrations (version) VALUES ('20100324134347'); - -INSERT INTO schema_migrations (version) VALUES ('20100615122038'); - -INSERT INTO schema_migrations (version) VALUES ('20100616111044'); - -INSERT INTO schema_migrations (version) VALUES ('20100721114952'); - -INSERT INTO schema_migrations (version) VALUES ('20100722081900'); - -INSERT INTO schema_migrations (version) VALUES ('20100823113320'); - -INSERT INTO schema_migrations (version) VALUES ('20100924083000'); - -INSERT INTO schema_migrations (version) VALUES ('20101011130358'); - -INSERT INTO schema_migrations (version) VALUES ('20101011133019'); - +-- Dump completed on 2014-04-08 13:31:52 INSERT INTO schema_migrations (version) VALUES ('20101213125330'); INSERT INTO schema_migrations (version) VALUES ('20110111175705'); @@ -1179,8 +967,6 @@ INSERT INTO schema_migrations (version) VALUES ('20110815110417'); INSERT INTO schema_migrations (version) VALUES ('20110921134810'); -INSERT INTO schema_migrations (version) VALUES ('20111118141748'); - INSERT INTO schema_migrations (version) VALUES ('20111123154235'); INSERT INTO schema_migrations (version) VALUES ('20111215221843'); @@ -1189,8 +975,6 @@ INSERT INTO schema_migrations (version) VALUES ('20120106214650'); INSERT INTO schema_migrations (version) VALUES ('20120301140904'); -INSERT INTO schema_migrations (version) VALUES ('20120413154754'); - INSERT INTO schema_migrations (version) VALUES ('20120424080000'); INSERT INTO schema_migrations (version) VALUES ('20120424080001'); @@ -1209,16 +993,12 @@ INSERT INTO schema_migrations (version) VALUES ('20120806203246'); INSERT INTO schema_migrations (version) VALUES ('20120806203332'); -INSERT INTO schema_migrations (version) VALUES ('20120807101549'); - INSERT INTO schema_migrations (version) VALUES ('20120921102118'); INSERT INTO schema_migrations (version) VALUES ('20121109141157'); INSERT INTO schema_migrations (version) VALUES ('20130111105833'); -INSERT INTO schema_migrations (version) VALUES ('20130704160000'); - INSERT INTO schema_migrations (version) VALUES ('20130729120232'); INSERT INTO schema_migrations (version) VALUES ('20130730145452'); @@ -1249,32 +1029,6 @@ INSERT INTO schema_migrations (version) VALUES ('20140225143238'); INSERT INTO schema_migrations (version) VALUES ('20140318103544'); -INSERT INTO schema_migrations (version) VALUES ('90000000000000'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000001'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000002'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000003'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000004'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000005'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000006'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000007'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000008'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000009'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000010'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000011'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000012'); - -INSERT INTO schema_migrations (version) VALUES ('90000000000013'); +INSERT INTO schema_migrations (version) VALUES ('20140328105448'); -INSERT INTO schema_migrations (version) VALUES ('90000000000014'); +INSERT INTO schema_migrations (version) VALUES ('20140402135726'); diff --git a/db/structure_with_views.sql b/db/structure_with_views.sql index 89e3e474ee..66e30593ac 100644 --- a/db/structure_with_views.sql +++ b/db/structure_with_views.sql @@ -501,6 +501,9 @@ CREATE TABLE `inventory_pools` ( `print_contracts` tinyint(1) DEFAULT '1', `opening_hours` text COLLATE utf8_unicode_ci, `address_id` int(11) DEFAULT NULL, + `automatic_suspension` tinyint(1) NOT NULL DEFAULT '0', + `automatic_suspension_reason` text COLLATE utf8_unicode_ci, + `automatic_access` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_inventory_pools_on_name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -1005,7 +1008,7 @@ CREATE TABLE `schema_migrations` ( LOCK TABLES `schema_migrations` WRITE; /*!40000 ALTER TABLE `schema_migrations` DISABLE KEYS */; -INSERT INTO `schema_migrations` VALUES ('20101213125330'),('20110111175705'),('20110117113700'),('20110119193618'),('20110201160119'),('20110222163245'),('20110318110901'),('20110523133506'),('20110617090905'),('20110704075302'),('20110815110417'),('20110921134810'),('20111123154235'),('20111215221843'),('20120106214650'),('20120301140904'),('20120424080000'),('20120424080001'),('20120427113142'),('20120523134739'),('20120618143839'),('20120619083752'),('20120806140527'),('20120806203246'),('20120806203332'),('20120921102118'),('20121109141157'),('20130111105833'),('20130729120232'),('20130730145452'),('20130823104438'),('20130906084646'),('20130923141326'),('20130924180000'),('20130924180001'),('20131118144431'),('20131121171123'),('20140115134047'),('20140116125357'),('20140203140055'),('20140214111545'),('20140225143238'),('20140318103544'); +INSERT INTO `schema_migrations` VALUES ('20101213125330'),('20110111175705'),('20110117113700'),('20110119193618'),('20110201160119'),('20110222163245'),('20110318110901'),('20110523133506'),('20110617090905'),('20110704075302'),('20110815110417'),('20110921134810'),('20111123154235'),('20111215221843'),('20120106214650'),('20120301140904'),('20120424080000'),('20120424080001'),('20120427113142'),('20120523134739'),('20120618143839'),('20120619083752'),('20120806140527'),('20120806203246'),('20120806203332'),('20120921102118'),('20121109141157'),('20130111105833'),('20130729120232'),('20130730145452'),('20130823104438'),('20130906084646'),('20130923141326'),('20130924180000'),('20130924180001'),('20131118144431'),('20131121171123'),('20140115134047'),('20140116125357'),('20140203140055'),('20140214111545'),('20140225143238'),('20140318103544'),('20140328105448'),('20140402135726'); /*!40000 ALTER TABLE `schema_migrations` ENABLE KEYS */; UNLOCK TABLES; @@ -1271,4 +1274,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2014-03-21 10:55:19 +-- Dump completed on 2014-04-08 13:31:53 diff --git a/domina/execution/feature_tasks.yml b/domina/execution/feature_tasks.yml index 08e2f2e9ca..e49e372345 100644 --- a/domina/execution/feature_tasks.yml +++ b/domina/execution/feature_tasks.yml @@ -43,6 +43,10 @@ scripts: cucumber: body: bundle exec cucumber -p default "features/technical/contract/update_lines_model.feature" +- name: technical/user/suspend + scripts: + cucumber: + body: bundle exec cucumber -p default "features/technical/user/suspend.feature" - name: technical/field/field_instance_methods scripts: cucumber: @@ -95,10 +99,6 @@ scripts: cucumber: body: bundle exec cucumber -p default "features/availability_story.feature" -- name: automatische_sperrung - scripts: - cucumber: - body: bundle exec cucumber -p default "features/automatische_sperrung.feature" - name: examples/verfuegbarkeit scripts: cucumber: @@ -443,6 +443,10 @@ scripts: cucumber: body: bundle exec cucumber -p default "features/examples/zweck.feature" +- name: examples/Software-erfassen + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/Software-erfassen.feature" - name: examples/hinzufuegen scripts: cucumber: diff --git a/domina/execution/features/diverse_features.yml b/domina/execution/features/diverse_features.yml index 7b9a378c65..65881b93e0 100644 --- a/domina/execution/features/diverse_features.yml +++ b/domina/execution/features/diverse_features.yml @@ -1,16 +1,108 @@ -- name: administration/wartungsmodus +- name: examples/benutzerverwaltung.feature scripts: cucumber: - body: bundle exec cucumber -p default "features/administration/wartungsmodus.feature" -- name: examples/benutzerverwaltung13 + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung.feature" +- name: examples/benutzerverwaltung1.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung1.feature" +- name: examples/benutzerverwaltung2.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung2.feature" +- name: examples/benutzerverwaltung3.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung3.feature" +- name: examples/benutzerverwaltung4.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung4.feature" +- name: examples/benutzerverwaltung5.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung5.feature" +- name: examples/benutzerverwaltung6.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung6.feature" +- name: examples/benutzerverwaltung7.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung7.feature" +- name: examples/benutzerverwaltung8.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung8.feature" +- name: examples/benutzerverwaltung9.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung9.feature" +- name: examples/benutzerverwaltung10.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung10.feature" +- name: examples/benutzerverwaltung11.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung11.feature" +- name: examples/benutzerverwaltung12.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung12.feature" +- name: examples/benutzerverwaltung13.feature scripts: cucumber: body: bundle exec cucumber -p default "features/examples/benutzerverwaltung13.feature" -- name: examples/timeline +- name: examples/benutzerverwaltung14.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung14.feature" +- name: examples/benutzerverwaltung15.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/benutzerverwaltung15.feature" +- name: examples/passwort.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort.feature" +- name: examples/passwort1.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort1.feature" +- name: examples/passwort2.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort2.feature" +- name: examples/passwort3.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort3.feature" +- name: examples/passwort4.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort4.feature" +- name: examples/passwort5.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort5.feature" +- name: examples/passwort6.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort6.feature" +- name: examples/passwort7.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort7.feature" +- name: examples/passwort8.feature + scripts: + cucumber: + body: bundle exec cucumber -p default "features/examples/passwort8.feature" +- name: examples/passwort9.feature scripts: cucumber: - body: bundle exec cucumber -p default "features/examples/timeline.feature" -- name: manage/delegation + body: bundle exec cucumber -p default "features/examples/passwort9.feature" +- name: examples/passwort10.feature scripts: cucumber: - body: bundle exec cucumber -p default "features/manage/delegation.feature" + body: bundle exec cucumber -p default "features/examples/passwort10.feature" diff --git a/domina/execution/rspec_tasks.yml b/domina/execution/rspec_tasks.yml index e03d0ca906..9ea840f63c 100644 --- a/domina/execution/rspec_tasks.yml +++ b/domina/execution/rspec_tasks.yml @@ -3,3 +3,7 @@ scripts: rspec: body: bundle exec rspec "spec/controllers/hslu_ldap_controller_spec.rb" +- name: controllers ldap_controller + scripts: + rspec: + body: bundle exec rspec "spec/controllers/ldap_controller_spec.rb" diff --git a/domina/lib/domina/database.rb b/domina/lib/domina/database.rb index 3f66ea8d12..6f5c83bdf9 100644 --- a/domina/lib/domina/database.rb +++ b/domina/lib/domina/database.rb @@ -5,12 +5,12 @@ module Database class << self def create_db config - puts Domina::System.execute_cmd! "mysql -u#{config['username']} --password=#{config['password']} -e 'drop database if exists #{config['database']}'" - puts Domina::System.execute_cmd! "mysql -u#{config['username']} --password=#{config['password']} -e 'create database if not exists #{config['database']}'" + puts Domina::System.execute_cmd! "mysql -u #{config['username']} --password=#{config['password']} -e 'drop database if exists #{config['database']}'" + puts Domina::System.execute_cmd! "mysql -u #{config['username']} --password=#{config['password']} -e 'create database if not exists #{config['database']}'" end def drop_db config - puts Domina::System.execute_cmd! "mysql -u#{config['username']} --password=#{config['password']} -e 'drop database if exists #{config['database']}'" + puts Domina::System.execute_cmd! "mysql -u #{config['username']} --password=#{config['password']} -e 'drop database if exists #{config['database']}'" end end diff --git a/factories/inventory_pool_factory.rb b/factories/inventory_pool_factory.rb index 7fee558d7b..5bcc08d6b2 100644 --- a/factories/inventory_pool_factory.rb +++ b/factories/inventory_pool_factory.rb @@ -8,6 +8,7 @@ email { Faker::Internet.email } contract_url { email } shortname { UUIDTools::UUID.random_create.to_s[0..5].upcase } + automatic_suspension { false } end -end \ No newline at end of file +end diff --git a/factories/model_factory.rb b/factories/model_factory.rb index 1f272be9ee..c0b4f0340f 100644 --- a/factories/model_factory.rb +++ b/factories/model_factory.rb @@ -2,13 +2,13 @@ factory :model do name do - name = Faker::Name.name + name = Faker::Commerce.product_name while(Model.find_by_name(name)) do - name = Faker::Name.name + name = Faker::Commerce.product_name end name end - manufacturer { Faker::Name.name } + manufacturer { Faker::Company.name } description { Faker::Lorem.sentence } internal_description { Faker::Lorem.sentence } maintenance_period { rand(4) } @@ -29,4 +29,4 @@ end -end \ No newline at end of file +end diff --git a/features/automatische_sperrung.feature b/features/automatische_sperrung.feature deleted file mode 100644 index 57efd82a93..0000000000 --- a/features/automatische_sperrung.feature +++ /dev/null @@ -1,11 +0,0 @@ -# language: de - -Funktionalität: Automatische Sperrung bei verspäteter Rückgabe - Grundlage: - Angenommen ein Gerätepark ist für die automatische Sperrung bei verspäteter Rückgabe konfiguriert - - Szenario: Automatische Sperrung - Angenommen man ist "Normin" - Und ich habe eine verspätete Rückgabe - Dann werde ich jetzt bis zum 1.1.2099 gesperrt - Und der Sperrgrund ist derjenige, der für diesen Gerätepark konfiguriert wurde diff --git a/features/examples/Software-erfassen.feature b/features/examples/Software-erfassen.feature new file mode 100644 index 0000000000..e43071c779 --- /dev/null +++ b/features/examples/Software-erfassen.feature @@ -0,0 +1,34 @@ +# language: de + +Funktionalität: Software erfassen + +Grundlage: +Angenommen Personas existieren +Und man ist "Mike" + + @javascript + Szenario: Software-Produkt erfassen + Angenommen ich erfasse eine neue Software + Wenn ich einen Produktnamen erfasse + Und ich eine Version erfasse + Und ich einen Hersteller erfasse + Und ich speichere + Dann sind die Informationen dieses Software-Produkts gespeichert + + @javascript + Szenario: Software-Lizenz erfassen + Angenommen es existiert ein Software-Produkt + Wenn ich eine neue Software-Lizenz erfasse + Und ich ein Produkt auswähle + Und eine Inventarnummer vergeben wird + Und ich eine Lizenznummer eingebe + Und ich eine Aktivierungsart eingebe + Und ich eine Lizenzart eingebe + Und ich speichere + Dann sind die Informationen dieser Software-Lizenz gespeichert + + + + + + diff --git a/features/examples/benutzerverwaltung10.feature b/features/examples/benutzerverwaltung10.feature index 6d83edc63e..347faf6825 100644 --- a/features/examples/benutzerverwaltung10.feature +++ b/features/examples/benutzerverwaltung10.feature @@ -9,7 +9,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Gino" Und man befindet sich auf der Editierseite eines Benutzers, der kein Administrator ist und der Zugriffe auf Inventarpools hat Wenn man diesen Benutzer die Rolle Administrator zuweist - Und man speichert den Benutzer + Und ich speichere Dann sieht man die Erfolgsbestätigung Und hat dieser Benutzer die Rolle Administrator Und alle andere Zugriffe auf Inventarpools bleiben beibehalten @@ -18,7 +18,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Gino" Und man befindet sich auf der Editierseite eines Benutzers, der ein Administrator ist und der Zugriffe auf Inventarpools hat Wenn man diesem Benutzer die Rolle Administrator wegnimmt - Und man speichert den Benutzer + Und ich speichere Dann hat dieser Benutzer die Rolle Administrator nicht mehr Und alle andere Zugriffe auf Inventarpools bleiben beibehalten diff --git a/features/examples/benutzerverwaltung11.feature b/features/examples/benutzerverwaltung11.feature index 4b1e5aeb43..68cba1d845 100644 --- a/features/examples/benutzerverwaltung11.feature +++ b/features/examples/benutzerverwaltung11.feature @@ -27,6 +27,6 @@ Funktionalität: Benutzer verwalten | Gruppen-Verwalter | group_manager | | Ausleihe-Verwalter | lending_manager | Und man teilt mehrere Gruppen zu - Und man speichert den Benutzer + Und ich speichere Dann ist der Benutzer mit all den Informationen gespeichert diff --git a/features/examples/benutzerverwaltung12.feature b/features/examples/benutzerverwaltung12.feature index 3fc2084490..845543de2b 100644 --- a/features/examples/benutzerverwaltung12.feature +++ b/features/examples/benutzerverwaltung12.feature @@ -14,7 +14,7 @@ Funktionalität: Benutzer verwalten Und den Vornahmen eingibt Und die Email-Addresse eingibt Und man gibt die Login-Daten ein - Und man speichert den Benutzer + Und ich speichere Dann wird man auf die Benutzerliste ausserhalb der Inventarpools umgeleitet Und man sieht eine Bestätigungsmeldung Und der neue Benutzer wurde erstellt diff --git a/features/examples/benutzerverwaltung13.feature b/features/examples/benutzerverwaltung13.feature index ea71d3329c..6b2d08ad2c 100644 --- a/features/examples/benutzerverwaltung13.feature +++ b/features/examples/benutzerverwaltung13.feature @@ -24,5 +24,5 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Pius" Und man editiert einen Benutzer der Zugriff auf das aktuelle Inventarpool hat Wenn man den Zugriff entfernt - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer keinen Zugriff auf das Inventarpool diff --git a/features/examples/benutzerverwaltung14.feature b/features/examples/benutzerverwaltung14.feature index 890cc95bbe..0ab7d6f8fa 100644 --- a/features/examples/benutzerverwaltung14.feature +++ b/features/examples/benutzerverwaltung14.feature @@ -19,7 +19,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Gino" Und man editiert einen Benutzer der Zugriff auf ein Inventarpool hat Wenn man den Zugriff entfernt - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer keinen Zugriff auf das Inventarpool Szenario: Startseite setzen diff --git a/features/examples/benutzerverwaltung4.feature b/features/examples/benutzerverwaltung4.feature index f7bf62a7c6..e6626f85a5 100644 --- a/features/examples/benutzerverwaltung4.feature +++ b/features/examples/benutzerverwaltung4.feature @@ -10,7 +10,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Mike" Und man editiert einen Benutzer der Zugriff auf das aktuelle Inventarpool hat und keine Gegenstände mehr zurückzugeben hat Wenn man den Zugriff entfernt - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer keinen Zugriff auf das Inventarpool @javascript @upcoming @@ -51,5 +51,5 @@ Funktionalität: Benutzer verwalten | Ausleihe-Verwalter | lending_manager | | Inventar-Verwalter | inventory_manager | Und man teilt mehrere Gruppen zu - Und man speichert den Benutzer + Und ich speichere Dann ist der Benutzer mit all den Informationen gespeichert diff --git a/features/examples/benutzerverwaltung5.feature b/features/examples/benutzerverwaltung5.feature index a120ee2ecd..7364d62008 100644 --- a/features/examples/benutzerverwaltung5.feature +++ b/features/examples/benutzerverwaltung5.feature @@ -15,7 +15,7 @@ Funktionalität: Benutzer verwalten | Group manager | | Lending manager | Wenn man den Zugriff auf "Ausleihe-Verwalter" ändert - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer die Rolle Ausleihe-Verwalter @javascript @@ -23,7 +23,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Pius" Und man editiert einen Benutzer der Ausleihe-Verwalter ist Wenn man den Zugriff auf "Kunde" ändert - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer die Rolle Kunde @javascript @@ -37,7 +37,7 @@ Funktionalität: Benutzer verwalten | Lending manager | | Inventory manager | Wenn man den Zugriff auf "Inventar-Verwalter" ändert - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer die Rolle Inventar-Verwalter @javascript @@ -45,6 +45,6 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Mike" Und man editiert einen Benutzer der kein Zugriff auf das aktuelle Inventarpool hat Wenn man den Zugriff auf "Kunde" ändert - Und man speichert den Benutzer + Und ich speichere Dann sieht man die Erfolgsbestätigung Und hat der Benutzer die Rolle Kunde diff --git a/features/examples/benutzerverwaltung6.feature b/features/examples/benutzerverwaltung6.feature index c6b9a4cd15..4655d5358b 100644 --- a/features/examples/benutzerverwaltung6.feature +++ b/features/examples/benutzerverwaltung6.feature @@ -16,7 +16,7 @@ Funktionalität: Benutzer verwalten | Lending manager | | Inventory manager | Wenn man den Zugriff auf "Inventar-Verwalter" ändert - Und man speichert den Benutzer + Und ich speichere Dann hat der Benutzer die Rolle Inventar-Verwalter @javascript diff --git a/features/examples/benutzerverwaltung7.feature b/features/examples/benutzerverwaltung7.feature index 024641f90d..8f9483d7f7 100644 --- a/features/examples/benutzerverwaltung7.feature +++ b/features/examples/benutzerverwaltung7.feature @@ -16,7 +16,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Pius" Und man editiert einen Benutzer der kein Zugriff auf das aktuelle Inventarpool hat Wenn man ändert die Email - Und man speichert den Benutzer + Und ich speichere Dann sieht man die Erfolgsbestätigung Und die neue Email des Benutzers wurde gespeichert Und der Benutzer hat nach wie vor keinen Zugriff auf das aktuelle Inventarpool diff --git a/features/examples/benutzerverwaltung8.feature b/features/examples/benutzerverwaltung8.feature index 13779c550b..01f56b0dae 100644 --- a/features/examples/benutzerverwaltung8.feature +++ b/features/examples/benutzerverwaltung8.feature @@ -29,7 +29,7 @@ Funktionalität: Benutzer verwalten | Ausleihe-Verwalter | lending_manager | | Inventar-Verwalter | inventory_manager | Und man teilt mehrere Gruppen zu - Und man speichert den Benutzer + Und ich speichere Dann ist der Benutzer mit all den Informationen gespeichert @javascript @@ -39,7 +39,7 @@ Funktionalität: Benutzer verwalten Und man einen Benutzer hinzufügt Und alle Pflichtfelder sind sichtbar und abgefüllt Wenn man ein nicht eingegeben hat - Und man speichert den Benutzer + Und ich speichere Dann sehe ich eine Fehlermeldung Beispiele: diff --git a/features/examples/benutzerverwaltung9.feature b/features/examples/benutzerverwaltung9.feature index c3dfef877d..7b86e66151 100644 --- a/features/examples/benutzerverwaltung9.feature +++ b/features/examples/benutzerverwaltung9.feature @@ -10,7 +10,7 @@ Funktionalität: Benutzer verwalten Angenommen man ist "Mike" Und man editiert einen Benutzer der mal einen Zugriff auf das aktuelle Inventarpool hatte Wenn man den Zugriff auf "Kunde" ändert - Und man speichert den Benutzer + Und ich speichere Dann sieht man die Erfolgsbestätigung Und hat der Benutzer die Rolle Kunde diff --git a/features/examples/geraetepark_grundinformationen.feature b/features/examples/geraetepark_grundinformationen.feature index ed24d57186..b64d89410a 100644 --- a/features/examples/geraetepark_grundinformationen.feature +++ b/features/examples/geraetepark_grundinformationen.feature @@ -17,13 +17,13 @@ Funktionalität: Gerätepark-Grundinformationen | E-Mail | | Beschreibung | | Standard-Vertragsnotiz | - | Verträge drucken | - #| Aut. zuweisen | + | Verträge drucken | + | Automatischer Zugriff | Und ich kann die angegebenen Grundinformationen speichern Dann sehe eine Bestätigung Und sind die Informationen aktualisiert Und ich bleibe auf derselben Ansicht - + @javascript Szenario: Pflichtfelder der Grundinformationen zusammen prüfen Angenommen Personas existieren @@ -35,34 +35,25 @@ Funktionalität: Gerätepark-Grundinformationen | E-Mail | Dann kann das Gerätepark nicht gespeichert werden Und ich sehe eine Fehlermeldung - - @upcoming - Szenario: Aut. zuweisen bei Login über LDAP-Schnittstelle - Angenommen Personas existieren - Und es ist bei mehreren Geräteparks aut. Zuweisung aktiviert - Angenommen ich bin ein Benutzer, der sich zum ersten Mal einloggt - Wenn ich mich einlogge - Dann wird für meine Personendaten aus der Schnittstelle ein neuer Benutzer erstellt - Und ich kriege bei allen Geräteparks mit aut. Zuweisung die Rolle 'Kunde' - - @upcoming + Szenario: Aut. zuweisen beim Benutzererstellen ausserhalb des Geräteparks Angenommen Personas existieren - Und es ist bei mehreren Geräteparks aut. Zuweisung aktiviert - Angenommen ich bin Gino - Und ich erstelle einen neuen Benutzer + Und ich bin Gino + Und es ist bei mehreren Geräteparks aut. Zuweisung aktiviert + Und man befindet sich auf der Benutzerliste + Wenn ich einen Benutzer mit Login "username" und Passwort "password" erstellt habe Dann kriegt der neu erstellte Benutzer bei allen Geräteparks mit aut. Zuweisung die Rolle 'Kunde' - - @upcoming + Szenario: Aut. zuweisen beim Benutzererstellen innerhalb des Geräteparks Angenommen Personas existieren - Und es ist bei mehreren und meinem Gerätepark aut. Zuweisung aktiviert Und ich bin Mike - Wenn ich in meinem Gerätepark einen neuen Benutzer mit Rolle 'Inventar-Verwalter' erstelle + Und es ist bei mehreren Geräteparks aut. Zuweisung aktiviert + Und es ist bei meinem Gerätepark aut. Zuweisung aktiviert + Wenn ich in meinem Gerätepark einen neuen Benutzer mit Rolle 'Inventar-Verwalter' erstelle Dann kriegt der neu erstellte Benutzer bei allen Geräteparks mit aut. Zuweisung ausser meinem die Rolle 'Kunde' Und in meinem Gerätepark hat er die Rolle 'Inventar-Verwalter' - - @upcoming + + @javascript Szenario: Aut. Zuweisen entfernen Angenommen Personas existieren Und ich bin Mike @@ -70,5 +61,9 @@ Funktionalität: Gerätepark-Grundinformationen Wenn ich die aut. Zuweisung deaktiviere Und ich speichere Dann ist die aut. Zuweisung deaktiviert - Angenommen ich bin ein Benutzer, der sich zum ersten Mal einloggt - Dann erhalte ich keinen aut. Zugriff für diesen Gerätepark + Angenommen ich bin Gino + Und man befindet sich auf der Benutzerliste + Und ich einen Benutzer mit Login "username" und Passwort "password" erstellt habe + Angenommen ich bin Mike + Dann kriegt der neu erstellte Benutzer bei dem vorher editierten Gerätepark kein Zugriffsrecht + Und ich logge mich aus diff --git a/features/examples/geraetepark_grundinformationen3.feature b/features/examples/geraetepark_grundinformationen3.feature index f8ecf979ab..99107af981 100644 --- a/features/examples/geraetepark_grundinformationen3.feature +++ b/features/examples/geraetepark_grundinformationen3.feature @@ -26,16 +26,14 @@ Funktionalität: Gerätepark-Grundinformationen | Kurzname | | E-Mail | - @javascript Szenario: Automatische Benutzersperrung bei verspäteter Rückgabe Angenommen persona "Mike" existing Und ich bin Mike - Wenn ich die Grundinformationen des Geräteparks editiere + Wenn ich die Grundinformationen des Geräteparks abfüllen möchte Wenn ich für den Gerätepark die automatische Sperrung von Benutzern mit verspäteten Rückgaben einschalte Dann muss ich einen Sperrgrund angeben Wenn ich speichere Dann ist diese Konfiguration gespeichert Wenn ein Benutzer wegen verspäteter Rückgaben automatisch gesperrt wird - Dann wird er für diesen Gerätepark gesperrt bis zum 1.1.2099 + Dann wird er für diesen Gerätepark gesperrt bis zum '1.1.2099' Und der Sperrgrund ist derjenige, der für diesen Park gespeichert ist - diff --git a/features/examples/inventar.feature b/features/examples/inventar.feature index 6975558528..430dc8cc70 100644 --- a/features/examples/inventar.feature +++ b/features/examples/inventar.feature @@ -12,6 +12,7 @@ Funktionalität: Inventar Dann sieht man Modelle Und man sieht Optionen Und man sieht Pakete + Und man sieht Software @javascript Szenario: Auswahlmöglichkeiten diff --git a/features/examples/vertrag6.feature b/features/examples/vertrag6.feature index 4220a75afd..8f4f117e66 100644 --- a/features/examples/vertrag6.feature +++ b/features/examples/vertrag6.feature @@ -26,5 +26,11 @@ Funktionalität: Vertrag Szenario: Adresse des Verleihers aufführen Angenommen man öffnet einen Vertrag bei der Aushändigung Dann wird unter 'Verleiher/in' der Gerätepark aufgeführt - Wenn in den Einstellungen die Adresse des Verleihers konfiguriert ist - Dann wird darunter die Adresse des Verleihers aufgeführt + Wenn in den globalen Einstellungen die Adresse der Instanz konfiguriert ist + Dann wird unter dem Verleiher diese Adresse angezeigt + + @javascript + Szenario: Adresse des Kunden ohne abschliessenden ", " anzeigen + Angenommen es gibt einen Kunden mit Vertrag wessen Addresse mit ", " endet + Wenn ich einen Vertrag dieses Kunden öffne + Dann wird seine Adresse ohne den abschliessenden ", " angezeigt diff --git a/features/personas/petra.rb b/features/personas/petra.rb index c5f46d5370..0efb3ebcb6 100644 --- a/features/personas/petra.rb +++ b/features/personas/petra.rb @@ -36,7 +36,7 @@ def select_inventory_pool def create_user @language = Language.find_by_locale_name "de-CH" - @user = FactoryGirl.create(:user, :language => @language, :firstname => @@name, :lastname => @@lastname, :login => @@name.downcase, :email => @@email) + @user = FactoryGirl.create(:user, :language => @language, :firstname => @@name, :lastname => @@lastname, :login => @@name.downcase, :email => @@email, :address => (Faker::Address.street_address + ", ")) @user.access_rights.create(:role => :customer, :inventory_pool => @inventory_pool) end diff --git a/features/personas/pius.rb b/features/personas/pius.rb index b384541651..199f6c56ff 100644 --- a/features/personas/pius.rb +++ b/features/personas/pius.rb @@ -4,6 +4,8 @@ # Job: Inventory Pool Manager # +require "#{Rails.root}/features/support/helper.rb" + module Persona class Pius @@ -11,7 +13,7 @@ class Pius @@name = "Pius" @@lastname = Faker::Name.last_name @@email = "pius@zhdk.ch" - @@inventory_pool_name = "A-Ausleihe" + @@inventory_pool_names = ["A-Ausleihe", "IT-Ausleihe", "AV-Technik"] def initialize setup_dependencies @@ -21,6 +23,7 @@ def initialize create_external_user create_user_with_large_hand_over create_users_with_take_backs + create_users_with_overdued_take_backs end end @@ -31,8 +34,10 @@ def setup_dependencies def create_lending_manager_user @language = Language.find_by_locale_name "de-CH" @user = FactoryGirl.create(:user, :language => @language, :firstname => @@name, :lastname => @@lastname, :login => @@name.downcase, :email => @@email) - @inventory_pool = InventoryPool.find_by_name(@@inventory_pool_name) + @inventory_pool = InventoryPool.find_by_name(@@inventory_pool_names.first) + @inventory_pool_2 = InventoryPool.find_by_name(@@inventory_pool_names.second) @user.access_rights.create(:role => :lending_manager, :inventory_pool => @inventory_pool) + @user.access_rights.create(:role => :lending_manager, :inventory_pool => @inventory_pool_2) end def create_external_user @@ -78,5 +83,19 @@ def create_users_with_take_backs contract.sign User.find_by_login("pius") end + def create_users_with_overdued_take_backs + back_to_the_future(Date.today - 5.days) + user = FactoryGirl.create :user + user.access_rights << FactoryGirl.create(:access_right, inventory_pool: @inventory_pool_2, suspended_until: Date.tomorrow, suspended_reason: Faker::Lorem.sentence) + overdued_contract = FactoryGirl.create(:contract, :user => user, :inventory_pool => @inventory_pool_2, :status => :approved) + purpose = FactoryGirl.create :purpose, :description => Faker::Lorem.sentence + model = FactoryGirl.create :model_with_items, inventory_pool: @inventory_pool_2 + overdued_contract.contract_lines << FactoryGirl.create(:contract_line, :purpose => purpose, :contract => overdued_contract, + :item_id => @inventory_pool_2.items.in_stock.where(:model_id => model.id).first.id, + :model => model, :start_date => Date.today, :end_date => (Date.today + 4.days)) + overdued_contract.sign(@user) + back_to_the_present + end + end end diff --git a/features/personas/ramon.rb b/features/personas/ramon.rb index 6b476ee66c..21f44e0068 100644 --- a/features/personas/ramon.rb +++ b/features/personas/ramon.rb @@ -54,7 +54,7 @@ def create_admin_user def create_inventory_pool_a_ausleihe description = "Wichtige Hinweise...\n Bitte die Gegenstände rechtzeitig zurückbringen" contact_details = "A Verleih / ZHdK\nav@zh-dk.ch\n+41 00 00 00 00" - @a_ausleihe = FactoryGirl.create(:inventory_pool, :name => "A-Ausleihe", :description => description, :contact_details => contact_details, :contract_description => "Gerät erhalten", :email => "av@zhdk.ch", :shortname => "A", :default_contract_note => Faker::Lorem.sentence) + @a_ausleihe = FactoryGirl.create(:inventory_pool, :name => "A-Ausleihe", :description => description, :contact_details => contact_details, :contract_description => "Gerät erhalten", :email => "av@zhdk.ch", :shortname => "A", :default_contract_note => Faker::Lorem.sentence, :automatic_suspension => true, :automatic_suspension_reason => Faker::Lorem.sentence) create_christmas_holiday @a_ausleihe end @@ -66,7 +66,7 @@ def create_christmas_holiday inventory_pool def create_inventory_pool_it_ausleihe description = "Bringt die Geräte bitte rechtzeitig zurück" contact_details = "IT Verleih / ZHdK\nav@zh-dk.ch\n+41 00 00 00 00" - @it_ausleihe = FactoryGirl.create(:inventory_pool, :name => "IT-Ausleihe", :description => description, :contact_details => contact_details, :contract_description => "Gerät erhalten", :email => "it@zhdk.ch", :shortname => "IT") + @it_ausleihe = FactoryGirl.create(:inventory_pool, :name => "IT-Ausleihe", :description => description, :contact_details => contact_details, :contract_description => "Gerät erhalten", :email => "it@zhdk.ch", :shortname => "IT", :automatic_suspension => true, :automatic_suspension_reason => Faker::Lorem.sentence) create_christmas_holiday @it_ausleihe end diff --git a/features/step_definitions/automatischer_email_versand_steps.rb.rb b/features/step_definitions/automatischer_email_versand_steps.rb.rb index facee4398c..4bc334f339 100644 --- a/features/step_definitions/automatischer_email_versand_steps.rb.rb +++ b/features/step_definitions/automatischer_email_versand_steps.rb.rb @@ -44,7 +44,7 @@ ActionMailer::Base.deliveries.empty?.should be_true @current_user.notifications.reload.empty?.should be_true - User.remind_all + User.remind_and_suspend_all ActionMailer::Base.deliveries.empty?.should be_false @current_user.notifications.reload.empty?.should be_false @@ -59,7 +59,7 @@ ActionMailer::Base.deliveries.empty?.should be_true @current_user.notifications.reload.empty?.should be_false - User.remind_all + User.remind_and_suspend_all ActionMailer::Base.deliveries.empty?.should be_false @current_user.notifications.reload.empty?.should be_false diff --git a/features/step_definitions/examples/ausleihe_steps.rb b/features/step_definitions/examples/ausleihe_steps.rb index e3272608ca..145dc553d0 100644 --- a/features/step_definitions/examples/ausleihe_steps.rb +++ b/features/step_definitions/examples/ausleihe_steps.rb @@ -232,6 +232,7 @@ end Wenn /^ich bei einem Gegenstand eine Inspektion durchführen$/ do + find(".line[data-line-type='item_line']", match: :first) within all(".line[data-line-type='item_line']").to_a.sample.find(".multibutton") do @item = ContractLine.find(JSON.parse(find("[data-ids]")["data-ids"]).first).item find(".dropdown-toggle").hover diff --git a/features/step_definitions/examples/benutzerverwaltung_steps.rb b/features/step_definitions/examples/benutzerverwaltung_steps.rb index a7dd7249e1..956312902a 100644 --- a/features/step_definitions/examples/benutzerverwaltung_steps.rb +++ b/features/step_definitions/examples/benutzerverwaltung_steps.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- Angenommen /^man ist Inventar\-Verwalter oder Ausleihe\-Verwalter$/ do - step 'man ist "%s"' % ["Mike", "Pius"].shuffle.first + step 'man ist "%s"' % ["Mike", "Pius"].sample ar = @current_user.access_rights.active.where(role: [:lending_manager, :inventory_manager]).first ar.should_not be_nil @inventory_pool = ar.inventory_pool @@ -360,7 +360,7 @@ Dann /^man kann sie einem anderen Gerätepark als Besitzer zuweisen$/ do attributes = { - owner_id: (InventoryPool.pluck(:id) - [@inventory_pool.id]).shuffle.first + owner_id: (InventoryPool.pluck(:id) - [@inventory_pool.id]).sample } @item.owner_id.should_not == attributes[:owner_id] @@ -372,7 +372,7 @@ Dann /^man kann die verantwortliche Abteilung eines Gegenstands frei wählen$/ do item = @inventory_pool.own_items.find &:in_stock? attributes = { - inventory_pool_id: (InventoryPool.pluck(:id) - [@inventory_pool.id]).shuffle.first + inventory_pool_id: (InventoryPool.pluck(:id) - [@inventory_pool.id]).sample } item.inventory_pool_id.should_not == attributes[:inventory_pool_id] @@ -618,10 +618,6 @@ @user.reload.has_role?(:admin).should be_true end -Wenn(/^man speichert den Benutzer$/) do - find(".button", text: _("Save")).click -end - Dann(/^alle andere Zugriffe auf Inventarpools bleiben beibehalten$/) do (@previous_access_rights - @user.access_rights.reload).should be_empty end diff --git a/features/step_definitions/examples/bestellungen_steps.rb b/features/step_definitions/examples/bestellungen_steps.rb index 0432fb04a7..77a0471e08 100644 --- a/features/step_definitions/examples/bestellungen_steps.rb +++ b/features/step_definitions/examples/bestellungen_steps.rb @@ -209,7 +209,7 @@ def ensure_suspended_user(user, inventory_pool) find("#purpose").set Faker::Lorem.paragraph find("#note").set Faker::Lorem.paragraph find("button.green[data-hand-over]").click - find("#error", text: _("You don't have permission")) + find("#error", text: _("You don't have permission to perform this action")) end end @@ -233,5 +233,5 @@ def ensure_suspended_user(user, inventory_pool) find("input[data-assign-item]").click find("li.ui-menu-item a", match: :first).click end - find("#flash .error", text: _("You don't have permission")) + find("#flash .error", text: _("You don't have permission to perform this action")) end diff --git a/features/step_definitions/examples/geraetepark_grundinformationen_steps.rb b/features/step_definitions/examples/geraetepark_grundinformationen_steps.rb index c58cd36898..6521b143c1 100644 --- a/features/step_definitions/examples/geraetepark_grundinformationen_steps.rb +++ b/features/step_definitions/examples/geraetepark_grundinformationen_steps.rb @@ -12,6 +12,8 @@ within(".row.padding-inset-s", match: :prefer_exact, text: field_name) do if field_name == "Verträge drucken" first("input").set false + elsif field_name == "Automatischer Zugriff" + first("input").set true else first("input,textarea").set (field_name == "E-Mail" ? "test@test.ch" : "test") end @@ -29,6 +31,8 @@ within(".row.padding-inset-s", match: :prefer_exact, text: field_name) do if field_name == "Verträge drucken" first("input").selected?.should be_false + elsif field_name == "Automatischer Zugriff" + first("input").selected?.should be_true else first("input,textarea").value.should == (field_name == "E-Mail" ? "test@test.ch" : "test") end @@ -116,3 +120,111 @@ Wenn(/^ich das gekennzeichnete "(.*?)" des Geräteparks leer lasse$/) do |field_name| first(".row.emboss", match: :prefer_exact, :text => field_name).first("input").set "" end + +Wenn(/^ich für den Gerätepark die automatische Sperrung von Benutzern mit verspäteten Rückgaben einschalte$/) do + check "inventory_pool[automatic_suspension]" +end + +Dann(/^muss ich einen Sperrgrund angeben$/) do + fill_in "inventory_pool[automatic_suspension_reason]", with: "" + step 'ich speichere' + step 'ich sehe eine Fehlermeldung' + @reason = Faker::Lorem.sentence + fill_in "inventory_pool[automatic_suspension_reason]", with: @reason + step 'ich speichere' +end + +Dann(/^ist diese Konfiguration gespeichert$/) do + page.has_selector?("#flash .notice") + @current_inventory_pool.reload + @current_inventory_pool.automatic_suspension.should be_true + @current_inventory_pool.automatic_suspension_reason.should == @reason +end + +Wenn(/^ein Benutzer wegen verspäteter Rückgaben automatisch gesperrt wird$/) do + user_id = ContractLine.by_inventory_pool(@current_inventory_pool).to_take_back.where("end_date < CURDATE()").pluck(:user_id).uniq.sample + @user = User.find user_id + @user.suspend +end + +Dann(/^wird er für diesen Gerätepark gesperrt bis zum '(\d+)\.(\d+)\.(\d+)'$/) do |day, month, year| + @access_right = @user.access_right_for(@current_inventory_pool) + @access_right.suspended_until.should == Date.new(year.to_i, month.to_i, day.to_i) +end + +Dann(/^der Sperrgrund ist derjenige, der für diesen Park gespeichert ist$/) do + @access_right.suspended_reason.should == @reason +end + +Angenommen(/^ich editiere meinen Gerätepark$/) do + visit manage_edit_inventory_pool_path(@current_inventory_pool) +end + +Wenn(/^ich die aut\. Zuweisung deaktiviere$/) do + within(".row.padding-inset-s", match: :prefer_exact, text: _("Automatic access")) do + first("input").set false + end +end + +Dann(/^ist die aut\. Zuweisung deaktiviert$/) do + @current_inventory_pool.reload.automatic_access.should be_false + @ip = @current_inventory_pool +end + +Angenommen(/^man ist ein Benutzer, der sich zum ersten Mal einloggt$/) do + @username = Faker::Internet.user_name + @password = Faker::Internet.password + step %Q(ich einen Benutzer mit Login "#{@username}" und Passwort "#{@password}" erstellt habe) +end + +Angenommen(/^es ist bei mehreren Geräteparks aut. Zuweisung aktiviert$/) do + InventoryPool.all.sample(rand(2..4)).each do |inventory_pool| + inventory_pool.update_attributes automatic_access: true + end + @inventory_pools_with_automatic_access = InventoryPool.where(automatic_access: true) + @inventory_pools_with_automatic_access.count.should > 1 +end + +Angenommen(/^es ist bei meinem Gerätepark aut. Zuweisung aktiviert$/) do + @current_inventory_pool.update_attributes automatic_access: true + @inventory_pools_with_automatic_access = InventoryPool.where(automatic_access: true) + @inventory_pools_with_automatic_access.count.should > 1 +end + +Dann(/^kriegt der neu erstellte Benutzer bei allen Geräteparks mit aut. Zuweisung die Rolle 'Kunde'$/) do + @user.access_rights.count.should == @inventory_pools_with_automatic_access.count + @user.access_rights.pluck(:inventory_pool_id).should == @inventory_pools_with_automatic_access.pluck(:id) + @user.access_rights.all? {|ar| ar.role == :customer}.should be_true +end + +Wenn(/^ich in meinem Gerätepark einen neuen Benutzer mit Rolle 'Inventar\-Verwalter' erstelle$/) do + steps %Q{ + Wenn man in der Benutzeransicht ist + Und man einen Benutzer hinzufügt + Und die folgenden Informationen eingibt + | Nachname | + | Vorname | + | E-Mail | + Und man gibt die Login-Daten ein + Und man gibt eine Badge-Id ein + Und eine der folgenden Rollen auswählt + | tab | role | + | Inventar-Verwalter | inventory_manager | + Und ich speichere + } + @user = User.find_by_lastname "test" +end + +Dann(/^kriegt der neu erstellte Benutzer bei allen Geräteparks mit aut\. Zuweisung ausser meinem die Rolle 'Kunde'$/) do + @user.access_rights.count.should == @inventory_pools_with_automatic_access.count + @user.access_rights.pluck(:inventory_pool_id).should == @inventory_pools_with_automatic_access.pluck(:id) + @user.access_rights.where("inventory_pool_id != ?", @current_inventory_pool ).all? {|ar| ar.role == :customer}.should be_true +end + +Dann(/^in meinem Gerätepark hat er die Rolle 'Inventar\-Verwalter'$/) do + @user.access_right_for(@current_inventory_pool).role.should == :inventory_manager +end + +Dann(/^kriegt der neu erstellte Benutzer bei dem vorher editierten Gerätepark kein Zugriffsrecht$/) do + @user.access_right_for(@ip).should be_nil +end diff --git a/features/step_definitions/examples/gruppen_steps.rb b/features/step_definitions/examples/gruppen_steps.rb index f8fb7e01c5..12c851b3ed 100644 --- a/features/step_definitions/examples/gruppen_steps.rb +++ b/features/step_definitions/examples/gruppen_steps.rb @@ -90,7 +90,7 @@ all("[name*='users'][name*='id']", visible: false).each do |existing_user_line| existing_user_line.first(:xpath, "./..").find(".button[data-remove-user]", :text => _("Remove")).click end - user = (@current_inventory_pool.users-@group.users).shuffle.first + user = (@current_inventory_pool.users-@group.users).sample @users = [user] find("input[data-search-users]").set user.name find(".ui-menu-item a", match: :prefer_exact, :text => user.name).click diff --git a/features/step_definitions/examples/inventar_steps.rb b/features/step_definitions/examples/inventar_steps.rb index d0f9e5b7b9..d86e1930ee 100644 --- a/features/step_definitions/examples/inventar_steps.rb +++ b/features/step_definitions/examples/inventar_steps.rb @@ -592,9 +592,15 @@ def parsed_query end Dann /^sieht man keine Modelle, denen keine Gegenstänge zugewiesen unter keinem der vorhandenen Reiter$/ do - all(".inlinetabs .tab").each do |tab| + find("#list-tabs") + all("#list-tabs .inline-tab-item").each do |tab| tab.click - page.should_not have_selector(".model.line .toggle .text", :text => "0") + find("#inventory .line[data-type]", match: :first) + if tab.text == _("Unused Models") + page.should_not have_selector(".line[data-type='model'] button[data-type='inventory-expander'] .arrow.right") + else + page.should_not have_selector(".line[data-type='model'] button[data-type='inventory-expander']", text: "0") + end end end diff --git a/features/step_definitions/examples/passwort_steps.rb b/features/step_definitions/examples/passwort_steps.rb index 9906105976..2c29378c7f 100644 --- a/features/step_definitions/examples/passwort_steps.rb +++ b/features/step_definitions/examples/passwort_steps.rb @@ -1,9 +1,13 @@ # encoding: utf-8 -def fill_in_required_user_information - find(".row.emboss", match: :prefer_exact, text: _("Last name")).find("input").set "test" - find(".row.emboss", match: :prefer_exact, text: _("First name")).find("input").set "test" - find(".row.emboss", match: :prefer_exact, text: _("E-Mail")).find("input").set "test@test.ch" +def fill_in_user_information(attrs) + find(".row.emboss", match: :prefer_exact, text: _("Last name")).find("input").set attrs[:firstname] if attrs[:lastname] + find(".row.emboss", match: :prefer_exact, text: _("First name")).find("input").set attrs[:firstname] if attrs[:firstname] + find(".row.emboss", match: :prefer_exact, text: _("E-Mail")).find("input").set attrs[:email] if attrs[:email] + find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set attrs[:login] if attrs[:login] + find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set attrs[:password] if attrs[:password] + find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set attrs[:password_confirmation] if attrs[:password_confirmation] + click_button _("Save") end Angenommen(/^man befindet sich auf der Benutzerliste$/) do @@ -17,15 +21,9 @@ def fill_in_required_user_information Wenn(/^ich einen Benutzer mit Login "(.*?)" und Passwort "(.*?)" erstellt habe$/) do |login, password| step "man einen Benutzer hinzufügt" - fill_in_required_user_information - - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "#{@login = login}" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "#{@password = password}" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "#{password}" - - click_button _("Save") + fill_in_user_information(firstname: "test", lastname: "test", email: "test@test.ch", login: login, password: password, password_confirmation: password) page.has_content? _("List of Users") - @user = User.find_by_login "#{@login}" + @user = User.find_by_login login DatabaseAuthentication.find_by_user_id(@user.id).should_not be_nil end @@ -43,11 +41,8 @@ def fill_in_required_user_information page.should have_content @user.short_name end -Wenn(/^ich das Passwort von "(.*?)" auf "(.*?)" ändere$/) do |persona, new_password| - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "#{@password = new_password}" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "#{new_password}" - - step "man speichert den Benutzer" +Wenn(/^ich das Passwort von "(.*?)" auf "(.*?)" ändere$/) do |persona, password| + fill_in_user_information(password: password, password_confirmation: password) page.has_content? _("List of Users") @user = User.find_by_login "#{User.find_by_login("normin").login}" DatabaseAuthentication.find_by_user_id(@user.id).should_not be_nil @@ -64,71 +59,43 @@ def fill_in_required_user_information sleep(0.66) end -Wenn(/^ich den Benutzernamen auf "(.*?)" und das Passwort auf "(.*?)" ändere$/) do |new_username, new_password| - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "#{@login = new_username}" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "#{@password = new_password}" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "#{new_password}" - - step "man speichert den Benutzer" +Wenn(/^ich den Benutzernamen auf "(.*?)" und das Passwort auf "(.*?)" ändere$/) do |login, password| + fill_in_user_information(login: login, password: password, password_confirmation: password) page.has_content? _("List of Users") - @user = User.find_by_login "#{@login}" + @user = User.find_by_login login DatabaseAuthentication.find_by_user_id(@user.id).should_not be_nil end -Wenn(/^ich den Benutzernamen von "(.*?)" auf "(.*?)" ändere$/) do |person, new_username| - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "#{@login = new_username}" - - step "man speichert den Benutzer" +Wenn(/^ich den Benutzernamen von "(.*?)" auf "(.*?)" ändere$/) do |person, login| + fill_in_user_information(login: login) page.has_content? _("List of Users") - @user = User.find_by_login @login + @user = User.find_by_login login DatabaseAuthentication.find_by_user_id(@user.id).should_not be_nil end Wenn(/^ich einen Benutzer ohne Loginnamen erstellen probiere$/) do step "man einen Benutzer hinzufügt" - fill_in_required_user_information - - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "newpassword}" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "newpassword" - - click_button _("Save") + fill_in_user_information(firstname: "test", lastname: "test", email: "test@test.ch", password: "newpassword", password_confirmation: "newpassword") end Wenn(/^ich einen Benutzer mit falscher Passwort\-Bestätigung erstellen probiere$/) do step "man einen Benutzer hinzufügt" - fill_in_required_user_information - - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "new_username" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "newpassword" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "wrongconfir" - - click_button _("Save") + fill_in_user_information(firstname: "test", lastname: "test", email: "test@test.ch", login: "new_username", password: "newpassword", password_confirmation: "wrongconfir") end Wenn(/^ich einen Benutzer mit fehlenden Passwortangaben erstellen probiere$/) do step "man einen Benutzer hinzufügt" - fill_in_required_user_information - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "new_username" - click_button _("Save") + fill_in_user_information(firstname: "test", lastname: "test", email: "test@test.ch", login: "new_username") end Wenn(/^ich den Benutzernamen von nicht ausfülle und speichere$/) do - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "a" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "newpassword" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "newpassword" - step "man speichert den Benutzer" + fill_in_user_information(login: "a", password: "newpassword", password_confirmation: "newpassword") end Wenn(/^ich eine falsche Passwort\-Bestägigung eingebe und speichere$/) do - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "newlogin" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set "newpassword" - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set "newpasswordxyz" - step "man speichert den Benutzer" + fill_in_user_information(login: "newlogin", password: "newpassword", password_confirmation: "newpasswordxyz") end Wenn(/^ich die Passwort\-Angaben nicht eingebe und speichere$/) do - find(".row.emboss", match: :prefer_exact, text: _("Login")).find("input").set "newlogin" - find(".row.emboss", match: :prefer_exact, text: _("Password")).find("input").set " " - find(".row.emboss", match: :prefer_exact, text: _("Password Confirmation")).find("input").set " " - step "man speichert den Benutzer" + fill_in_user_information(login: "newlogin", password: " ", password_confirmation: " ") end diff --git a/features/step_definitions/examples/probleme_steps.rb b/features/step_definitions/examples/probleme_steps.rb index 4eb391dee1..8352f921d3 100644 --- a/features/step_definitions/examples/probleme_steps.rb +++ b/features/step_definitions/examples/probleme_steps.rb @@ -153,9 +153,9 @@ def open_inspection_for_line(line_id) Angenommen /^eine Gegenstand ist defekt$/ do if @event == "hand_over" - @item = @ip.items.broken.first + @item = @ip.items.broken.sample step 'I add an item to the hand over' - @line_id = find("input[value='#{@item.inventory_code}']").find(:xpath, "ancestor::div[@data-id]")["data-id"].to_i + @line_id = find("input[value='#{@item.inventory_code}']").find(:xpath, "ancestor::div[@data-id]")["data-id"] elsif @event == "take_back" @line_id = find(".line[data-line-type='item_line']", match: :first)[:"data-id"] step 'markiere ich den Gegenstand als defekt' @@ -164,9 +164,9 @@ def open_inspection_for_line(line_id) Angenommen /^eine Gegenstand ist unvollständig$/ do if @event == "hand_over" - @item = @ip.items.incomplete.first + @item = @ip.items.incomplete.sample step 'I add an item to the hand over' - @line_id = find(".line [data-assign-item][disabled]", match: :first).find(:xpath, "./../../..")[:"data-id"] + @line_id = find("input[value='#{@item.inventory_code}']").find(:xpath, "ancestor::div[@data-id]")["data-id"] elsif @event == "take_back" @line_id = find(".line[data-line-type='item_line']", match: :first)[:"data-id"] step 'markiere ich den Gegenstand als unvollständig' diff --git a/features/step_definitions/examples/vertrag_steps.rb b/features/step_definitions/examples/vertrag_steps.rb index 0e97e7e088..d9978bbd49 100644 --- a/features/step_definitions/examples/vertrag_steps.rb +++ b/features/step_definitions/examples/vertrag_steps.rb @@ -213,3 +213,29 @@ expect(names.sort == names).to be_true end end + +Dann(/^wird unter 'Verleiher\/in' der Gerätepark aufgeführt$/) do + find(".inventory_pool").has_content? @contract.inventory_pool.name +end + +Angenommen(/^es gibt einen Kunden mit Vertrag wessen Addresse mit "(.*?)" endet$/) do |arg1| + @user = @current_inventory_pool.users.customers.find {|u| u.contracts.where(status: [:signed, :closed]).exists? and u.address =~ /, $/} + @user.should_not be_nil +end + +Wenn(/^ich einen Vertrag dieses Kunden öffne$/) do + visit manage_contract_path(@current_inventory_pool, @user.contracts.where(status: [:signed, :closed]).sample) +end + +Dann(/^wird seine Adresse ohne den abschliessenden "(.*?)" angezeigt$/) do |arg1| + find(".street").text.should == @user.address.chomp(", ") +end + +Wenn(/^in den globalen Einstellungen die Adresse der Instanz konfiguriert ist$/) do + @address = Setting::CONTRACT_LENDING_PARTY_STRING + @address.should_not be_nil +end + +Dann(/^wird unter dem Verleiher diese Adresse angezeigt$/) do + all(".inventory_pool span")[1].text == @address +end diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 1114909248..3b5050cba9 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -61,6 +61,10 @@ visit "/logout" end +When 'ich logge mich aus' do + visit "/logout" +end + When /^I am redirected to the "([^"]*)" section$/ do |section_name| find("nav#topbar .topbar-navigation .active", match: :prefer_exact, text: _(section_name)) end diff --git a/features/step_definitions/manage/acknowledge/add_item_steps.rb b/features/step_definitions/manage/acknowledge/add_item_steps.rb index 116ff353e1..28f70263ca 100644 --- a/features/step_definitions/manage/acknowledge/add_item_steps.rb +++ b/features/step_definitions/manage/acknowledge/add_item_steps.rb @@ -69,9 +69,8 @@ av.changes.keys.size > 1 end - total_quantity_in_ip = @current_inventory_pool.items.borrowable.select{|i| i.model == @model}.count - @new_start_date = av.changes.select{|k, v| v.values.any? {|v| v[:in_quantity] < total_quantity_in_ip }}.keys.first - + init_start_date = Date.parse find("#add-start-date").value + @new_start_date = av.changes.select{|k, v| k > init_start_date }.keys.first fill_in "add-input", with: @model.name find("a.ui-corner-all", match: :first) @init_aval = find("a.ui-corner-all", match: :prefer_exact, text: @model.name).find("div.col1of4:nth-child(2) > div:nth-child(1)").text diff --git a/features/step_definitions/manage/delegation_steps.rb b/features/step_definitions/manage/delegation_steps.rb index a3d91bbb6d..39f8acccb6 100644 --- a/features/step_definitions/manage/delegation_steps.rb +++ b/features/step_definitions/manage/delegation_steps.rb @@ -597,6 +597,11 @@ Wenn(/^ich eine Kontaktperson wähle, der für diesen Gerätepark gesperrt ist$/) do delegated_user = @delegation.delegated_users.select{|u| u.suspended? @current_inventory_pool}.sample + delegated_user ||= begin + user = @delegation.delegated_users.sample + ensure_suspended_user(user, @current_inventory_pool) + user + end find("input#user-id", match: :first).set delegated_user.name find(".ui-menu-item a", match: :first, text: delegated_user.name).click end diff --git a/features/step_definitions/manage/linegroup/selection_steps.rb b/features/step_definitions/manage/linegroup/selection_steps.rb index 0fc85dd745..29b86c575e 100644 --- a/features/step_definitions/manage/linegroup/selection_steps.rb +++ b/features/step_definitions/manage/linegroup/selection_steps.rb @@ -1,7 +1,7 @@ When /^I open a take back, hand over or I edit a contract$/ do @ip = @current_user.managed_inventory_pools.first possible_types = ["take_back", "hand_over", "contract"] - type = possible_types.shuffle.first + type = possible_types.sample case type when "take_back" @customer = @ip.users.detect {|x| x.contracts.signed.size > 0} diff --git a/features/step_definitions/technical/user_steps.rb b/features/step_definitions/technical/user_steps.rb new file mode 100644 index 0000000000..874aa449d4 --- /dev/null +++ b/features/step_definitions/technical/user_steps.rb @@ -0,0 +1,27 @@ +Given(/^there are at least (\d+) users with late take backs from at least (\d+) inventory pools where automatic suspension is activated$/) do |users_n, ips_n| + cls = ContractLine.to_take_back.where("end_date < CURDATE()").uniq{|cl| cl.contract.inventory_pool and cl.contract.user} + cls.count.should >= 2 + @contracts = cls.map(&:contract) +end + +When(/^the cronjob executes the rake task for reminding and suspending all late users$/) do + User.remind_and_suspend_all +end + +Then(/^every such user is suspended until '(\d+)\.(\d+)\.(\d+)' in the corresponding inventory pool$/) do |day, month, year| + @contracts.each do |c| + ip = c.inventory_pool + u = c.user + ar = u.access_right_for(ip) + ar.suspended_until.should == Date.new(year.to_i, month.to_i, day.to_i) + end +end + +Then(/^the suspended reason is the one configured for the corresponding inventory pool$/) do + @contracts.each do |c| + ip = c.inventory_pool + u = c.user + ar = u.access_right_for(ip) + ar.suspended_reason == ip.automatic_suspension_reason + end +end diff --git a/features/technical/user/suspend.feature b/features/technical/user/suspend.feature new file mode 100644 index 0000000000..c9dca33c95 --- /dev/null +++ b/features/technical/user/suspend.feature @@ -0,0 +1,12 @@ +Feature: Suspend all users + + Model test (instance methods) + + Background: + Given personas existing + + Scenario: Suspend all users with late take backs + Given there are at least 2 users with late take backs from at least 2 inventory pools where automatic suspension is activated + When the cronjob executes the rake task for reminding and suspending all late users + Then every such user is suspended until '1.1.2099' in the corresponding inventory pool + And the suspended reason is the one configured for the corresponding inventory pool diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb index 1fd4ee20b0..4a2381e48c 100644 --- a/lib/authenticated_system.rb +++ b/lib/authenticated_system.rb @@ -32,7 +32,7 @@ def access_denied redirect_to login_path else # NOTE in case of post requests - render status: :method_not_allowed, text: _("You don't have permission") + render status: :method_not_allowed, text: _("You don't have permission to perform this action") end end diff --git a/lib/tasks/app/test.rake b/lib/tasks/app/test.rake index 058868f3d4..b05c32f259 100644 --- a/lib/tasks/app/test.rake +++ b/lib/tasks/app/test.rake @@ -93,6 +93,7 @@ namespace :app do task :generate_structure_with_views_sql do Rails.env = "test" config = Rails.configuration.database_configuration[Rails.env] + `rake db:drop db:create db:migrate` `mysqldump #{config['host'] ? "-h #{config['host']}" : nil} -u #{config['username']} #{config['password'] ? "--password=#{config['password']}" : nil} #{config['database']} --no-create-db | grep -v 'SQL SECURITY DEFINER' > #{File.join(Rails.root, "db/structure_with_views.sql")}` end diff --git a/lib/tasks/leihs.rake b/lib/tasks/leihs.rake index adf081d806..28389d45f1 100644 --- a/lib/tasks/leihs.rake +++ b/lib/tasks/leihs.rake @@ -64,11 +64,11 @@ namespace :leihs do puts "Maintenance complete ------------------------" end - desc "Remind users" - task :remind => :environment do - puts "Reminding users..." - User.remind_all - puts "Remind complete -----------------------------" + desc "Remind and suspend users" + task :remind_and_suspend => :environment do + puts "Reminding and suspending users..." + User.remind_and_suspend_all + puts "Remind and suspend complete -----------------------------" end desc "Deadline soon reminder" @@ -77,9 +77,9 @@ namespace :leihs do User.send_deadline_soon_reminder_to_everybody puts "Deadline soon reminded ----------------------" end - + desc "Cron: Remind & Maintenance" - task :cron => [:remind, :maintenance, :deadline_soon_reminder] + task :cron => [:remind_and_suspend, :maintenance, :deadline_soon_reminder] desc "Recreate DB and reindex" diff --git a/locale/de_CH/leihs.po b/locale/de_CH/leihs.po index 677abe1940..e24f75bd6a 100644 --- a/locale/de_CH/leihs.po +++ b/locale/de_CH/leihs.po @@ -67,6 +67,15 @@ msgstr "%s bis %s" msgid "** This is an automatically generated response **" msgstr "** Automatisch generierte E-Mail **" +msgid "Automatic suspension" +msgstr "Automatische Sperrung" + +msgid "Automatic suspension reason" +msgstr "Grund der automatischen Sperrung" + +msgid "Users who don't bring back the items on the required date are suspended from next day on." +msgstr "Benutzer, die ihre Geräte nicht bis geforderten Tag zurückbringen, werden ab nächstem Tag danach gesperrt." + msgid "A model for the Inventory Code / Serial Number '%s' was not found" msgstr "Modell für Inventarcode/Seriennummer '%s' wurde nicht gefunden" @@ -1709,8 +1718,8 @@ msgstr "Sie haben keinen Zugriff auf diesen Gegenstand." msgid "You don't have any rights to access this application." msgstr "Sie sind nicht berechtigt, diese Applikation zu verwenden" -msgid "You don't have permission" -msgstr "Sie haben keine Berechtigung" +msgid "You don't have permission to perform this action" +msgstr "Sie haben keine Berechtigung, diese Aktion durchzuführen" msgid "You have %{no_access} to any inventory pools!" msgstr "SIe haben %{no_access} auf diese Geräteparks" @@ -2854,3 +2863,9 @@ msgstr "Die Kontaktperson muss leer sein bei einem normalen User" msgid "Maintenance" msgstr "Wartung" + +msgid "Automatic access" +msgstr "Automatischer Zugriff" + +msgid "New users will get customer access automatically." +msgstr "Neue Benutzer kriegen automatisch den Zugriff als Kunde." diff --git a/locale/leihs.pot b/locale/leihs.pot index 23e4e81b69..19f7991ade 100644 --- a/locale/leihs.pot +++ b/locale/leihs.pot @@ -63,6 +63,15 @@ msgstr "" msgid "** This is an automatically generated response **" msgstr "" +msgid "Users who don't bring back the items on the required date are suspended from next day on." +msgstr "" + +msgid "Automatic suspension" +msgstr "" + +msgid "Automatic suspension reason" +msgstr "" + msgid "A model for the Inventory Code / Serial Number '%s' was not found" msgstr "" @@ -1643,7 +1652,7 @@ msgstr "" msgid "You don't have any rights to access this application." msgstr "" -msgid "You don't have permission" +msgid "You don't have permission to perform this action" msgstr "" msgid "You have %{no_access} to any inventory pools!" @@ -2754,3 +2763,9 @@ msgstr "" msgid "Maintenance" msgstr "" + +msgid "Automatic access" +msgstr "" + +msgid "New users will get customer access automatically." +msgstr "" diff --git a/spec/LDAP_generic.yml b/spec/LDAP_generic.yml new file mode 100644 index 0000000000..4e0ec78d2a --- /dev/null +++ b/spec/LDAP_generic.yml @@ -0,0 +1,15 @@ +test: + host: localhost + port: 12345 + #encryption: simple_tls + encryption: none + log_file: log/ldap_server.log + log_level: warn + master_bind_dn: uid=ldap_master,ou=people,dc=example,dc=org + master_bind_pw: pass + base_dn: ou=people,dc=example,dc=org + admin_dn: cn=admins,ou=people,dc=example,dc=org + unique_id_field: uid + log_file: log/ldap_server.log + search_field: uid + #search_field: samaccountname diff --git a/spec/LDAP.yml b/spec/LDAP_hslu.yml similarity index 89% rename from spec/LDAP.yml rename to spec/LDAP_hslu.yml index b8cd482add..5322c293b4 100644 --- a/spec/LDAP.yml +++ b/spec/LDAP_hslu.yml @@ -1,8 +1,7 @@ test: host: hostname - port: port_number + port: 12345 encryption: simple_tls - base: dc=xyz,dc=abcc,dc=ch log_file: log/ldap_server.log log_level: warn search_field: userprincipalname @@ -10,7 +9,6 @@ test: master_bind_pw: 12345 base_dn: OU=p_user,OU=prod,OU=hslu,DC=campus,DC=intern admin_dn: CN=blah,OU=diblah,OU=diblahblah,OU=p_ma,OU=p_group,OU=prod,OU=hslu,DC=campus,DC=intern - port: 636 unique_id_field: pager log_file: log/ldap_server.log video_displayname: DK.BA_VID diff --git a/spec/controllers/hslu_ldap_controller_spec.rb b/spec/controllers/hslu_ldap_controller_spec.rb index 3a08f0ff24..38080a70a8 100644 --- a/spec/controllers/hslu_ldap_controller_spec.rb +++ b/spec/controllers/hslu_ldap_controller_spec.rb @@ -11,7 +11,7 @@ LeihsFactory.create_default_languages @group = FactoryGirl.create(:group, :name => 'Video') - Setting::LDAP_CONFIG = File.join(Rails.root, "spec", "LDAP.yml") + Setting::LDAP_CONFIG = File.join(Rails.root, "spec", "LDAP_hslu.yml") #LDAP_CONFIG = {"test"=> # {"master_bind_pw"=>"12345", # "base_dn"=>"OU=p_user,OU=prod,OU=hslu,DC=campus,DC=intern", diff --git a/spec/controllers/ldap_controller_spec.rb b/spec/controllers/ldap_controller_spec.rb new file mode 100644 index 0000000000..5996205b8c --- /dev/null +++ b/spec/controllers/ldap_controller_spec.rb @@ -0,0 +1,79 @@ +# encoding: utf-8 +require 'spec_helper.rb' +require "#{Rails.root}/features/support/leihs_factory.rb" + +describe Authenticator::LdapAuthenticationController do + + before(:all) do + ENV['TMPDIR'] = File.join(Rails.root, "tmp") + # TODO: Move this out to something that runs *before* the test suite itself? + unless File.exist?(ENV['TMPDIR']) + Dir.mkdir(ENV['TMPDIR']) + end + @ip = FactoryGirl.create(:inventory_pool) + LeihsFactory.create_default_languages + Setting::LDAP_CONFIG = File.join(Rails.root, "spec", "LDAP_generic.yml") + + @server = Ladle::Server.new( + :port => 12345, + :ldif => File.join(Rails.root, "spec", "ldif", "generic.ldif"), + :domain => "dc=example,dc=org" + ) + @server.start + end + + after(:all) do + @server.stop + end + + def destroy_user(login) + user = User.where(:login => login).first + if user + return user.destroy + end + end + + before(:each) do + destroy_user("normal_user") + end + + context "if the user does not yet exist" do + it "should be able to create a normal with various useful data grabbed from LDAP" do + post :login, {:login => { :username => "normal_user", :password => "pass" }}, {} + User.where(:login => "normal_user").first.should_not == nil + # TODO: Check that all the data from LDAP made it into our user object + end + + it "newly created user should get automatically access as customer in all the pools where automatic access is activated" do + 3.times do + FactoryGirl.create :inventory_pool + end + ips_with_automatic_access = InventoryPool.all.sample(2) + ips_with_automatic_access.each {|ip| ip.update_attributes automatic_access: true} + + post :login, {:login => { :username => "normal_user", :password => "pass" }}, {} + + user = User.where(:login => "normal_user").first + access_rights = user.access_rights.where(role: "customer") + access_rights.count.should == 2 + ips_with_automatic_access.each {|ip| user.inventory_pools.should include ip} + end + end + + context "if the user is in the admin DN on LDAP" do + it "should give that user the admin role" do + post :login, {:login => { :username => "admin_user", :password => "pass" }}, {} + user = User.where(:login => "admin_user").first + user.access_rights.active.collect(&:role).include?(:admin).should == true + end + end + + context "if the user is not in the admin DN on LDAP" do + it "should not give that user the admin role" do + post :login, {:login => { :username => "normal_user", :password => "pass" }}, {} + user = User.where(:login => "normal_user").first + user.access_rights.active.collect(&:role).include?(:admin).should == false + end + end + +end diff --git a/spec/ldif/generic.ldif b/spec/ldif/generic.ldif new file mode 100644 index 0000000000..45ef9ad49e --- /dev/null +++ b/spec/ldif/generic.ldif @@ -0,0 +1,78 @@ +version: 1 + +dn: ou=people,dc=example,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: cn=admins,ou=people,dc=example,dc=org +objectClass: groupOfNames +objectClass: top +cn: admins +member: uid=admin_user,ou=people,dc=example,dc=org + +dn: uid=ldap_master,ou=people,dc=example,dc=org +# Password: pass +uid: ldap_master +cn: ldap_master +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= +mail: ldapmaster@mail.example.org +objectclass: organizationalPerson +objectclass: top +objectclass: person +objectclass: inetOrgPerson +sn: Master + +dn: uid=normal_user,ou=people,dc=example,dc=org +uid: normal_user +cn: normal_user +# Password: pass +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= +description: Test User for leihs +displayname: Test User +givenname: Test +l: Musterstadt +c: Switzerland +mail: test@mail.example.org +# This virtual attribute is NOT supported yet on ApacheDS. Enter +# it again once it is. +#memberof: CN=u_all_ad_deny,OU=p_administration,OU=p_group,OU=generic,DC=example,DC=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: country +pager: L9999 +postalcode: 9999 +sn: User +st: Zürich +streetaddress: Musterstrasse 1, Postfach 999 +telephonenumber: 044 999 99 99 +title: Lord of Test + +dn: uid=admin_user,ou=people,dc=example,dc=org +uid: admin_user +cn: admin_user +# Password: pass +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= +description: Admin Test User for leihs +displayname: Admin Test User +givenname: Admintest +l: Musterstadt +c: Switzerland +mail: admintest@mail.example.org +# This virtual attribute is NOT supported yet on ApacheDS. Enter +# it again once it is. +#memberof: CN=u_all_ad_deny,OU=p_administration,OU=p_group,OU=generic,DC=example,DC=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: country +pager: L9999 +postalcode: 9999 +sn: User +st: Zürich +streetaddress: Musterstrasse 1, Postfach 999 +telephonenumber: 044 999 99 99 +title: Admin Lord of Test