diff --git a/.rubocop.yml b/.rubocop.yml index 9a9c0c4ea..48a00e17b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -188,7 +188,7 @@ SpecialGlobalVars: Enabled: false StringLiterals: - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes VariableInterpolation: Enabled: false diff --git a/CONTRIBUTING.en.md b/CONTRIBUTING.en.md new file mode 100644 index 000000000..30955c7ff --- /dev/null +++ b/CONTRIBUTING.en.md @@ -0,0 +1,17 @@ +# Contribuciones + +Did you find a bug? Do you want to collaborate? + +Process: +* Open a thread in [discourse](http://community.coopdevs.org/) to make sure whether it's a bug or a feature :wink: +* Once we understand what the bug is about and know the steps to reproduce we will create an issue in GitHub linking to the Discourse thread. +* Create a pull request to solve the issue +* Report back to the discourse thread the bug has been solved linking to the pull request + +Visita [la guia para empezar a desarrollar para timeoverflow](https://github.com/coopdevs/timeoverflow/wiki/Getting-started) + +## Contributing with translations + +- Edit the translations directly on the [coopdevs/timeoverflow](https://www.localeapp.com/projects/10031) project on Locale. +- **That's it!** +- The maintainer will then pull translations from the Locale project and push to Github. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c57f786c..188ef7f30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,6 @@ +Read this in English: +[CONTRIBUTING.en.md](https://github.com/coopdevs/timeoverflow/blob/master/CONTRIBUTING.en.md) + # Contribuciones ¿Has encontrado algún bug? ¿Quieres colaborar? @@ -10,8 +13,8 @@ Proceso: Visita [la guia para empezar a desarrollar para timeoverflow](https://github.com/coopdevs/timeoverflow/wiki/Getting-started) -## Contributing with translations +## Contribuir con traducciones -- Edit the translations directly on the [coopdevs/timeoverflow](https://www.localeapp.com/projects/10031) project on Locale. -- **That's it!** -- The maintainer will then pull translations from the Locale project and push to Github. +- Modifica las traducciones directamente en el proyecto [coopdevs/timeoverflow](https://www.localeapp.com/projects/10031) en Locale. +- **Eso es todo!** +- El mantenedor obtendrá las nuevas tradcciones del proyecto de Locale y las publicará en Github. diff --git a/Gemfile b/Gemfile index c69876c33..e35652d93 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,8 @@ source 'https://rubygems.org' ruby '2.3.0' -gem 'rails', '4.2.5.2' +gem 'rails', '~> 4.2.7.1' gem 'rails-i18n' -gem 'rails_12factor' gem "rdiscount" gem 'high_voltage', '~> 2.1.0' gem 'activeadmin', github: 'activeadmin' @@ -17,13 +16,10 @@ gem "http_accept_language" gem 'thin' gem 'unicorn' gem 'foreman' -gem 'dotenv-rails' gem 'kaminari' gem "simple_form", ">= 3.0.0" -gem "awesome_print" gem 'memcachier' gem 'rollbar', '2.8.3' -gem 'travis-lint' gem 'whenever', :require => false gem 'prawn' gem 'prawn-table' @@ -50,15 +46,15 @@ group :development do gem 'web-console', '2.1.3' gem 'capistrano', '~> 3.1' gem 'capistrano-rails', '~> 1.1' - # gem 'capistrano3-delayed-job', '~> 1.0' gem 'airbrussh', require: false gem "quiet_assets" gem 'localeapp', '2.1.1', require: false gem 'letter_opener', '1.4.1' + gem 'dotenv-rails', '1.0.2' end group :development, :test do - gem "rspec-rails", '~> 3.4.0' + gem "rspec-rails", '~> 3.5.2' gem "capybara", '~> 2.4.4' gem "byebug" end @@ -75,3 +71,7 @@ group :test do gem 'fabrication' gem 'faker' end + +group :production do + gem 'rails_12factor', '0.0.3' +end diff --git a/Gemfile.lock b/Gemfile.lock index c473dfbb1..5812b2581 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,36 +19,36 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5.2) - actionpack (= 4.2.5.2) - actionview (= 4.2.5.2) - activejob (= 4.2.5.2) + actionmailer (4.2.7.1) + actionpack (= 4.2.7.1) + actionview (= 4.2.7.1) + activejob (= 4.2.7.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5.2) - actionview (= 4.2.5.2) - activesupport (= 4.2.5.2) + actionpack (4.2.7.1) + actionview (= 4.2.7.1) + activesupport (= 4.2.7.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5.2) - activesupport (= 4.2.5.2) + actionview (4.2.7.1) + activesupport (= 4.2.7.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5.2) - activesupport (= 4.2.5.2) + activejob (4.2.7.1) + activesupport (= 4.2.7.1) globalid (>= 0.3.0) - activemodel (4.2.5.2) - activesupport (= 4.2.5.2) + activemodel (4.2.7.1) + activesupport (= 4.2.7.1) builder (~> 3.1) - activerecord (4.2.5.2) - activemodel (= 4.2.5.2) - activesupport (= 4.2.5.2) + activerecord (4.2.7.1) + activemodel (= 4.2.7.1) + activesupport (= 4.2.7.1) arel (~> 6.0) - activesupport (4.2.5.2) + activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -60,14 +60,13 @@ GEM sshkit (>= 1.6.1, != 1.7.0) arbre (1.0.3) activesupport (>= 3.0.0) - arel (6.0.3) + arel (6.0.4) ast (2.0.0) astrolabe (1.3.0) parser (>= 2.2.0.pre.3, < 3.0) autoprefixer-rails (6.3.1) execjs json - awesome_print (1.6.1) bcrypt (3.1.11) better_errors (2.1.1) coderay (>= 1.0.0) @@ -81,7 +80,7 @@ GEM bourbon (3.2.4) sass (~> 3.2) thor - builder (3.2.2) + builder (3.2.3) byebug (4.0.5) columnize (= 0.9.0) capistrano (3.4.0) @@ -110,7 +109,8 @@ GEM execjs coffee-script-source (1.8.0) columnize (0.9.0) - concurrent-ruby (1.0.1) + concurrent-ruby (1.0.5) + crass (1.0.3) daemons (1.1.9) dalli (2.7.2) database_cleaner (1.3.0) @@ -122,7 +122,7 @@ GEM responders thread_safe (~> 0.1) warden (~> 1.2.3) - diff-lcs (1.2.5) + diff-lcs (1.3) domain_name (0.5.20170223) unf (>= 0.0.5, < 1.0.0) dotenv (1.0.2) @@ -156,8 +156,8 @@ GEM actionpack (>= 3.2.13) formtastic_i18n (0.1.1) gli (2.16.0) - globalid (0.3.6) - activesupport (>= 4.1.0) + globalid (0.4.1) + activesupport (>= 4.2.0) has_scope (0.6.0) actionpack (>= 3.2, < 5) activesupport (>= 3.2, < 5) @@ -168,7 +168,8 @@ GEM http-cookie (1.0.3) domain_name (~> 0.5) http_accept_language (2.0.2) - i18n (0.7.0) + i18n (0.9.1) + concurrent-ruby (~> 1.0) inherited_resources (1.6.0) actionpack (>= 3.2, < 5) has_scope (~> 0.6.0.rc) @@ -180,7 +181,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.3) railties (>= 3.2.16) - json (1.8.3) + json (1.8.6) kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -194,16 +195,18 @@ GEM i18n (~> 0.4) json rest-client - loofah (2.0.3) + loofah (2.1.1) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) - mime-types (>= 1.16, < 4) + mail (2.7.0) + mini_mime (>= 0.1.1) memcachier (0.0.2) - mime-types (3.0) + mime-types (3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0221) + mime-types-data (3.2016.0521) + mini_mime (1.0.0) mini_portile2 (2.0.0) - minitest (5.8.4) + minitest (5.11.1) multi_json (1.11.2) multipart-post (2.0.0) net-scp (1.2.1) @@ -229,25 +232,25 @@ GEM activesupport (>= 3.0.0) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.4) + rack (1.6.8) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.5.2) - actionmailer (= 4.2.5.2) - actionpack (= 4.2.5.2) - actionview (= 4.2.5.2) - activejob (= 4.2.5.2) - activemodel (= 4.2.5.2) - activerecord (= 4.2.5.2) - activesupport (= 4.2.5.2) + rails (4.2.7.1) + actionmailer (= 4.2.7.1) + actionpack (= 4.2.7.1) + actionview (= 4.2.7.1) + activejob (= 4.2.7.1) + activemodel (= 4.2.7.1) + activerecord (= 4.2.7.1) + activesupport (= 4.2.7.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5.2) + railties (= 4.2.7.1) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) @@ -259,14 +262,14 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.3) rails_stdout_logging (0.0.3) - railties (4.2.5.2) - actionpack (= 4.2.5.2) - activesupport (= 4.2.5.2) + railties (4.2.7.1) + actionpack (= 4.2.7.1) + activesupport (= 4.2.7.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.0.0) raindrops (0.16.0) - rake (11.1.1) + rake (12.3.0) ransack (1.6.3) actionpack (>= 3.0) activerecord (>= 3.0) @@ -282,23 +285,23 @@ GEM netrc (~> 0.8) rollbar (2.8.3) multi_json - rspec-core (3.4.1) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-rails (3.4.0) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) + rspec-support (~> 3.5.0) + rspec-rails (3.5.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) rubocop (0.28.0) astrolabe (~> 1.3) parser (>= 2.2.0.pre.7, < 3.0) @@ -324,10 +327,10 @@ GEM simple_form (3.1.0) actionpack (~> 4.0) activemodel (~> 4.0) - sprockets (3.5.2) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.4) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -338,13 +341,11 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) rack (~> 1.0) - thor (0.19.1) - thread_safe (0.3.5) + thor (0.19.4) + thread_safe (0.3.6) tilt (2.0.2) - travis-lint (2.0.0) - json ttfunk (1.4.0) - tzinfo (1.2.2) + tzinfo (1.2.4) thread_safe (~> 0.1) uglifier (2.7.2) execjs (>= 0.3.0) @@ -374,7 +375,6 @@ PLATFORMS DEPENDENCIES activeadmin! airbrussh - awesome_print better_errors binding_of_caller bootstrap-sass @@ -387,7 +387,7 @@ DEPENDENCIES dalli database_cleaner (= 1.3.0) devise (= 3.5.6) - dotenv-rails + dotenv-rails (= 1.0.2) elasticsearch-model elasticsearch-rails fabrication @@ -409,24 +409,26 @@ DEPENDENCIES prawn-table pundit quiet_assets - rails (= 4.2.5.2) + rails (~> 4.2.7.1) rails-i18n - rails_12factor + rails_12factor (= 0.0.3) rake rdiscount rollbar (= 2.8.3) - rspec-rails (~> 3.4.0) + rspec-rails (~> 3.5.2) rubocop sass-rails (~> 5.0.1) select2-rails shoulda (>= 3.5) simple_form (>= 3.0.0) thin - travis-lint uglifier (= 2.7.2) unicorn web-console (= 2.1.3) whenever +RUBY VERSION + ruby 2.3.0p0 + BUNDLED WITH - 1.11.2 + 1.16.1 diff --git a/README.en.md b/README.en.md index 2817e60f8..28a0074be 100644 --- a/README.en.md +++ b/README.en.md @@ -1,11 +1,7 @@ -# TimeOverflow -## https://www.timeoverflow.org/ +# TimeOverflow [](https://travis-ci.org/coopdevs/timeoverflow) [](https://codeclimate.com/github/timeoverflow/timeoverflow) [](https://gemnasium.com/coopdevs/timeoverflow) +#### https://www.timeoverflow.org/ -[](https://travis-ci.org/coopdevs/timeoverflow) -[](https://codeclimate.com/github/timeoverflow/timeoverflow) -[](https://gemnasium.com/coopdevs/timeoverflow) - -:bank: :hourglass: Time Bank management system. [Learn more about Time Banks] (http://www.bdtonline.org/) +:bank: :hourglass: Time Bank management system. [Learn more about Time Banks](http://www.bdtonline.org/) TimeOverflow is a software developed in an altruistic way to offer a system that facilitates the interaction of the members and the management of the Time Banks. @@ -14,6 +10,8 @@ of it and is prepared to be able to accommodate several Time Banks in a single i for this account with three levels of privileges: superadmin, admin (only manages a bank) and members of a bank. +  + TimeOverflow is divided into 2 large blocks: * ** Management system for administrators ** diff --git a/README.md b/README.md index e9d98e475..69c0dce83 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ -# TimeOverflow -## https://www.timeoverflow.org/ -#### Read this in English : https://github.com/coopdevs/timeoverflow/blob/develop/README.en.md - -[](https://travis-ci.org/coopdevs/timeoverflow) -[](https://codeclimate.com/github/timeoverflow/timeoverflow) -[](https://gemnasium.com/coopdevs/timeoverflow) +# TimeOverflow [](https://travis-ci.org/coopdevs/timeoverflow) [](https://codeclimate.com/github/timeoverflow/timeoverflow) [](https://gemnasium.com/coopdevs/timeoverflow) +#### www.timeoverflow.org +#### Read this in English: https://github.com/coopdevs/timeoverflow/blob/master/README.en.md :bank: :hourglass: Sistema de gestión de Banco de Tiempo. [Saber más sobre Bancos de Tiempo](http://www.bdtonline.org/) @@ -13,6 +9,8 @@ de los miembros y la gestión de los Bancos de Tiempo. El modelo sobre el que se que hacen uso de él y está preparado para poder albergar varios Bancos de Tiempo en una sola instalación, para ello cuenta con tres niveles de privilegios: superadmin, admin (solo gestiona un Banco) y miembros de un Banco. +  + TimeOverflow está dividido en 2 grandes bloques: * **Sistema de gestión para los administradores** diff --git a/app/admin/user.rb b/app/admin/user.rb index 816a8bd30..09d337b42 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -1,7 +1,7 @@ # coding: utf-8 ActiveAdmin.register User do - action_item only: :index do + action_item :upload_csv, only: :index do link_to I18n.t("active_admin.users.upload_from_csv"), action: "upload_csv" end diff --git a/app/assets/javascripts/app/app.js.coffee b/app/assets/javascripts/app/app.js.coffee deleted file mode 100644 index bee55ffcb..000000000 --- a/app/assets/javascripts/app/app.js.coffee +++ /dev/null @@ -1,51 +0,0 @@ -angular.module('timeoverflow').controller 'UserListCtrl', ["$scope", "$modal", "$http", "$location", ($scope, $modal, $http, $location) -> - - $scope.sortBy = (field) -> - $scope.sort = if $scope.sort == field then "-#{field}" else field - $scope.filterTerm = '' - $scope.$location = $location - - ['filterTerm', 'sort'].map (prop) -> - Object.defineProperty($scope, prop, - get: -> - if prop == 'sort' and $location.search()[prop] == undefined - 'member_id' - else - $location.search()[prop] - set: (val) -> $location.search(prop, val || null) - ) - - $scope.toggle_manager = (user) -> - $modal.open( - templateUrl: 'confirm_toggle_manager.html' - size: 'sm' - scope: $scope - controller: ["$scope", ($scope) -> $scope.username = user.username] - ).result - .then(-> $http.put(user.toggle_manager_link)) - .then(-> user.manager = !user.manager) - - $scope.toggle_active = (user) -> - $modal.open( - templateUrl: 'confirm_toggle_active.html' - size: 'sm' - scope: $scope - controller: ["$scope", ($scope) -> $scope.username = user.username] - ).result - .then(-> $http.put(user.toggle_active_link)) - .then(-> user.active = !user.active) -] - -# override this in a view where the organizations are needed -angular.module('timeoverflow').value 'Organizations', [] - -angular.module('timeoverflow').filter 'timeBalance', -> - (seconds) -> - if seconds isnt 0 - minutes = Math.abs(seconds) / 60 - hours = (minutes / 60) >> 0 - minutes %= 60 - minutes >>= 0; - if seconds < 0 then "-#{hours}:#{minutes}" else "#{hours}:#{minutes}" - else - "—" diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 8fcd14578..d37fff8f0 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -2,15 +2,11 @@ #= require datepicker #= require give_time #= require tags -#= require_tree ./app - -angular.module "timeoverflow", ["ng-rails-csrf", 'ui.bootstrap'] $(document).on 'click', 'a[data-popup]', (event) -> window.open($(this).attr('href'), 'popup', 'width=600,height=600') event.preventDefault() - $(document).on 'click', 'span.show-password', (event) -> if $(this).hasClass('checked') $(this).removeClass('checked'); @@ -20,4 +16,4 @@ $(document).on 'click', 'span.show-password', (event) -> $(this).addClass('checked'); $(this).prev('input').attr('type', 'text'); $(this).find('.material-icons').html("visibility_off") - event.preventDefault() \ No newline at end of file + event.preventDefault() diff --git a/app/assets/javascripts/libs.js b/app/assets/javascripts/libs.js index d54523d4c..63a46c808 100644 --- a/app/assets/javascripts/libs.js +++ b/app/assets/javascripts/libs.js @@ -6,6 +6,3 @@ //= require highcharts //= require highcharts-exporting //= require select2 -//= require angular.min -//= require ui-bootstrap-tpls-0.11.0 -//= require ng-rails-csrf diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 73c38db59..364c77d35 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -27,11 +27,6 @@ $pages-anchor-hover: #8a8a8a; $features-background: #f5f5f5; $features-separator: #d8d8d8; -[ng-cloak], -.ng-cloak { - visibility: hidden !important; -} - html { font-size:62.5%; } @@ -71,7 +66,7 @@ html { border: 0; border-radius: 0.3rem; margin: 0; - padding: 1rem 3rem 1.4rem 3rem; + padding: 1rem 0 1.4rem 0; } form .material-icons { @@ -123,7 +118,7 @@ html { } .panel-body { - padding: 0; + padding: 0 3rem 0 3rem; } .panel-footer { @@ -166,7 +161,7 @@ html { font-weight: 400; height: 7.5rem; } - + .form-control:focus { border-color: none; box-shadow: none; @@ -264,6 +259,10 @@ html { padding: 10px; } +.table-responsive { + overflow-x: inherit; +} + table.users { padding: 10px; } @@ -346,6 +345,10 @@ ul.statistics li{ } /*flash*/ +.alert > p, .alert > ul { + padding-left: 1.5rem; +} + .alert-error { background-color: #f2dede; border-color: #eed3d7; @@ -394,6 +397,11 @@ label[required]::after{ margin: 0 auto; } +//fix select2 100px +.select2-container { + width: 100% !important; +} + .navbar-form { padding: 0; background-color: transparent; @@ -622,7 +630,7 @@ form .checkbox input[type="checkbox"] { .material-icons { font-size: 3rem; } - + .checkbox { color: $form-login-gray-text; font-size: 1.6rem; diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 0e3ab87a7..1d84b947d 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -48,14 +48,6 @@ def destroy redirect_to organizations_path, notice: "deleted" end - def give_time - @destination = @organization.account.id - @source = find_transfer_source - @offer = find_transfer_offer - @transfer = Transfer.new(source: @source, destination: @destination) - @sources = find_transfer_sources_for_admin - end - def set_current if current_user session[:current_organization_id] = @organization.id @@ -70,20 +62,4 @@ def organization_params public_opening_times description address neighborhood city domain]) end - - def find_transfer_offer - current_organization.offers. - find(params[:offer]) if params[:offer].present? - end - - def find_transfer_source - current_user.members. - find_by(organization: @organization).account.id - end - - def find_transfer_sources_for_admin - return unless admin? - [current_organization.account] + - current_organization.member_accounts.where("members.active is true") - end end diff --git a/app/controllers/transfers_controller.rb b/app/controllers/transfers_controller.rb index 8d4f4f432..29704e42b 100644 --- a/app/controllers/transfers_controller.rb +++ b/app/controllers/transfers_controller.rb @@ -6,12 +6,29 @@ def create transfer_params.merge(source: @source, destination: @account) ) - begin - transfer.save! - rescue ActiveRecord::RecordInvalid - flash[:error] = transfer.errors.full_messages.to_sentence - end + transfer.save! redirect_to redirect_target + rescue ActiveRecord::RecordInvalid + flash[:error] = transfer.errors.full_messages.to_sentence + end + + def new + transfer_factory = TransferFactory.new( + current_organization, + current_user, + params[:offer], + params[:destination_account_id] + ) + + render( + :new, + locals: { + accountable: transfer_factory.accountable, + transfer: transfer_factory.build_transfer, + offer: transfer_factory.offer, + sources: transfer_factory.transfer_sources + } + ) end def delete_reason diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 68f6fb828..95c10f40a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,17 +1,15 @@ class UsersController < ApplicationController before_filter :authenticate_user! - def scoped_users - current_organization.users - end - def index - @users = scoped_users - @memberships = current_organization.members. - where(user_id: @users.map(&:id)). - includes(:account).each_with_object({}) do |mem, ob| - ob[mem.user_id] = mem - end + @search = current_organization.users.ransack(params[:q]) + + @users = @search + .result(distinct: false) + .joins(members: :account) + .eager_load(members: :account) + .page(params[:page]) + .per(25) end def show @@ -61,20 +59,12 @@ def update end end - def give_time - @user = scoped_users.find(params[:id]) - @destination = @user.members. - find_by(organization: current_organization).account.id - @source = find_transfer_source - @offer = find_transfer_offer - @transfer = Transfer.new(source: @source, - destination: @destination, - post: @offer) - @sources = find_transfer_sources_for_admin - end - private + def scoped_users + current_organization.users + end + def user_params fields_to_permit = %w"gender username email date_of_birth phone alt_phone active description notifications" @@ -85,22 +75,6 @@ def user_params params.require(:user).permit *fields_to_permit end - def find_transfer_offer - current_organization.offers. - find(params[:offer]) if params[:offer].present? - end - - def find_transfer_source - current_user.members. - find_by(organization: current_organization).account.id - end - - def find_transfer_sources_for_admin - return unless admin? - [current_organization.account] + - current_organization.member_accounts.where("members.active is true") - end - def find_user if current_user.id == params[:id].to_i current_user diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 98e19d862..03271794f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,24 +34,17 @@ def tnc_path document_path(Document.terms_and_conditions || 0, modal: true) end - def languages_list - I18n.available_locales.each do |locale| - concat content_tag(:li, - link_to(locale_menu_item(locale), - switch_lang_path(locale: locale)), - class: ("disabled" if I18n.locale == locale)) - end - end - def show_error_messages!(resource) return "" if resource.errors.empty? messages = resource.errors. full_messages.map { |msg| content_tag(:li, msg) }.join html = <<-HTML -