diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..78f31d17a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:9.4 + ports: ["5432:5432"] + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: timeoverflow_test + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Run tests + env: + RAILS_ENV: test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + run: | + bundle exec rails db:setup + bundle exec rspec + - name: Publish code coverage + uses: paambaati/codeclimate-action@v3.2.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageLocations: ${{ github.workspace }}/coverage/coverage.json:simplecov diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d1259e700..000000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: ruby -dist: bionic -cache: bundler -services: - - postgresql -addons: - postgresql: "9.4" - chrome: stable -bundler_args: '--without development' -env: - global: - - DATABASE_URL=postgres://postgres@localhost/timeoverflow_test - - CC_TEST_REPORTER_ID=025bc15a0fa9afa52d86ee24fea845cf1d363f48a466bcf2cef8ab80c29acb28 -before_script: - - psql -c 'create database timeoverflow_test;' -U postgres - - psql -U postgres -q -d timeoverflow_test -f db/structure.sql - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build -after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/Gemfile b/Gemfile index a1cf2a6b5..424f74532 100644 --- a/Gemfile +++ b/Gemfile @@ -1,18 +1,17 @@ source 'https://rubygems.org' -ruby File.read('.ruby-version').strip - gem 'rails', '~> 6.1.1' gem 'rails-i18n', '~> 6.0.0' -gem 'rdiscount', '~> 2.2.0.1' +gem 'rdiscount', '~> 2.2.7' gem 'rubyzip', '~> 2.3.0' gem 'activeadmin', '~> 2.9.0' -gem 'bootsnap', '~> 1.7.3', require: false +gem 'bootsnap', '~> 1.12.0', require: false gem 'has_scope', '~> 0.7.2' gem 'pundit', '~> 2.1.0' -gem 'pg', '~> 1.2.1' +gem 'pg', '~> 1.4' gem 'json_translate', '~> 4.0.0' -gem 'devise', '~> 4.7.1' +gem 'devise', '~> 4.9.1' +gem 'devise-i18n', '~> 1.11.0' gem 'http_accept_language', '~> 2.1.1' gem 'unicorn', '~> 5.5.1' gem 'kaminari', '~> 1.2.1' @@ -22,10 +21,10 @@ gem 'prawn', '~> 2.4.0' gem 'prawn-table', '~> 0.2.2' gem 'pg_search', '~> 2.3.5' gem 'skylight', '~> 5.0' -gem 'sidekiq', '~> 6.1.2' +gem 'sidekiq', '~> 6.4.0' gem 'sidekiq-cron', '~> 1.2.0' gem 'aws-sdk-s3', '~> 1.94', require: false -gem 'image_processing', '~> 1.2' +gem 'image_processing', '~> 1.12' # Assets gem 'jquery-rails', '~> 4.3.5' @@ -36,7 +35,7 @@ gem 'select2-rails', '~> 4.0.13' group :development do gem 'listen', '~> 3.2.0' - gem 'localeapp', '~> 3.1', require: false + gem 'localeapp', '~> 3.3', require: false gem 'letter_opener', '~> 1.7.0' gem 'web-console', '~> 4.1.0' gem 'capistrano', '~> 3.1' diff --git a/Gemfile.lock b/Gemfile.lock index f3797bd52..1a610fc34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,40 +1,40 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.3.1) - actionpack (= 6.1.3.1) - activesupport (= 6.1.3.1) + actioncable (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.3.1) - actionpack (= 6.1.3.1) - activejob (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionmailbox (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) mail (>= 2.7.1) - actionmailer (6.1.3.1) - actionpack (= 6.1.3.1) - actionview (= 6.1.3.1) - activejob (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionmailer (6.1.7.3) + actionpack (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activesupport (= 6.1.7.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.3.1) - actionview (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionpack (6.1.7.3) + actionview (= 6.1.7.3) + activesupport (= 6.1.7.3) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.3.1) - actionpack (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + actiontext (6.1.7.3) + actionpack (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) nokogiri (>= 1.8.5) - actionview (6.1.3.1) - activesupport (= 6.1.3.1) + actionview (6.1.7.3) + activesupport (= 6.1.7.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -48,28 +48,28 @@ GEM kaminari (~> 1.0, >= 1.2.1) railties (>= 5.2, < 6.2) ransack (~> 2.1, >= 2.1.1) - activejob (6.1.3.1) - activesupport (= 6.1.3.1) + activejob (6.1.7.3) + activesupport (= 6.1.7.3) globalid (>= 0.3.6) - activemodel (6.1.3.1) - activesupport (= 6.1.3.1) - activerecord (6.1.3.1) - activemodel (= 6.1.3.1) - activesupport (= 6.1.3.1) - activestorage (6.1.3.1) - actionpack (= 6.1.3.1) - activejob (= 6.1.3.1) - activerecord (= 6.1.3.1) - activesupport (= 6.1.3.1) - marcel (~> 1.0.0) - mini_mime (~> 1.0.2) - activesupport (6.1.3.1) + activemodel (6.1.7.3) + activesupport (= 6.1.7.3) + activerecord (6.1.7.3) + activemodel (= 6.1.7.3) + activesupport (= 6.1.7.3) + activestorage (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activesupport (= 6.1.7.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) @@ -77,8 +77,8 @@ GEM activesupport (>= 3.0.0, < 6.2) ruby2_keywords (>= 0.0.2, < 1.0) ast (2.4.2) - autoprefixer-rails (10.2.4.0) - execjs + autoprefixer-rails (10.4.13.0) + execjs (~> 2) aws-eventstream (1.1.1) aws-partitions (1.451.0) aws-sdk-core (3.114.0) @@ -95,10 +95,10 @@ GEM aws-sigv4 (~> 1.1) aws-sigv4 (1.2.3) aws-eventstream (~> 1, >= 1.0.2) - bcrypt (3.1.16) + bcrypt (3.1.18) bindex (0.8.1) - bootsnap (1.7.4) - msgpack (~> 1.0) + bootsnap (1.12.0) + msgpack (~> 1.2) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) @@ -126,16 +126,19 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) childprocess (3.0.0) - concurrent-ruby (1.1.8) + concurrent-ruby (1.2.2) connection_pool (2.2.5) crass (1.0.6) database_cleaner (1.8.5) - devise (4.7.3) + date (3.3.3) + devise (4.9.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) + devise-i18n (1.11.0) + devise (>= 4.9.0) diff-lcs (1.4.4) docile (1.3.5) domain_name (0.5.20190701) @@ -144,33 +147,33 @@ GEM dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - erubi (1.10.0) + erubi (1.12.0) et-orbi (1.2.4) tzinfo - execjs (2.7.0) + execjs (2.8.1) fabrication (2.22.0) faker (2.17.0) i18n (>= 1.6, < 2) - ffi (1.15.0) + ffi (1.15.5) formtastic (4.0.0) actionpack (>= 5.2.0) formtastic_i18n (0.6.0) fugit (1.4.5) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) - gli (2.20.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + gli (2.21.0) + globalid (1.1.0) + activesupport (>= 5.0) has_scope (0.7.2) actionpack (>= 4.1) activesupport (>= 4.1) http-accept (1.7.0) - http-cookie (1.0.3) + http-cookie (1.0.5) domain_name (~> 0.5) http_accept_language (2.1.1) - i18n (1.8.10) + i18n (1.12.0) concurrent-ruby (~> 1.0) - image_processing (1.12.1) + image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) inherited_resources (1.12.0) @@ -178,12 +181,12 @@ GEM has_scope (~> 0.6) railties (>= 5.2, < 6.2) responders (>= 2, < 4) - jmespath (1.4.0) + jmespath (1.6.1) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.5.1) + json (2.6.3) json_translate (4.0.1) activerecord (>= 4.2.0) kaminari (1.2.1) @@ -206,40 +209,52 @@ GEM listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - localeapp (3.1.3) + localeapp (3.3.0) gli i18n (>= 0.7, < 2) json (>= 1.7.7) rest-client (>= 1.8.0) - loofah (2.9.1) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) method_source (1.0.0) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) + mime-types-data (3.2022.0105) mini_magick (4.11.0) - mini_mime (1.0.3) - mini_portile2 (2.5.1) - minitest (5.14.4) - msgpack (1.4.2) + mini_mime (1.1.2) + mini_portile2 (2.8.1) + minitest (5.18.0) + msgpack (1.5.2) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout net-scp (3.0.0) net-ssh (>= 2.6.5, < 7.0.0) + net-smtp (0.3.3) + net-protocol net-ssh (6.1.0) netrc (0.11.0) - nio4r (2.5.7) - nokogiri (1.11.4) - mini_portile2 (~> 2.5.0) + nio4r (2.5.8) + nokogiri (1.13.10) + mini_portile2 (~> 2.8.0) racc (~> 1.4) orm_adapter (0.5.0) parallel (1.20.1) parser (3.0.1.1) ast (~> 2.4.1) pdf-core (0.9.0) - pg (1.2.3) + pg (1.4.6) pg_search (2.3.5) activerecord (>= 5.2) activesupport (>= 5.2) @@ -252,24 +267,24 @@ GEM pundit (2.1.0) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.5.2) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.3.1) - actioncable (= 6.1.3.1) - actionmailbox (= 6.1.3.1) - actionmailer (= 6.1.3.1) - actionpack (= 6.1.3.1) - actiontext (= 6.1.3.1) - actionview (= 6.1.3.1) - activejob (= 6.1.3.1) - activemodel (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + racc (1.6.2) + rack (2.2.6.4) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.3) + actioncable (= 6.1.7.3) + actionmailbox (= 6.1.7.3) + actionmailer (= 6.1.7.3) + actionpack (= 6.1.7.3) + actiontext (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activemodel (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) bundler (>= 1.15.0) - railties (= 6.1.3.1) + railties (= 6.1.7.3) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -278,20 +293,20 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.1.3.1) - actionpack (= 6.1.3.1) - activesupport (= 6.1.3.1) + railties (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) method_source - rake (>= 0.8.7) + rake (>= 12.2) thor (~> 1.0) rainbow (3.0.0) raindrops (0.19.1) - rake (13.0.3) + rake (13.0.6) ransack (2.4.2) activerecord (>= 5.2.4) activesupport (>= 5.2.4) @@ -299,8 +314,8 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - rdiscount (2.2.0.2) - redis (4.2.5) + rdiscount (2.2.7) + redis (4.5.1) regexp_parser (2.1.1) responders (3.0.1) actionpack (>= 5.0) @@ -345,7 +360,7 @@ GEM rack (>= 1.1) rubocop (>= 0.90.0, < 2.0) ruby-progressbar (1.11.0) - ruby-vips (2.1.0) + ruby-vips (2.1.4) ffi (~> 1.12) ruby2_keywords (0.0.4) rubyzip (2.3.0) @@ -363,7 +378,7 @@ GEM rubyzip (>= 1.2.2) shoulda-matchers (4.5.1) activesupport (>= 4.2.0) - sidekiq (6.1.3) + sidekiq (6.4.0) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) @@ -381,26 +396,27 @@ GEM simplecov_json_formatter (0.1.3) skylight (5.0.1) activesupport (>= 5.2.0) - sprockets (4.0.2) + sprockets (4.2.0) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - thor (1.1.0) + thor (1.2.1) tilt (2.0.10) + timeout (0.3.2) ttfunk (1.7.0) - tzinfo (2.0.4) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) + unf_ext (0.0.8.2) unicode-display_width (2.0.0) unicorn (5.5.5) kgio (~> 2.6) @@ -416,12 +432,12 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - websocket-driver (0.7.3) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.4.2) + zeitwerk (2.6.7) PLATFORMS ruby @@ -429,7 +445,7 @@ PLATFORMS DEPENDENCIES activeadmin (~> 2.9.0) aws-sdk-s3 (~> 1.94) - bootsnap (~> 1.7.3) + bootsnap (~> 1.12.0) bootstrap-sass (~> 3.4) byebug (~> 11.0) capistrano (~> 3.1) @@ -437,20 +453,21 @@ DEPENDENCIES capistrano-rbenv (~> 2.1) capybara (~> 3.29) database_cleaner (~> 1.8.5) - devise (~> 4.7.1) + devise (~> 4.9.1) + devise-i18n (~> 1.11.0) dotenv-rails (~> 2.7.1) fabrication (~> 2.20) faker (~> 2.15) has_scope (~> 0.7.2) http_accept_language (~> 2.1.1) - image_processing (~> 1.2) + image_processing (~> 1.12) jquery-rails (~> 4.3.5) json_translate (~> 4.0.0) kaminari (~> 1.2.1) letter_opener (~> 1.7.0) listen (~> 3.2.0) - localeapp (~> 3.1) - pg (~> 1.2.1) + localeapp (~> 3.3) + pg (~> 1.4) pg_search (~> 2.3.5) prawn (~> 2.4.0) prawn-table (~> 0.2.2) @@ -458,7 +475,7 @@ DEPENDENCIES rails (~> 6.1.1) rails-controller-testing rails-i18n (~> 6.0.0) - rdiscount (~> 2.2.0.1) + rdiscount (~> 2.2.7) rollbar (~> 2.22.1) rspec-rails (~> 4.0.0) rubocop (~> 1.6) @@ -468,7 +485,7 @@ DEPENDENCIES select2-rails (~> 4.0.13) selenium-webdriver (~> 3.142) shoulda-matchers (~> 4.4) - sidekiq (~> 6.1.2) + sidekiq (~> 6.4.0) sidekiq-cron (~> 1.2.0) simple_form (~> 5.0.2) simplecov (~> 0.17) @@ -478,8 +495,5 @@ DEPENDENCIES web-console (~> 4.1.0) webdrivers (~> 4.4) -RUBY VERSION - ruby 2.6.3p62 - BUNDLED WITH 2.1.4 diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..dbbe35581 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md index a9c210130..c08cc6ea1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TimeOverflow [![View performance data on Skylight](https://badges.skylight.io/problem/grDTNuzZRnyu.svg)](https://oss.skylight.io/app/applications/grDTNuzZRnyu) -[![Build Status](https://travis-ci.com/coopdevs/timeoverflow.svg?branch=develop)](https://travis-ci.com/coopdevs/timeoverflow) +[![Build Status](https://github.com/coopdevs/timeoverflow/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/coopdevs/timeoverflow/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/maintainability)](https://codeclimate.com/github/coopdevs/timeoverflow/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/test_coverage)](https://codeclimate.com/github/coopdevs/timeoverflow/test_coverage) @@ -49,6 +49,6 @@ of Time and also have the possibility to consult the extract of their account. ## License -> The Unlicense +> AGPL3 -You can find the license file [here](UNLICENSE). +You can find the license file [here](LICENSE). diff --git a/UNLICENSE b/UNLICENSE deleted file mode 100644 index 68a49daad..000000000 --- a/UNLICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/app/admin/category.rb b/app/admin/category.rb index 51e147d21..9a80ac39d 100644 --- a/app/admin/category.rb +++ b/app/admin/category.rb @@ -1,13 +1,16 @@ ActiveAdmin.register Category do index do id_column - column :name, sortable: false + column :name do |category| + "#{tag.span(nil, class: "glyphicon glyphicon-#{category.icon_name}")} #{category.name}".html_safe + end actions end form do |f| f.inputs do f.input :name + f.input :icon_name, hint: "See all available icons here".html_safe end f.actions end @@ -16,14 +19,12 @@ attributes_table do row :created_at row :updated_at + row :icon_name row :name_translations do - cat.name_translations.map do |locale, translation| - tag.strong("#{I18n.t("locales.#{locale}", locale: locale)}: ") + - tag.span(translation) - end.join(" | ").html_safe + render_translations(cat.name_translations) end end end - permit_params :name + permit_params :name, :icon_name end diff --git a/app/admin/document.rb b/app/admin/document.rb index 804b8a8fe..55c9d0fa8 100644 --- a/app/admin/document.rb +++ b/app/admin/document.rb @@ -1,5 +1,5 @@ ActiveAdmin.register Document do - permit_params *Document.attribute_names + permit_params :label, :title, :content index do id_column @@ -16,9 +16,11 @@ t.documentable end row :label - row :title - row :content do - raw RDiscount.new(t.content).to_html + row :title_translations do + render_translations(t.title_translations) + end + row :content_translations do + render_translations(t.content_translations, "
") end end end @@ -26,8 +28,8 @@ form do |f| f.inputs do f.input :label - f.input :title, as: :string - f.input :content + f.input :title, as: :text + f.input :content, as: :text end f.actions end diff --git a/app/admin/organization.rb b/app/admin/organization.rb index a8d75a707..825cb1937 100644 --- a/app/admin/organization.rb +++ b/app/admin/organization.rb @@ -46,5 +46,6 @@ def destroy filter :city, as: :select, collection: -> { Organization.pluck(:city).uniq } filter :neighborhood - permit_params *Organization.attribute_names + permit_params :name, :email, :web, :phone, :city, :neighborhood, + :address, :description, :public_opening_times end diff --git a/app/admin/petition.rb b/app/admin/petition.rb new file mode 100644 index 000000000..f0c88c5ba --- /dev/null +++ b/app/admin/petition.rb @@ -0,0 +1,14 @@ +ActiveAdmin.register Petition do + actions :index + + index do + id_column + column :user + column :organization + column :created_at + column :status + end + + filter :status, as: :select, collection: -> { Petition.statuses } + filter :created_at +end diff --git a/app/admin/post.rb b/app/admin/post.rb index 5aef7fe3c..43c32daf2 100644 --- a/app/admin/post.rb +++ b/app/admin/post.rb @@ -30,7 +30,8 @@ f.actions end - permit_params :type, :tag_list, *Post.attribute_names + permit_params :type, :tag_list, :title, :category_id, :user_id, + :description, :organization_id, :active, :is_group filter :type, as: :select, collection: -> { Post.subclasses } filter :id diff --git a/app/admin/user.rb b/app/admin/user.rb index ff4690e2b..2bec1c543 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -71,12 +71,13 @@ end column :entry_date column :member_uid + column :tag_list end end end end end - permit_params *User.attribute_names, - members_attributes: Member.attribute_names + permit_params :username, :email, :phone, :postcode, :gender, + members_attributes: [:organization_id, :active, :manager] end diff --git a/app/assets/images/redeira.png b/app/assets/images/redeira.png deleted file mode 100644 index 1806f0428..000000000 Binary files a/app/assets/images/redeira.png and /dev/null differ diff --git a/app/assets/stylesheets/active_admin.scss b/app/assets/stylesheets/active_admin.scss index 49d8b8101..46fb8521f 100644 --- a/app/assets/stylesheets/active_admin.scss +++ b/app/assets/stylesheets/active_admin.scss @@ -5,3 +5,6 @@ $table-stripe-color: #f5f5f5; @import "active_admin/mixins"; @import "active_admin/base"; @import "select2"; +@import "bootstrap-sprockets"; +@import "bootstrap/variables"; +@import "bootstrap/glyphicons"; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index dec301cc0..606f11684 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -11,12 +11,12 @@ html { } .content { - margin-bottom: 76px; + margin-bottom: 120px; } .actions-menu { - margin-bottom: 16px; - padding: 0 15px; + margin-bottom: 10px; + padding: 0 10px; @media(max-width: $screen-sm-min) { padding: 0; @@ -190,14 +190,14 @@ html { display: block; } - .glyphicon-folder-open { - font-size: 140%; - margin: 0 5px; - } - .category { font-weight: bold; margin-right: 10px; + + .glyphicon { + font-size: 140%; + margin-right: 4px; + } } &__datetime { @@ -669,3 +669,20 @@ label[required]::after{ display: inline; margin: 0 !important; } + +.organization-logo { + padding-top: 120px; +} + +.input__password-eye { + display: flex; + align-items: center; + justify-content: right; + + .show-password { + position: absolute; + display: flex; + margin-right: 12px; + cursor: pointer; + } +} diff --git a/app/assets/stylesheets/application/bootstrap-custom.scss b/app/assets/stylesheets/application/bootstrap-custom.scss index 4d9e6df45..8b57fc34a 100644 --- a/app/assets/stylesheets/application/bootstrap-custom.scss +++ b/app/assets/stylesheets/application/bootstrap-custom.scss @@ -1,12 +1,3 @@ -/*! - * Bootstrap v3.3.7 (http://getbootstrap.com) - * Copyright 2011-2016 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * - * This file lists all the available Bootstrap modules, uncomment - * the modules you want to import - */ - // Core variables and mixins @import "bootstrap-overrides"; @import "bootstrap/variables"; @@ -33,27 +24,18 @@ @import "bootstrap/input-groups"; @import "bootstrap/navs"; @import "bootstrap/navbar"; -// @import "bootstrap/breadcrumbs"; @import "bootstrap/pagination"; @import "bootstrap/pager"; @import "bootstrap/labels"; @import "bootstrap/badges"; -// @import "bootstrap/jumbotron"; -// @import "bootstrap/thumbnails"; @import "bootstrap/alerts"; -// @import "bootstrap/progress-bars"; @import "bootstrap/media"; @import "bootstrap/list-group"; @import "bootstrap/panels"; @import "bootstrap/responsive-embed"; -// @import "bootstrap/wells"; @import "bootstrap/close"; - -// Components w/ JavaScript @import "bootstrap/modals"; @import "bootstrap/tooltip"; -// @import "bootstrap/popovers"; -// @import "bootstrap/carousel"; // Utility classes @import "bootstrap/utilities"; diff --git a/app/assets/stylesheets/application/member-card.scss b/app/assets/stylesheets/application/member-card.scss index c72c603eb..6592e33f6 100644 --- a/app/assets/stylesheets/application/member-card.scss +++ b/app/assets/stylesheets/application/member-card.scss @@ -37,13 +37,6 @@ } } - &__tags { - a { - margin-left: 4px; - color: white; - } - } - &__activity { font-size: 14px; color: #78adb9; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6b301af1a..1a7f0d1ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -121,10 +121,18 @@ def resource_not_found render 'errors/not_found', status: 404 end - def member_should_be_active - if !current_member.active + def member_should_exist_and_be_active + if !current_member + redirect_to organizations_path + elsif !current_member.active flash[:error] = I18n.t('users.index.account_deactivated') redirect_to select_organization_path end end + + def user_should_be_confirmed + return if !current_user || current_user.confirmed? + + redirect_to please_confirm_users_path + end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index d84b2ff49..ad585bb44 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -2,11 +2,11 @@ class MembersController < ApplicationController before_action :authenticate_user! def destroy - find_member + @member = Member.find(params[:id]) toggle_active_posts @member.destroy - redirect_to manage_users_path + redirect_to request.referer.include?(organizations_path) ? organizations_path : manage_users_path end def toggle_manager diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 42eae556c..37daeafcc 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,8 +1,14 @@ class OrganizationsController < ApplicationController before_action :load_resource, only: [:show, :edit, :update, :set_current] + before_action :user_should_be_confirmed def index - organizations = Organization.all + if current_user + user_organizations = Organization.left_outer_joins(:petitions).where(petitions: { user_id: current_user.id }) + @user_organizations = user_organizations.or(Organization.where(id: current_user.organizations.pluck(:id))).distinct + end + + organizations = Organization.where.not(id: @user_organizations&.pluck(:id)) organizations = organizations.search_by_query(params[:q]) if params[:q].present? @organizations = organizations.page(params[:page]).per(25) end @@ -46,6 +52,6 @@ def load_resource def organization_params params[:organization].permit(*%w[name theme email phone web public_opening_times description address - neighborhood city domain]) + neighborhood city domain logo]) end end diff --git a/app/controllers/petitions_controller.rb b/app/controllers/petitions_controller.rb new file mode 100644 index 000000000..005c29b0c --- /dev/null +++ b/app/controllers/petitions_controller.rb @@ -0,0 +1,43 @@ +class PetitionsController < ApplicationController + before_action :authenticate_user! + + def create + petition = Petition.new petition_params + + if petition.save + OrganizationNotifier.new_petition(petition).deliver_now + OrganizationNotifier.petition_sent(petition).deliver_now + + flash[:notice] = t('petitions.application_status', status: t("petitions.status.sent")) + else + flash[:error] = t('errors.internal_server_error.description') + end + + redirect_to organizations_path + end + + def update + petition = Petition.find params[:id] + status = params[:status] + + if petition.update(status: status) + petition.user.add_to_organization(petition.organization) if status == 'accepted' + flash[:notice] = t('petitions.application_status', status: t("petitions.status.#{status}")) + else + flash[:error] = t('errors.internal_server_error.description') + end + + redirect_to manage_petitions_path + end + + def manage + @status = params[:status] || 'pending' + @users = User.joins(:petitions).where(petitions: { organization_id: current_organization.id, status: @status }).page(params[:page]).per(20) + end + + private + + def petition_params + params.permit(%i[organization_id user_id status]) + end +end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 858e9120c..560c548ee 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,5 @@ class TagsController < ApplicationController - before_action :authenticate_user!, :member_should_be_active + before_action :authenticate_user!, :member_should_exist_and_be_active def index model = params[:model].classify.constantize diff --git a/app/controllers/terms_controller.rb b/app/controllers/terms_controller.rb index ecf1ce81e..456c919f5 100644 --- a/app/controllers/terms_controller.rb +++ b/app/controllers/terms_controller.rb @@ -8,6 +8,6 @@ def show def accept current_user.touch :terms_accepted_at - redirect_to root_path + redirect_to(current_user.organizations.empty? ? organizations_path : root_path) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 79e48b807..b701f070f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,7 @@ class UsersController < ApplicationController - before_action :authenticate_user!, :member_should_be_active + before_action :authenticate_user!, except: %i[signup create] + before_action :user_should_be_confirmed, except: %i[signup create please_confirm] + before_action :member_should_exist_and_be_active, except: %i[signup create edit show update please_confirm] has_scope :tagged_with, as: :tag @@ -16,6 +18,8 @@ def manage def show @user = find_user + redirect_to edit_user_path(@user) and return if !current_organization + @member = @user.as_member_of(current_organization) @movements = @member.movements.order("created_at DESC").page(params[:page]). per(10) @@ -38,26 +42,29 @@ def create u.attributes = user_params end empty_email = @user.email.empty? + @user.from_signup = params[:from_signup].present? @user.setup_and_save_user if @user.persisted? - @user.tune_after_persisted(current_organization) - @user.add_tags(current_organization, params[:tag_list] || []) + unless @user.from_signup + @user.tune_after_persisted(current_organization) + @user.add_tags(current_organization, params[:tag_list] || []) + end redirect_to_after_create else @user.email = "" if empty_email - render action: "new" + render action: @user.from_signup ? 'signup' : 'new' end end def update - @user = scoped_users.find(params[:id]) - authorize @user + @user = User.find(params[:id]) + authorize @user unless @user == current_user if @user.update(user_params) - @user.add_tags(current_organization, params[:tag_list] || []) + @user.add_tags(current_organization, params[:tag_list] || []) if current_organization redirect_to @user else @@ -65,6 +72,12 @@ def update end end + def signup + redirect_to root_path and return if current_user + + @user = User.new + end + def update_avatar operation = AvatarGenerator.new(current_user, params) @@ -77,6 +90,8 @@ def update_avatar redirect_to current_user end + def please_confirm; end + private def search_and_load_members(members_scope, default_search_params) @@ -102,6 +117,7 @@ def user_params fields_to_permit += %w"admin registration_number registration_date" if admin? fields_to_permit += %w"organization_id superadmin" if superadmin? + fields_to_permit += %w"password" if params[:from_signup].present? params.require(:user).permit *fields_to_permit end @@ -115,17 +131,22 @@ def find_user end def redirect_to_after_create - id = @user.member(current_organization).member_uid - if params[:more] - redirect_to new_user_path, - notice: I18n.t("users.new.user_created_add", - uid: id, - name: @user.username) + if params[:from_signup].present? + sign_in(@user) + redirect_to terms_path else - redirect_to users_path, - notice: I18n.t("users.index.user_created", - uid: id, - name: @user.username) + id = @user.member(current_organization).member_uid + if params[:more] + redirect_to new_user_path, + notice: I18n.t("users.new.user_created_add", + uid: id, + name: @user.username) + else + redirect_to users_path, + notice: I18n.t("users.index.user_created", + uid: id, + name: @user.username) + end end end end diff --git a/app/helpers/active_admin_helper.rb b/app/helpers/active_admin_helper.rb new file mode 100644 index 000000000..8e43496a7 --- /dev/null +++ b/app/helpers/active_admin_helper.rb @@ -0,0 +1,8 @@ +module ActiveAdminHelper + def render_translations(attribute, joiner = " | ") + attribute.map do |locale, translation| + tag.strong("#{I18n.t("locales.#{locale}", locale: locale)}: ") + + tag.span(translation) + end.join(joiner).html_safe + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index becad91c1..c34d8186b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -24,6 +24,17 @@ def gravatar_url(user, size = 32) "https://www.gravatar.com/avatar/#{gravatar_id}.png?#{gravatar_options.to_param}" end + def organization_logo + org = @organization || @current_organization + + return unless org && org.logo.attached? + return if "#{controller_name}##{action_name}".in? %w(organizations#index pages#show) + + content_tag(:div, class: "row organization-logo") do + image_tag(org.logo.variant(resize: "x200^"), class: 'img-responsive center-block') + end + end + def mdash raw "—" end diff --git a/app/helpers/brand_logo_helper.rb b/app/helpers/brand_logo_helper.rb deleted file mode 100644 index bc02bb1eb..000000000 --- a/app/helpers/brand_logo_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -module BrandLogoHelper - def render_brand_logo - return unless should_render_logo? - render 'application/brand_logo' - end - - private - - def should_render_logo? - return false unless current_user - current_organization&.id == branded_organization_id - end - - def branded_organization_id - Rails.application.config.branded_organization_id - end -end diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb index ed46bac27..f644257b8 100644 --- a/app/helpers/categories_helper.rb +++ b/app/helpers/categories_helper.rb @@ -6,4 +6,9 @@ def all_categories def categories_for_select all_categories.map { |cat| [cat.name, cat.id] } end + + def category_icon(category) + icon_name = category.icon_name + glyph(icon_name) if icon_name + end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 75ac944cb..e0562469b 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -38,4 +38,8 @@ def toggle_active_member_path(member) def can_toggle_active?(_member) superadmin? || admin? end + + def status_applications(status) + t('petitions.status_applications', status: t("petitions.status.#{status}").humanize) + end end diff --git a/app/mailers/organization_notifier.rb b/app/mailers/organization_notifier.rb index 44117b519..d3ed1fcd5 100644 --- a/app/mailers/organization_notifier.rb +++ b/app/mailers/organization_notifier.rb @@ -12,4 +12,27 @@ def recent_posts(posts, locale, users) mail(bcc: users.map(&:email)) end end + + def new_petition(petition) + @user = petition.user + organization = petition.organization + + I18n.with_locale(locale) do + mail( + subject: 'New Application', + to: organization.users.joins(:members).where(members: { manager: true }).pluck(:email).uniq + ) + end + end + + def petition_sent(petition) + @organization_name = petition.organization.name + + I18n.with_locale(locale) do + mail( + subject: 'Application sent correctly', + to: petition.user.email + ) + end + end end diff --git a/app/models/document.rb b/app/models/document.rb index 6cbb0a814..ff42de6c9 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -1,6 +1,8 @@ class Document < ApplicationRecord belongs_to :documentable, polymorphic: true, optional: true + translates :title, :content + def self.terms_and_conditions where(label: "t&c", documentable_id: nil).first end diff --git a/app/models/organization.rb b/app/models/organization.rb index dfc7a4b00..559f34a8a 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -10,6 +10,8 @@ class Organization < ApplicationRecord } } + has_one_attached :logo + has_many :members, dependent: :destroy has_many :users, -> { order "members.created_at DESC" }, through: :members has_many :all_accounts, class_name: "Account", inverse_of: :organization, dependent: :destroy @@ -21,6 +23,7 @@ class Organization < ApplicationRecord has_many :offers has_many :inquiries has_many :documents, as: :documentable, dependent: :destroy + has_many :petitions, dependent: :delete_all validates :name, presence: true, uniqueness: true diff --git a/app/models/petition.rb b/app/models/petition.rb new file mode 100644 index 000000000..24ad28376 --- /dev/null +++ b/app/models/petition.rb @@ -0,0 +1,6 @@ +class Petition < ApplicationRecord + enum status: %i[pending accepted declined] + + belongs_to :user + belongs_to :organization +end diff --git a/app/models/user.rb b/app/models/user.rb index 4f3e006c8..a625c0d09 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,8 +17,10 @@ class User < ApplicationRecord ) attr_accessor :empty_email + attr_accessor :from_signup has_one_attached :avatar + has_many :members, dependent: :destroy has_many :organizations, through: :members has_many :accounts, through: :members @@ -27,6 +29,7 @@ class User < ApplicationRecord has_many :offers has_many :inquiries has_many :device_tokens + has_many :petitions, dependent: :delete_all accepts_nested_attributes_for :members @@ -37,6 +40,7 @@ class User < ApplicationRecord validates :username, presence: true validates :email, presence: true, uniqueness: true + validates :password, presence: true, if: :from_signup? # Allows @domain.com for dummy emails but does not allow pure invalid # emails like 'without email' validates_format_of :email, @@ -98,8 +102,8 @@ def setup_and_save_user # temporary valid email with current time milliseconds # this will be updated to user.id@example.com later on self.empty_email = email.strip.empty? - self.email = "user#{DateTime.now.strftime('%Q')}@example.com" if empty_email - skip_confirmation! # auto-confirm, not sending confirmation email + self.email = "user#{DateTime.now.strftime('%Q')}@example.com" if empty_email && !from_signup + skip_confirmation! unless from_signup? save end @@ -123,4 +127,12 @@ def has_valid_email? def email_if_real has_valid_email? ? email : "" end + + def was_member?(petition) + petition.status == 'accepted' && Member.where(organization: petition.organization, user: self).none? + end + + def from_signup? + from_signup + end end diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 43682895f..d65f899f9 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -1,6 +1,6 @@ class UserPolicy < ApplicationPolicy def create? - user.admins?(organization) + !user || user.admins?(organization) end def update? diff --git a/app/views/application/_brand_logo.html.erb b/app/views/application/_brand_logo.html.erb deleted file mode 100644 index 4959dfd88..000000000 --- a/app/views/application/_brand_logo.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
- <%= image_tag("redeira.png", class: 'organization-brand-logo img-responsive center-block') %> -
diff --git a/app/views/application/menus/_organization_listings_menu.html.erb b/app/views/application/menus/_organization_listings_menu.html.erb index 83c90dcc6..a95177c04 100644 --- a/app/views/application/menus/_organization_listings_menu.html.erb +++ b/app/views/application/menus/_organization_listings_menu.html.erb @@ -11,6 +11,12 @@ <%= t "application.navbar.users" %> <% end %> +
  • + <%= link_to manage_petitions_path do %> + <%= glyph 'list-alt' %> + <%= t('petitions.applications') %> + <% end %> +
  • <%= link_to offers_path(org: current_organization) do %> <%= glyph :link %> diff --git a/app/views/application/menus/_user_admin_menu_items.html.erb b/app/views/application/menus/_user_admin_menu_items.html.erb index b145ff05d..cfbadd218 100644 --- a/app/views/application/menus/_user_admin_menu_items.html.erb +++ b/app/views/application/menus/_user_admin_menu_items.html.erb @@ -21,6 +21,13 @@ <% end %>
  • +
  • + <%= link_to organizations_path do %> + <%= glyph :list %> + <%= t('layouts.application.manage_memberships') %> + <% end %> +
  • + <% current_user.members.where(manager: true).each do |m| %>
  • <%= link_to m.organization do %> diff --git a/app/views/devise/mailer/confirmation_instructions.ca.html.erb b/app/views/devise/mailer/confirmation_instructions.ca.html.erb deleted file mode 100644 index 3921f3157..000000000 --- a/app/views/devise/mailer/confirmation_instructions.ca.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

    Benvingut <%= @email %>!

    - -

    Confirma el teu compte fent clic en el següent enllaç:

    - -

    <%= link_to 'Confirmar compte', confirmation_url(@resource, :confirmation_token => @token) %>

    diff --git a/app/views/devise/mailer/confirmation_instructions.es.html.erb b/app/views/devise/mailer/confirmation_instructions.es.html.erb deleted file mode 100644 index 2343f5619..000000000 --- a/app/views/devise/mailer/confirmation_instructions.es.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

    ¡Bienvenido <%= @email %>!

    - -

    Confirma tu cuenta haciendo click en el siguiente link:

    - -

    <%= link_to 'Confirmar cuenta', confirmation_url(@resource, :confirmation_token => @token) %>

    diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb deleted file mode 100644 index 36670f913..000000000 --- a/app/views/devise/mailer/confirmation_instructions.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

    Welcome <%= @email %>!

    - -

    You can confirm your account email through the link below:

    - -

    <%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %>

    diff --git a/app/views/devise/mailer/reset_password_instructions.ca.html.erb b/app/views/devise/mailer/reset_password_instructions.ca.html.erb deleted file mode 100644 index bd2808b2a..000000000 --- a/app/views/devise/mailer/reset_password_instructions.ca.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

    Hola <%= @resource.email %>!

    - -

    S'ha sol·licitat el canvi de la teva contrasenya. Pots canviar-la a travès del següent enllaç.

    - -

    <%= link_to 'Canviar contrasenya', edit_password_url(@resource, :reset_password_token => @token) %>

    - -

    Si tu no has sol·licitat el canvi de contrasenya, no facis cas d'aquest correu.

    -

    La teva contrasenya no canviarà fins que no facis clic a l'enllaç.

    diff --git a/app/views/devise/mailer/reset_password_instructions.es.html.erb b/app/views/devise/mailer/reset_password_instructions.es.html.erb deleted file mode 100644 index 1f5716d49..000000000 --- a/app/views/devise/mailer/reset_password_instructions.es.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

    Hola <%= @resource.email %>!

    - -

    Se ha solicitado el cambio de tu contraseña. Puedes cambiarlo a través del siguiente enlace.

    - -

    <%= link_to 'Cambiar mi contraseña', edit_password_url(@resource, :reset_password_token => @token) %>

    - -

    Si tu no has solicitado un cambio de contraseña ignora este mail.

    -

    Tu password no cambiará hasta que no accedas al link.

    diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb deleted file mode 100644 index 93de6d05d..000000000 --- a/app/views/devise/mailer/reset_password_instructions.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

    Hello <%= @resource.email %>!

    - -

    Someone has requested a link to change your password. You can do this through the link below.

    - -

    <%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %>

    - -

    If you didn't request this, please ignore this email.

    -

    Your password won't change until you access the link above and create a new one.

    diff --git a/app/views/devise/mailer/unlock_instructions.ca.html.erb b/app/views/devise/mailer/unlock_instructions.ca.html.erb deleted file mode 100644 index c1a3ce628..000000000 --- a/app/views/devise/mailer/unlock_instructions.ca.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

    Hola <%= @resource.email %>!

    - -

    El teu compte ha estat bloquejat després de diversos intents d'entrada.

    - -

    Per desbloquejar el teu compte accedeix al següent enllaç:

    - -

    <%= link_to 'Desbloquejar compte', unlock_url(@resource, :unlock_token => @token) %>

    diff --git a/app/views/devise/mailer/unlock_instructions.es.html.erb b/app/views/devise/mailer/unlock_instructions.es.html.erb deleted file mode 100644 index 607993de4..000000000 --- a/app/views/devise/mailer/unlock_instructions.es.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

    ¡Hola <%= @resource.email %>!

    - -

    Tu cuenta ha sido bloqueada después de varios intentos fallidos de acceso.

    - -

    Accede al siguiente link para desbloquear tu cuenta:

    - -

    <%= link_to 'Desbloquear mi cuenta', unlock_url(@resource, :unlock_token => @token) %>

    diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb deleted file mode 100644 index f59615fed..000000000 --- a/app/views/devise/mailer/unlock_instructions.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

    Hello <%= @resource.email %>!

    - -

    Your account has been locked due to an excessive number of unsuccessful sign in attempts.

    - -

    Click the link below to unlock your account:

    - -

    <%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @token) %>

    diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 2c8d1320f..6fcd5c7c2 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -43,6 +43,14 @@ +
    <%= t('global.or').upcase %>
    +
    +
    +
    + <%= link_to t('devise.registrations.new.sign_up'), signup_users_path, class: "btn btn-primary btn-lg col-xs-12" %> +
    +
    +
    <% end %>
  • - <%= link_to c.name, "#{base_path}?cat=#{c.id}" %> + <%= link_to "#{base_path}?cat=#{c.id}" do %> + <%= category_icon(c) %> + <%= c.name %> + <% end %>
  • <% end %> diff --git a/app/views/shared/_post_form.html.erb b/app/views/shared/_post_form.html.erb index 851e96d9a..c984e4a4f 100644 --- a/app/views/shared/_post_form.html.erb +++ b/app/views/shared/_post_form.html.erb @@ -41,5 +41,5 @@ required: true %> <% end %> - <%= f.button label_button, class: "btn btn-default", style: "margin-bottom: 20px;" %> + <%= f.button label_button, class: "btn btn-default" %> <% end %> diff --git a/app/views/shared/_posts.html.erb b/app/views/shared/_posts.html.erb index 69fbd1e7c..593f0fc71 100644 --- a/app/views/shared/_posts.html.erb +++ b/app/views/shared/_posts.html.erb @@ -12,18 +12,20 @@

    <% if post.category %> - <%= glyph :folder_open %> <%= link_to [post.class, cat: post.category] do %> + <%= category_icon(post.category) %> <%= post.category %> <% end %> <% end %> <% (post.tags || []).each do |tag| %> - <%= glyph :tag %> - <%= link_to [post.class, tag: tag] do %> - <%= tag %> - <% end %> + + <%= glyph :tag %> + <%= link_to [post.class, tag: tag] do %> + <%= tag %> + <% end %> + <% end %>

    diff --git a/app/views/tags/_grouped_index.html.erb b/app/views/tags/_grouped_index.html.erb index a3be369bb..f876c0e1f 100644 --- a/app/views/tags/_grouped_index.html.erb +++ b/app/views/tags/_grouped_index.html.erb @@ -11,7 +11,7 @@
    <%= count %>
    - <%= link_to [post_type.pluralize, tag: tag] do %> + <%= link_to [post_type.pluralize.to_sym, tag: tag] do %> <%= glyph count == 1 ? :tag : :tags %> <%= tag %> <% end %> diff --git a/app/views/terms/show.html.erb b/app/views/terms/show.html.erb index eed77c824..8505fdcc0 100644 --- a/app/views/terms/show.html.erb +++ b/app/views/terms/show.html.erb @@ -1,13 +1,7 @@ <%= m @document.content %> -<%= form_tag accept_terms_path, method: :post do %> - -<% end %> +<%= button_to t('.accept'), accept_terms_path, class: "btn btn-primary" %> diff --git a/app/views/transfers/new.html.erb b/app/views/transfers/new.html.erb index b5f7163a3..b00a3379d 100644 --- a/app/views/transfers/new.html.erb +++ b/app/views/transfers/new.html.erb @@ -11,9 +11,7 @@ as: :integer, input_html: { min: 0, - max: 20, - "data-rule-either-hours-minutes-informed" => "true", - "data-rule-range" => "[0,20]" + "data-rule-either-hours-minutes-informed" => "true" } %> <%= f.input :minutes, as: :integer, diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 39a845213..f7d6d9328 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -3,7 +3,7 @@
    <%= f.input :username %> - <% if admin? %> + <% if admin? || short %> <%= f.input :email %> <% if @user.unconfirmed_email.present? %> <%= f.input :unconfirmed_email, readonly: true %> @@ -12,6 +12,19 @@ <%= f.input :email, readonly: true %> <% end %> + <% if short %> +
    + +
    + + + visibility + +
    +
    + <%= hidden_field_tag 'from_signup', 'true' %> + <% end %> + <%= f.input :phone %> <%= f.input :alt_phone %> <%= f.input :gender, collection: genders_collection %> @@ -21,15 +34,18 @@ include_blank: :true %> <%= f.input :description, as: "text" %> <%= f.input :postcode %> - <%= label_tag :tag_list, t('activerecord.attributes.post.tag_list') %> -
    - <%= select_tag :tag_list, - options_for_select(member.tags, member.tags), - multiple: true, - data: { placeholder: t("application.tips.entertag"), model: "member" }, - id: "tags-js", - class: "form-control" %> -
    + + <% if current_organization %> + <%= label_tag :tag_list, t('activerecord.attributes.post.tag_list') %> +
    + <%= select_tag :tag_list, + options_for_select(member.tags, member.tags), + multiple: true, + data: { placeholder: t("application.tips.entertag"), model: "member" }, + id: "tags-js", + class: "form-control" %> +
    + <% end %>
    @@ -49,9 +65,12 @@
    <%= f.button :submit %> - <% if @user.new_record? %> - <%= f.button :submit, t('users.new.create_more_users_button'), name: 'more' %> + + <% if !short %> + <% if @user.new_record? %> + <%= f.button :submit, t('users.new.create_more_users_button'), name: 'more' %> + <% end %> + <%= link_to t('users.new.cancel'), users_path, class: "btn btn-default" %> <% end %> - <%= link_to t('users.new.cancel'), users_path, class: "btn btn-default" %>
    <% end %> diff --git a/app/views/users/_member_card.html.erb b/app/views/users/_member_card.html.erb index 162c04c60..aab28333a 100644 --- a/app/views/users/_member_card.html.erb +++ b/app/views/users/_member_card.html.erb @@ -12,7 +12,7 @@ <%= t('.no_activity') %> <% end %> <% member.tags[0..2].each do |tag| %> - + <%= link_to users_path tag: tag do %> <%= glyph :tag %> <%= tag&.truncate(29) %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 55fb08316..1a5e3d53e 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -3,4 +3,4 @@ <%= t ".edit_user" %> -<%= render "form", member: @user.as_member_of(current_organization) %> +<%= render "form", member: @user.as_member_of(current_organization), short: false %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index a2600bbd9..47b7322e7 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,37 +1,31 @@ -
    -
    -
    -

    - <%= link_to current_organization.name, current_organization %> - <%= t(".members") %> -

    -
    +
    +
    +

    + <%= link_to current_organization.name, current_organization %> + <%= t(".members") %> +

    -
    -
    -
    - <%= search_form_for(@search, class: "navbar-form navbar-left", url: users_path) do |f| %> -
    - <%= f.search_field :member_search_cont, class: "form-control" %> -
    - - <% end %> -
    +
    +
    + <%= search_form_for(@search, class: "navbar-form navbar-left", url: users_path) do |f| %> +
    + <%= f.search_field :member_search_cont, value: params.dig(:q, :member_search_cont), class: "form-control" %> +
    + + <% end %>
    -
    -
    - <%= render partial: 'member_card', collection: @member_view_models, as: :member %> -
    +
    + <%= render partial: 'member_card', collection: @member_view_models, as: :member %> +
    -
    -
    - <%= paginate @members %> -
    +
    +
    + <%= paginate @members %>
    diff --git a/app/views/users/manage.html.erb b/app/views/users/manage.html.erb index dfc08098c..8619f9d17 100644 --- a/app/views/users/manage.html.erb +++ b/app/views/users/manage.html.erb @@ -1,78 +1,71 @@ -
    -
    -
    -

    - <%= link_to current_organization.name, current_organization %> - <%= t("users.index.members") %> -

    -
    +
    +
    +

    + <%= link_to current_organization.name, current_organization %> + <%= t("users.index.members") %> +

    -
    -
    -
    - <%= search_form_for(@search, class: "navbar-form navbar-left", url: manage_users_path) do |f| %> -
    - <%= f.search_field :member_search_cont, class: "form-control" %> -
    - +
    +
    + <%= search_form_for(@search, class: "navbar-form navbar-left", url: manage_users_path) do |f| %> +
    + <%= f.search_field :member_search_cont, value: params.dig(:q, :member_search_cont), class: "form-control" %> +
    + + <% end %> +
    +
    -
    -
    -
    -
    -
    - - - - - - - +
    +
    +
    +
    - <%= sort_link @search, :member_uid, 'ID' %> - - <%= sort_link @search, :user_username, User.human_attribute_name(:username) %> - - <%= User.human_attribute_name(:email) %> -
    + + + + + + + + + <% if current_user.manages? current_organization %> - - <% if current_user.manages? current_organization %> - - <% end %> - - - - <%= render partial: "user_row", collection: @member_view_models, as: :member %> - -
    + <%= sort_link @search, :member_uid, 'ID' %> + + <%= sort_link @search, :user_username, User.human_attribute_name(:username) %> + + <%= User.human_attribute_name(:email) %> + + <%= User.human_attribute_name(:phone) %> + + <%= sort_link @search, 'account_balance', Account.human_attribute_name(:balance) %> + - <%= User.human_attribute_name(:phone) %> + + <%= t(".actions") %> - <%= sort_link @search, 'account_balance', Account.human_attribute_name(:balance) %> - - - <%= t(".actions") %> -
    + <% end %> + + + + <%= render partial: "user_row", collection: @member_view_models, as: :member %> + + - <%= paginate @members %> -
    + <%= paginate @members %>
    diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 5d83ed235..f2d83fec9 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,4 +1,4 @@

    <%= t ".new_user" %>

    -<%= render "form", member: Member.new %> +<%= render "form", member: Member.new, short: false %> diff --git a/app/views/users/please_confirm.html.erb b/app/views/users/please_confirm.html.erb new file mode 100644 index 000000000..5660e9f7c --- /dev/null +++ b/app/views/users/please_confirm.html.erb @@ -0,0 +1,2 @@ +

    <%= t('users.confirm_email.please') %>

    +<%= t('users.confirm_email.email_sent', email: current_user.email) %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 6b30727cc..4bdf1824e 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -73,7 +73,7 @@
    <% @member.tags.each do |tag| %> - + <%= link_to users_path tag: tag do %> <%= glyph(:tag) %> <%= tag %> diff --git a/app/views/users/signup.html.erb b/app/views/users/signup.html.erb new file mode 100644 index 000000000..3a5ee8d5d --- /dev/null +++ b/app/views/users/signup.html.erb @@ -0,0 +1 @@ +<%= render 'form', member: Member.new, short: true %> diff --git a/config/database.yml b/config/database.yml index ea70e91a2..a840d2a02 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,20 +1,6 @@ -# If you want to change this file, please keep the changes in your working -# copy by using -# -# git update-index --skip-worktree config/database.yml -# -# or just use DATABASE_URL, in which case Rails will happily skip the whole -# file. -# -# See https://github.com/coopdevs/timeoverflow/wiki/Keeping-your-local-files -# for more information -# - defaults: &defaults adapter: postgresql - username: <%= ENV['DATABASE_USER'] %> # default is null - collation: 'es_ES.UTF-8' - ctype: 'es_ES.UTF-8' + username: <%= ENV['DATABASE_USER'] || ENV["POSTGRES_USER"] %> template: 'template0' encoding: 'UTF8' @@ -24,12 +10,18 @@ development: test: <<: *defaults - database: 'timeoverflow_test' + database: timeoverflow_test + host: localhost + password: <%= ENV['DATABASE_PASSWORD'] || ENV["POSTGRES_PASSWORD"] %> staging: <<: *defaults + collation: 'es_ES.UTF-8' + ctype: 'es_ES.UTF-8' database: <%= ENV.fetch('DATABASE_NAME', 'timeoverflow_staging') %> production: <<: *defaults + collation: 'es_ES.UTF-8' + ctype: 'es_ES.UTF-8' database: <%= ENV.fetch('DATABASE_NAME', 'timeoverflow_production') %> diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index a1a9bee9f..e84397b52 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -1,6 +1,7 @@ ActiveAdmin.setup do |config| config.site_title = "TimeOverflow" config.site_title_link = "/" + config.breadcrumb = false config.footer = "TimeOverflow Admin | www.timeoverflow.org" config.authentication_method = :authenticate_superuser! config.current_user_method = :current_user diff --git a/config/initializers/branded_organization.rb b/config/initializers/branded_organization.rb deleted file mode 100644 index 17bbac2b0..000000000 --- a/config/initializers/branded_organization.rb +++ /dev/null @@ -1,7 +0,0 @@ -DEFAULT_BRANDED_ORG_ID = 246 - -Rails.application.config.branded_organization_id = nil - -unless Rails.env.test? - Rails.application.config.branded_organization_id = (Redis.current.get('branded_organization_id') || DEFAULT_BRANDED_ORG_ID).to_i -end diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 8f67de85f..f30d500d6 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -274,6 +274,7 @@ ca: contact_details: Dades de contacte create: Crear date: Data + decline: rebutjar delete: Esborrar demote: Convertir en usuari normal edit: Modificar @@ -281,6 +282,7 @@ ca: filter: Filtre from: Des de give_time: Transferir temps + here: aquí home: Inici information: Informació locales_header: canviar llengua @@ -288,6 +290,7 @@ ca: more: Veure més movements: Moviments next: Següent + or: o promote: Convertir en administrador reason: Raó required_field: "* Camp obligatori" @@ -315,6 +318,7 @@ ca: edit_profile: Modificar perfil help: Ajuda login: Entra + manage_memberships: Gestiona membres report: report_title: INFORME locales: @@ -411,6 +415,20 @@ ca: subtitle: TimeOverflow és lliure, gratuït i col·laboratiu title: El software disenyat per i per title2: als Bancs de Temps + petitions: + application_sent: Sol·licitud enviada correctament + application_sent_body: Hola! La teva sol·licitud a %{organization_name} s'ha enviat correctament. + application_status: Sol·licitud %{status} + applications: Sol·licituds + apply: Sol·licita unir-te + new: Nova sol·licitud + new_body: Hola! Nova petició de l'usuari %{username}. Gestiona les sol·licituds %{here_link}. + status: + accepted: acceptada + declined: rebutjada + pending: pendent + sent: enviada + status_applications: "%{status} sol·licituds" posts: show: info: Aquesta %{type} pertany a %{organization}. @@ -506,6 +524,9 @@ ca: change_your_image: Canvia la teva imatge crop_the_image: Retalla la imatge max_size_warning: La imatge és massa gran, el màxim permès és de %{size}MB + confirm_email: + email_sent: T'hem enviat un correu electrònic a %{email}. Un cop confirmis el teu compte de correu podràs sol·licitar unir-te a qualsevol organització. + please: Si us plau, confirma el teu correu electrònic. edit: edit_user: Canviar usuari form: @@ -555,7 +576,9 @@ ca: active_warning: Vas a canviar l'estat del compte de l'usuari %{user} cancel_warning: Vas a eliminar del banc a l'usuari %{user} deactivate: Desactivar + delete_membership: Elimina pertinença manage_warning: Vas a canviar els privilegis de l'usuari %{user} + sure_delete: Estàs segur que vols sortir de %{organization_name}? views: pagination: first: "« Primera" diff --git a/config/locales/en.yml b/config/locales/en.yml index 96f498108..0f0ec74d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -19,7 +19,7 @@ en: created_at: Created updated_at: Updated inquiry: - is_group: Group inquiry + is_group: Group request offer: is_group: Group offer organization: @@ -95,8 +95,8 @@ en: one: Comment other: Comments inquiry: - one: Inquiry - other: Inquiries + one: Request + other: Requests offer: one: Offer other: Offers @@ -137,7 +137,7 @@ en: demographics: Demographics data global_activity: Global activity inactive_users: Inactive users - inquiry_public_link: Inquiries public link + inquiry_public_link: Requests public link last_login: Last login offer_public_link: Offers public link organizations: Organizations @@ -274,6 +274,7 @@ en: contact_details: Contact details create: Create date: Data + decline: decline delete: Delete demote: Demote to normal user edit: Update @@ -281,6 +282,7 @@ en: filter: Filter from: From give_time: Time transfer + here: here home: Home information: Information locales_header: change language @@ -288,6 +290,7 @@ en: more: More movements: Transactions next: Next + or: or promote: Promote to administrator reason: Reason required_field: "* Required field" @@ -302,11 +305,11 @@ en: to: To inquiries: edit: - submit: Change inquiry + submit: Change request index: - new_inquiry: New inquiry + new_inquiry: New request new: - submit: Create inquiry + submit: Create request layouts: application: about: About TimeOverflow @@ -315,6 +318,7 @@ en: edit_profile: Update my profile help: Help login: Login + manage_memberships: Manage memberships report: report_title: REPORT locales: @@ -411,6 +415,20 @@ en: subtitle: TimeOverflow is open source, free and collaborative title: The software designed by and for title2: Time Banks + petitions: + application_sent: Application sent correctly + application_sent_body: Hello! your application to %{organization_name} has been sent correctly. + application_status: Application %{status} + applications: Applications + apply: Apply to join + new: New Application + new_body: Hello! New petition from user %{username}. Manage your applications %{here_link}. + status: + accepted: accepted + declined: declined + pending: pending + sent: sent + status_applications: "%{status} applications" posts: show: info: This %{type} belongs to %{organization}. @@ -422,7 +440,7 @@ en: delete_reason: Are you sure to delete this comment? movements: Movements post_form: - group_inquiry: Is it a group inquiry? + group_inquiry: Is it a group request? group_offer: Is it a group offer? you_can_use: You can use simple_form: @@ -506,6 +524,9 @@ en: change_your_image: Change your image crop_the_image: Crop the image max_size_warning: Image is too big, max allowed is %{size}MB + confirm_email: + email_sent: An email has been sent to %{email}. After confirm you will be able to apply to any organization. + please: Please, confirm the email edit: edit_user: Update user form: @@ -555,7 +576,9 @@ en: active_warning: You are going to change user account status for %{user} cancel_warning: You are going to delete account from the Time Bank for user %{user} deactivate: Deactivate + delete_membership: Delete membership manage_warning: You are going to change privileges for user %{user} + sure_delete: Are you sure you want to delete your membership from %{organization_name}? views: pagination: first: First diff --git a/config/locales/es.yml b/config/locales/es.yml index 30353ba1b..cc68059e2 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -274,6 +274,7 @@ es: contact_details: Datos de contacto create: Crear date: Fecha + decline: rechazar delete: Borrar demote: Convertir en usuario normal edit: Modificar @@ -281,6 +282,7 @@ es: filter: Filtro from: De give_time: Transferir tiempo + here: aquí home: Inicio information: Información locales_header: cambiar idioma @@ -288,6 +290,7 @@ es: more: Ver más movements: Movimientos next: Siguiente + or: o promote: Convertir en administrador reason: Razón required_field: "* Campo obligatorio" @@ -315,6 +318,7 @@ es: edit_profile: Modificar mi perfil help: Ayuda login: Entra + manage_memberships: Gestionar membresia report: report_title: INFORME locales: @@ -411,6 +415,20 @@ es: subtitle: TimeOverflow es libre, gratuito y colaborativo title: El software diseñado por y para title2: los Bancos de Tiempo + petitions: + application_sent: Solicitud enviada correctamente + application_sent_body: 'Hola! Tu solicitud a %{organization_name} se ha enviado correctamente. ' + application_status: Solicitud %{status} + applications: Solicitudes + apply: Solicita unirte + new: Nueva solicitud + new_body: Hola! Nueva petición del usuario %{username}. Gestiona las solicitudes %{here_link}. + status: + accepted: aceptada + declined: rechazada + pending: pendiente + sent: enviada + status_applications: "%{status} solicitudes" posts: show: info: Esta %{type} pertenece a %{organization}. @@ -506,6 +524,9 @@ es: change_your_image: Cambia tu imagen crop_the_image: Recortar la imagen max_size_warning: La imagen es demasiado grande, el máximo permitido es %{size}MB + confirm_email: + email_sent: Un email se ha enviado a %{email}. Cuando lo hayas confirmado podrás solicitar unirte a cualquier organización. + please: Por favor, confirma el correo electrónico edit: edit_user: Cambiar usuario form: @@ -555,7 +576,9 @@ es: active_warning: Va a cambiar el estado de la cuenta del usuario %{user} cancel_warning: Va a eliminar del banco al usuario %{user} deactivate: Desactivar + delete_membership: Borrar membresia manage_warning: Va a cambiar los privilegios del usuario %{user} + sure_delete: Estás seguro de que quieres dejar de ser miembro de %{organization_name}? views: pagination: first: "« Primera" diff --git a/config/locales/eu.yml b/config/locales/eu.yml index d5672e39f..b0723f2b6 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -274,6 +274,7 @@ eu: contact_details: Kontaktuaren datuak create: Sortu date: Datuak + decline: delete: Ezabatu demote: Ohiko erabiltzaile bihurtu edit: Aldaketak egin @@ -281,6 +282,7 @@ eu: filter: Iragazkia from: tik give_time: Denbora eman + here: home: Hasiera information: Informazioa locales_header: Hizkuntza aldatu @@ -288,6 +290,7 @@ eu: more: 'Gehiago ikusi ' movements: Mugimenduak next: Hurrengoa + or: promote: Administratzaile bihurtu reason: Arrazoia required_field: Derrigorrez bete beharrekoa @@ -315,6 +318,7 @@ eu: edit_profile: Nire profila aldatu help: Laguntza login: Sartu + manage_memberships: report: report_title: TXOSTENA locales: @@ -411,6 +415,20 @@ eu: subtitle: TimeOverflow librea dohakoa eta kolaborazio bidezkoa da title: Denbora bankuek diseinaturiko softwarea, title2: Denbora bankuentzat + petitions: + application_sent: + application_sent_body: + application_status: + applications: + apply: + new: + new_body: + status: + accepted: + declined: + pending: + sent: + status_applications: posts: show: info: "%{type} hau %{organization}(e)ri dagokio." @@ -506,6 +524,9 @@ eu: change_your_image: crop_the_image: max_size_warning: + confirm_email: + email_sent: + please: edit: edit_user: Erabiltzailea aldatu form: @@ -555,7 +576,9 @@ eu: active_warning: " %{user} erabiltzailearen kontuaren egoera aldatuko duzu" cancel_warning: " %{user} erabiltzailea D bankutik ezabatuko duzu" deactivate: Desaktibatu + delete_membership: manage_warning: "%{user} erabiltzailearen onurak aldatuko dituzu" + sure_delete: views: pagination: first: Lehenengoa diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 71e4d60bb..16661d4ea 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -274,6 +274,7 @@ gl: contact_details: Datos de contacto create: Crea date: Datos + decline: delete: Eliminar demote: Degradar a usuario/a normal edit: Actualización @@ -281,6 +282,7 @@ gl: filter: Filtro from: Desde give_time: Transferencia de tempo + here: home: Inicio information: Información locales_header: cambiar o idioma @@ -288,6 +290,7 @@ gl: more: Máis movements: Transaccións next: Próximo + or: promote: Promover á persoa administradora reason: Razón required_field: "* Campo obrigatorio" @@ -315,6 +318,7 @@ gl: edit_profile: Actualiza o meu perfil help: Axuda login: Acceder + manage_memberships: report: report_title: INFORME locales: @@ -411,6 +415,20 @@ gl: subtitle: TimeOverflow é de código aberto, gratuíto e colaborativo title: O software deseñado por e para title2: Bancos de tempo + petitions: + application_sent: + application_sent_body: + application_status: + applications: + apply: + new: + new_body: + status: + accepted: + declined: + pending: + sent: + status_applications: posts: show: info: Este %{type} pertence a %{organization}. @@ -506,6 +524,9 @@ gl: change_your_image: crop_the_image: max_size_warning: + confirm_email: + email_sent: + please: edit: edit_user: Actualizar persoa usuaria form: @@ -555,7 +576,9 @@ gl: active_warning: Vas cambiar o estado da conta de usuario/a para %{user} cancel_warning: Vas borrar a conta do Banco de tempo para o usuario/a %{user} deactivate: Desactivar + delete_membership: manage_warning: Vas cambiar privilexios para o usuario/a %{user} + sure_delete: views: pagination: first: Primeira diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 9a8b9edf3..684f7f3ac 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -274,6 +274,7 @@ pt-BR: contact_details: Dados de contato create: Criar date: Data + decline: delete: Apagar demote: Converter em usuário normal edit: Modificar @@ -281,6 +282,7 @@ pt-BR: filter: Filtro from: De give_time: Transferir tempo + here: home: Início information: Informação locales_header: Trocar idioma @@ -288,6 +290,7 @@ pt-BR: more: Ver mais movements: Movimentos next: Próximo + or: promote: Converter em administrador reason: Razão required_field: "* Campo obrigatório" @@ -315,6 +318,7 @@ pt-BR: edit_profile: Modificar meu perfil help: Ajuda login: Entre + manage_memberships: report: report_title: INFORME locales: @@ -411,6 +415,20 @@ pt-BR: subtitle: TimeOverflow é livre, gratuito e colaborativo title: O software desenhado por e para title2: os Bancos de Tempo + petitions: + application_sent: + application_sent_body: + application_status: + applications: + apply: + new: + new_body: + status: + accepted: + declined: + pending: + sent: + status_applications: posts: show: info: Este %{type} pertence a %{organization}. @@ -506,6 +524,9 @@ pt-BR: change_your_image: crop_the_image: max_size_warning: + confirm_email: + email_sent: + please: edit: edit_user: Trocar usuário form: @@ -555,7 +576,9 @@ pt-BR: active_warning: Mudará o estado da conta do usuário %{user} cancel_warning: Eliminará o usuário do banco %{user} deactivate: Desativar + delete_membership: manage_warning: Mudará os privilégios do usuário %{user} + sure_delete: views: pagination: first: "« Primeira" diff --git a/config/routes.rb b/config/routes.rb index e41d2670e..500c4581d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,11 +37,19 @@ resources :users, concerns: :accountable, except: :destroy, :path => "members" do collection do + get 'signup' get 'manage' + get 'please_confirm' end end put :update_avatar, to: 'users#update_avatar' + resources :petitions, only: [:create, :update] do + collection do + get 'manage' + end + end + resources :transfers, only: [:new, :create] do member do put :delete_reason diff --git a/db/migrate/20221016192111_create_petitions.rb b/db/migrate/20221016192111_create_petitions.rb new file mode 100644 index 000000000..56511765c --- /dev/null +++ b/db/migrate/20221016192111_create_petitions.rb @@ -0,0 +1,11 @@ +class CreatePetitions < ActiveRecord::Migration[6.1] + def change + create_table :petitions do |t| + t.references :user, null: false, foreign_key: true + t.references :organization, null: false, foreign_key: true + t.integer :status + + t.timestamps + end + end +end diff --git a/db/migrate/20230312231058_migrate_hstore_to_json.rb b/db/migrate/20230312231058_migrate_hstore_to_json.rb new file mode 100644 index 000000000..7ab08b7af --- /dev/null +++ b/db/migrate/20230312231058_migrate_hstore_to_json.rb @@ -0,0 +1,15 @@ +class MigrateHstoreToJson < ActiveRecord::Migration[6.1] + def up + rename_column :categories, :name_translations, :name_translations_hstore + add_column :categories, :name_translations, :jsonb, default: {}, null: false, index: { using: 'gin' } + execute 'UPDATE "categories" SET "name_translations" = json_object(hstore_to_matrix("name_translations_hstore"))::jsonb' + remove_column :categories, :name_translations_hstore + end + + def down + rename_column :categories, :name_translations, :name_translations_jsonb + add_column :categories, :name_translations, :hstore, default: {}, null: false + execute 'UPDATE "categories" SET "name_translations" = (SELECT hstore(key, value) FROM jsonb_each_text("name_translations_jsonb"))' + remove_column :categories, :name_translations_jsonb + end +end diff --git a/db/migrate/20230314233504_add_icon_name_to_categories.rb b/db/migrate/20230314233504_add_icon_name_to_categories.rb new file mode 100644 index 000000000..7376d3a85 --- /dev/null +++ b/db/migrate/20230314233504_add_icon_name_to_categories.rb @@ -0,0 +1,22 @@ +class AddIconNameToCategories < ActiveRecord::Migration[6.1] + def change + add_column :categories, :icon_name, :string + + # Initialize icon names for each category with mapping defined in #673 + icon_mapping = { + 'Acompañamiento' => 'random', + 'Asesoramiento' => 'briefcase', + 'Clases' => 'education', + 'Estética' => 'scissors', + 'Ocio' => 'music', + 'Otros' => 'asterisk', + 'Préstamo de herramientas, material, libros, ...' => 'wrench', + 'Salud' => 'apple', + 'Tareas administrativas' => 'list-alt', + 'Tareas domésticas' => 'shopping-cart' + } + Category.all.each do |category| + category.update(icon_name: icon_mapping[category.name] || 'folder-open') + end + end +end diff --git a/db/migrate/20230401114456_make_terms_translatable.rb b/db/migrate/20230401114456_make_terms_translatable.rb new file mode 100644 index 000000000..c03e9ed2c --- /dev/null +++ b/db/migrate/20230401114456_make_terms_translatable.rb @@ -0,0 +1,21 @@ +class MakeTermsTranslatable < ActiveRecord::Migration[6.1] + def up + add_column :documents, :title_translations, :jsonb, default: {}, null: false + add_column :documents, :content_translations, :jsonb, default: {}, null: false + Document.find_each do |doc| + doc.update_columns(title_translations: { es: doc[:title] }, content_translations: { es: doc[:content] }) + end + remove_column :documents, :title + remove_column :documents, :content + end + + def down + add_column :documents, :title, :text + add_column :documents, :content, :text + Document.find_each do |doc| + doc.update_columns(title: doc.title_translations["es"], content: doc.content_translations["es"]) + end + remove_column :documents, :title_translations + remove_column :documents, :content_translations + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 818dbdfff..f0aece735 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -128,8 +128,8 @@ unless Category.exists? Category.connection.execute "ALTER SEQUENCE categories_id_seq RESTART;" [ - "Acompañamiento", "Salud", "Tareas domésticas", "Tareas administrativas", - "Clases", "Ocio", "Asesoramiento", "Otro" + "Acompañamiento", "Salud", "Tareas domésticas", "Tareas administrativas", "Estética", "Clases", + "Ocio", "Asesoramiento", "Otros", "Préstamo de herramientas, material, libros, ...", "Tareas domésticas" ].each do |name| unless Category.with_name_translation(name).exists? Category.create { |c| c.name = name } diff --git a/db/structure.sql b/db/structure.sql index 8ad16f15b..7239a85a3 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -158,7 +158,7 @@ ALTER SEQUENCE public.active_admin_comments_id_seq OWNED BY public.active_admin_ -- --- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: - +-- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.active_storage_attachments ( @@ -191,7 +191,7 @@ ALTER SEQUENCE public.active_storage_attachments_id_seq OWNED BY public.active_s -- --- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: - +-- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.active_storage_blobs ( @@ -227,7 +227,7 @@ ALTER SEQUENCE public.active_storage_blobs_id_seq OWNED BY public.active_storage -- --- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: - +-- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.active_storage_variant_records ( @@ -257,7 +257,7 @@ ALTER SEQUENCE public.active_storage_variant_records_id_seq OWNED BY public.acti -- --- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.ar_internal_metadata ( @@ -276,7 +276,8 @@ CREATE TABLE public.categories ( id integer NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, - name_translations public.hstore + name_translations jsonb DEFAULT '{}'::jsonb NOT NULL, + icon_name character varying ); @@ -339,11 +340,11 @@ CREATE TABLE public.documents ( id integer NOT NULL, documentable_id integer, documentable_type character varying, - title text, - content text, label character varying, created_at timestamp without time zone, - updated_at timestamp without time zone + updated_at timestamp without time zone, + title_translations jsonb DEFAULT '{}'::jsonb NOT NULL, + content_translations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -512,6 +513,39 @@ CREATE SEQUENCE public.organizations_id_seq ALTER SEQUENCE public.organizations_id_seq OWNED BY public.organizations.id; +-- +-- Name: petitions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.petitions ( + id bigint NOT NULL, + user_id bigint NOT NULL, + organization_id bigint NOT NULL, + status integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: petitions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.petitions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: petitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.petitions_id_seq OWNED BY public.petitions.id; + + -- -- Name: posts; Type: TABLE; Schema: public; Owner: - -- @@ -777,6 +811,13 @@ ALTER TABLE ONLY public.movements ALTER COLUMN id SET DEFAULT nextval('public.mo ALTER TABLE ONLY public.organizations ALTER COLUMN id SET DEFAULT nextval('public.organizations_id_seq'::regclass); +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.petitions ALTER COLUMN id SET DEFAULT nextval('public.petitions_id_seq'::regclass); + + -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -822,7 +863,7 @@ ALTER TABLE ONLY public.active_admin_comments -- --- Name: active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_storage_attachments @@ -830,7 +871,7 @@ ALTER TABLE ONLY public.active_storage_attachments -- --- Name: active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_storage_blobs @@ -838,7 +879,7 @@ ALTER TABLE ONLY public.active_storage_blobs -- --- Name: active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_storage_variant_records @@ -846,7 +887,7 @@ ALTER TABLE ONLY public.active_storage_variant_records -- --- Name: ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ar_internal_metadata @@ -909,6 +950,14 @@ ALTER TABLE ONLY public.organizations ADD CONSTRAINT organizations_pkey PRIMARY KEY (id); +-- +-- Name: petitions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.petitions + ADD CONSTRAINT petitions_pkey PRIMARY KEY (id); + + -- -- Name: posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -977,28 +1026,28 @@ CREATE INDEX index_active_admin_comments_on_resource_type_and_resource_id ON pub -- --- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX index_active_storage_attachments_on_blob_id ON public.active_storage_attachments USING btree (blob_id); -- --- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - +-- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON public.active_storage_attachments USING btree (record_type, record_id, name, blob_id); -- --- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: public; Owner: - +-- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX index_active_storage_blobs_on_key ON public.active_storage_blobs USING btree (key); -- --- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: - +-- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.active_storage_variant_records USING btree (blob_id, variation_digest); @@ -1081,6 +1130,20 @@ CREATE INDEX index_movements_on_transfer_id ON public.movements USING btree (tra CREATE UNIQUE INDEX index_organizations_on_name ON public.organizations USING btree (name); +-- +-- Name: index_petitions_on_organization_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_petitions_on_organization_id ON public.petitions USING btree (organization_id); + + +-- +-- Name: index_petitions_on_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_petitions_on_user_id ON public.petitions USING btree (user_id); + + -- -- Name: index_posts_on_category_id; Type: INDEX; Schema: public; Owner: - -- @@ -1175,6 +1238,22 @@ ALTER TABLE ONLY public.events ADD CONSTRAINT events_transfer_id_fkey FOREIGN KEY (transfer_id) REFERENCES public.transfers(id); +-- +-- Name: fk_rails_0f0c5fe120; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.petitions + ADD CONSTRAINT fk_rails_0f0c5fe120 FOREIGN KEY (organization_id) REFERENCES public.organizations(id); + + +-- +-- Name: fk_rails_148f563e25; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.petitions + ADD CONSTRAINT fk_rails_148f563e25 FOREIGN KEY (user_id) REFERENCES public.users(id); + + -- -- Name: fk_rails_1ceb778440; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -1285,6 +1364,10 @@ INSERT INTO "schema_migrations" (version) VALUES ('20210423193937'), ('20210424174640'), ('20210502160343'), -('20210503201944'); +('20210503201944'), +('20221016192111'), +('20230312231058'), +('20230314233504'), +('20230401114456'); diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index 66df6030e..e09b320d7 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -61,6 +61,17 @@ expect(assigns(:organizations)).to eq([second_organization]) end end + + context 'a user is logged' do + before { login(member.user) } + + it 'populates an array of user organizations' do + get :index + + expect(assigns(:user_organizations)).to include(member.organization) + expect(assigns(:organizations)).to eq([second_organization]) + end + end end describe 'GET #show' do diff --git a/spec/controllers/petitions_controller_spec.rb b/spec/controllers/petitions_controller_spec.rb new file mode 100644 index 000000000..be6897063 --- /dev/null +++ b/spec/controllers/petitions_controller_spec.rb @@ -0,0 +1,49 @@ +RSpec.describe PetitionsController do + let!(:organization) { Fabricate(:organization) } + let(:user) { Fabricate(:user) } + let!(:admin) { Fabricate(:member, organization: organization, manager: true) } + + describe 'POST #create' do + before { login(user) } + + it 'creates the petition' do + expect do + post :create, params: { user_id: user.id, organization_id: organization.id } + end.to change(Petition, :count).by(1) + end + end + + describe 'PUT #update' do + before { login(admin.user) } + let(:petition) { Petition.create(user: user, organization: organization, status: 'pending') } + + it 'decline the petition' do + put :update, params: { status: 'declined', id: petition.id } + + petition.reload + expect(petition.status).to eq('declined') + end + + it 'accept the petition and add the user to the org' do + put :update, params: { status: 'accepted', id: petition.id } + + petition.reload + expect(user.members.last.organization.id).to eq(organization.id) + expect(petition.status).to eq('accepted') + end + end + + describe 'GET #manage' do + before do + allow(controller).to receive(:current_organization) { organization } + login(admin.user) + end + let!(:petition) { Petition.create(user: user, organization: organization, status: 'pending') } + + it 'populates a list of users with pending petitions' do + get :manage + + expect(assigns(:users)).to include(user) + end + end +end diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb index f7b896cc0..a034f778c 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -28,13 +28,13 @@ it 'finds the destination account' do get :new, params: params - expect(response.body).to include("") + expect(response.body).to include("") end it 'builds a transfer with the id of the destination' do get :new, params: params expect(response.body) - .to include("") + .to include("") end context 'when the offer is specified' do @@ -47,7 +47,7 @@ it 'builds a transfer with the offer as post' do get :new, params: params.merge(offer: offer.id) - expect(response.body).to include("") + expect(response.body).to include("") end end @@ -94,13 +94,13 @@ it 'finds the destination account' do get :new, params: params - expect(response.body).to include("") + expect(response.body).to include("") end it 'builds a transfer with the id of the destination' do get :new, params: params expect(response.body) - .to include("") + .to include("") end context 'when the user is the admin of the current organization' do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 16676d9fb..f8a3f7a23 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -320,10 +320,23 @@ end end + + context 'with no logged user' do + before { allow_any_instance_of(ActionController::TestRequest).to receive(:referer).and_return(signup_users_path) } + + it 'creates the user' do + expect do + post :create, params: { user: Fabricate.to_params(:user, password: '1234test'), from_signup: 'true' } + end.to change(User, :count).by(1) + expect(subject).to redirect_to(terms_path) + end + end end end describe "PUT #update" do + before { allow_any_instance_of(ActionController::TestRequest).to receive(:referer).and_return('/edit') } + context "with valid params" do context "with a logged" do context "normal user" do diff --git a/spec/features/brand_logo_spec.rb b/spec/features/brand_logo_spec.rb deleted file mode 100644 index 00c913465..000000000 --- a/spec/features/brand_logo_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -RSpec.feature 'sign in' do - let(:user) do - user = Fabricate( - :user, - email: 'user@timeoverflow.org', - password: 'papapa22', - terms_accepted_at: 1.day.from_now - ) - - user.add_to_organization(organization) - - user - end - - let(:organization) { Fabricate(:organization) } - - context 'with a branded org id' do - before do - allow(Rails.application.config).to receive(:branded_organization_id).and_return(organization.id) - sign_in_with(user.email, user.password) - end - - it 'renders the logo' do - expect(page).to have_css('.organization-brand-logo') - end - end - - context 'without a branded org id' do - before do - allow(Rails.application.config).to receive(:branded_organization_id).and_return(1234) - sign_in_with(user.email, user.password) - end - - it 'does not render the logo' do - expect(page).to have_no_css('.organization-brand-logo') - end - end -end - -RSpec.feature 'sign out' do - let!(:user) do - Fabricate( - :user, - email: 'user@timeoverflow.org', - password: 'papapa22', - terms_accepted_at: 1.day.from_now - ) - end - - context 'without a user' do - it 'does not render the logo' do - sign_in_with(user.email, user.password) - click_link user.email - click_link I18n.t('application.navbar.sign_out') - - expect(page).to have_no_css('.organization-brand-logo') - end - end -end diff --git a/spec/helpers/active_admin_helper_spec.rb b/spec/helpers/active_admin_helper_spec.rb new file mode 100644 index 000000000..f7d0971d4 --- /dev/null +++ b/spec/helpers/active_admin_helper_spec.rb @@ -0,0 +1,8 @@ +RSpec.describe ActiveAdminHelper do + describe '#render_translations' do + it 'renders hash to HTML' do + attr_with_translations = { en: 'hi', es: 'hola' } + expect(helper.render_translations(attr_with_translations)).to eq("English: hi | Español: hola") + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8045aedaa..1ab96aa99 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,16 @@ -require 'simplecov' -SimpleCov.start 'rails' - ENV["RAILS_ENV"] ||= 'test' ENV["ADMINS"] = "admin@timeoverflow.org" +require 'simplecov' + +SimpleCov.formatter = if ENV["CI"] + require "simplecov_json_formatter" + SimpleCov::Formatter::JSONFormatter +else + SimpleCov::Formatter::HTMLFormatter +end +SimpleCov.start 'rails' + require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'capybara/rails'