From e831089934b03de718645a26d7e92887e55021eb Mon Sep 17 00:00:00 2001 From: Thiago Guerrero Date: Sun, 13 Mar 2022 22:52:09 -0300 Subject: [PATCH 01/20] migrate project to rails 7 + dockerization Signed-off-by: Thiago Guerrero --- .circleci/config.yml | 59 --- .env | 6 +- .env.sample | 5 + .gitattributes | 7 + .gitignore | 51 +- .ruby-gemset | 1 - .ruby-version | 2 +- Dockerfile | 25 + Gemfile | 114 +++-- Gemfile.lock | 441 ++++++++++-------- README.md | 27 +- Rakefile | 2 +- _config.yml | 1 - app.json | 17 - app/assets/javascripts/application.js | 19 +- app/assets/javascripts/bixos.coffee | 3 - app/assets/javascripts/cable.js | 13 - app/assets/stylesheets/application.scss | 41 +- app/assets/stylesheets/bixos.scss | 3 - app/assets/stylesheets/scaffolds.scss | 8 +- app/controllers/application_controller.rb | 23 - ...ixos_controller.rb => bixes_controller.rb} | 76 +-- app/controllers/confirmacoes_controller.rb | 15 + app/controllers/confirmations_controller.rb | 15 - app/controllers/modalidades_controller.rb | 4 +- app/controllers/pagamentos_controller.rb | 44 -- app/controllers/vendas_controller.rb | 83 ---- app/controllers/veteranos_controller.rb | 31 -- app/helpers/application_helper.rb | 10 +- app/helpers/bixes_helper.rb | 2 + app/helpers/bixos_helper.rb | 2 - app/helpers/confirmacoes_helper.rb | 2 + app/helpers/modalidades_helper.rb | 2 + app/helpers/vendas_helper.rb | 13 - app/jobs/application_job.rb | 5 + app/mailers/application_mailer.rb | 4 +- app/models/application_record.rb | 2 +- app/models/{bixo.rb => bixe.rb} | 10 +- app/models/confirmacao.rb | 10 + app/models/confirmation.rb | 9 - app/models/modalidade.rb | 4 +- app/models/pagamento.rb | 5 - app/models/venda.rb | 97 ---- app/models/veterano.rb | 4 - app/views/application/admin.html.erb | 8 - app/views/{bixos => bixes}/_form.html.erb | 21 +- app/views/{bixos => bixes}/contatos.html.erb | 6 +- app/views/bixes/emails.html.erb | 1 + app/views/{bixos => bixes}/index.html.erb | 5 +- .../{bixos => bixes}/modalidades.html.erb | 7 +- app/views/bixes/new.html.erb | 3 + app/views/{bixos => bixes}/show.html.erb | 20 +- app/views/bixos/_bixo.json.jbuilder | 2 - app/views/bixos/edit.html.erb | 3 - app/views/bixos/emails.html.erb | 1 - app/views/bixos/index.json.jbuilder | 1 - app/views/bixos/new.html.erb | 3 - app/views/bixos/show.json.jbuilder | 1 - .../index.html.erb | 8 +- app/views/layouts/application.html.erb | 18 +- app/views/layouts/mailer.html.erb | 13 - app/views/layouts/mailer.text.erb | 1 - app/views/modalidades/_form.html.erb | 2 +- app/views/modalidades/contatos.html.erb | 10 +- app/views/modalidades/edit.html.erb | 3 +- app/views/modalidades/index.html.erb | 3 +- app/views/modalidades/new.html.erb | 3 +- app/views/modalidades/show.html.erb | 5 +- app/views/pagamentos/edit.html.erb | 53 --- app/views/vendas/edit.html.erb | 61 --- app/views/vendas/index.html.erb | 102 ---- app/views/veteranos/index.html.erb | 49 -- bin/bundle | 3 - bin/rails | 11 +- bin/rake | 9 +- bin/setup | 31 +- bin/spring | 17 - bin/update | 29 -- bin/yarn | 11 - circle.yml | 12 - config.ru | 3 +- config/application.rb | 33 +- config/boot.rb | 5 +- config/cable.yml | 6 +- config/credentials.yml.enc | 1 + config/database.yml | 16 +- config/environment.rb | 2 +- config/environments/development.rb | 42 +- config/environments/production.rb | 52 ++- config/environments/test.rb | 40 +- .../application_controller_renderer.rb | 8 - config/initializers/assets.rb | 4 +- config/initializers/backtrace_silencers.rb | 7 - .../initializers/content_security_policy.rb | 26 ++ config/initializers/cookies_serializer.rb | 5 - .../initializers/filter_parameter_logging.rb | 8 +- config/initializers/inflections.rb | 12 +- config/initializers/mime_types.rb | 4 - config/initializers/permissions_policy.rb | 11 + config/initializers/wrap_parameters.rb | 14 - config/locales/en.yml | 8 +- config/puma.rb | 43 +- config/routes.rb | 25 +- config/secrets.yml | 32 -- config/spring.rb | 6 - config/storage.yml | 34 ++ ...03155057_create_bixos_modalidades_table.rb | 8 - db/migrate/20180205160823_create_vendas.rb | 11 - .../20180208165302_create_pagamentos.rb | 10 - db/migrate/20180208185214_create_veteranos.rb | 9 - ...85534_add_veterano_column_to_pagamentos.rb | 5 - ...20180210141332_drop_columns_from_vendas.rb | 6 - ...5_create_cor_and_tamanho_columns_as_int.rb | 6 - ...0180215102940_add_caneca_column_to_bixo.rb | 5 - .../20180215104914_add_caneca_to_venda.rb | 6 - ...214185449_add_tutorship_column_to_bixos.rb | 5 - .../20190214193750_create_confirmations.rb | 9 - ...ixos.rb => 20220313221143_create_bixes.rb} | 4 +- ...b => 20220313221313_create_modalidades.rb} | 2 +- .../20220313221535_create_confirmacoes.rb | 9 + ...14002825_create_bixes_modalidades_table.rb | 10 + db/schema.rb | 63 +-- db/seeds.rb | 8 +- db/test.sqlite3 | Bin 20480 -> 0 bytes docker-compose.yaml | 23 + entrypoint.sh | 8 + .../assets/javascripts/channels => log}/.keep | 0 package.json | 5 - process.yml | 185 -------- public/404.html | 67 +++ public/422.html | 67 +++ public/500.html | 66 +++ public/apple-touch-icon-precomposed.png | 0 public/apple-touch-icon.png | 0 public/favicon.ico | 0 public/robots.txt | 1 + .../confirmations_controller_spec.rb | 36 -- spec/factories/bixes.rb | 8 + spec/factories/bixo_factories.rb | 9 - spec/factories/confirmacaos.rb | 5 + spec/factories/confirmation_factories.rb | 5 - spec/factories/modalidades.rb | 5 + spec/helpers/bixes_helper_spec.rb | 15 + spec/helpers/confirmacoes_helper_spec.rb | 15 + spec/helpers/modalidades_helper_spec.rb | 15 + spec/models/bixe_spec.rb | 5 + spec/models/bixo_spec.rb | 26 -- spec/models/confirmacao_spec.rb | 5 + spec/models/confirmation_spec.rb | 5 - spec/models/modalidade_spec.rb | 2 +- spec/models/pagamento_spec.rb | 5 - spec/models/venda_spec.rb | 17 - spec/models/veterano_spec.rb | 5 - spec/rails_helper.rb | 63 --- spec/requests/bixes_spec.rb | 7 + spec/requests/confirmacoes_spec.rb | 7 + spec/requests/modalidades_spec.rb | 7 + spec/spec_helper.rb | 96 ---- storage/.keep | 0 test/application_system_test_case.rb | 5 + .../application_cable/connection_test.rb | 11 + test/controllers/.keep | 0 test/fixtures/files/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/system/.keep | 0 test/test_helper.rb | 13 + tmp/.keep | 0 tmp/pids/.keep | 0 tmp/storage/.keep | 0 vendor/.keep | 0 173 files changed, 1233 insertions(+), 2057 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .env.sample create mode 100644 .gitattributes delete mode 100644 .ruby-gemset create mode 100644 Dockerfile delete mode 100644 _config.yml delete mode 100644 app.json delete mode 100644 app/assets/javascripts/bixos.coffee delete mode 100644 app/assets/javascripts/cable.js delete mode 100644 app/assets/stylesheets/bixos.scss rename app/controllers/{bixos_controller.rb => bixes_controller.rb} (51%) create mode 100644 app/controllers/confirmacoes_controller.rb delete mode 100644 app/controllers/confirmations_controller.rb delete mode 100644 app/controllers/pagamentos_controller.rb delete mode 100644 app/controllers/vendas_controller.rb delete mode 100644 app/controllers/veteranos_controller.rb create mode 100644 app/helpers/bixes_helper.rb delete mode 100644 app/helpers/bixos_helper.rb create mode 100644 app/helpers/confirmacoes_helper.rb create mode 100644 app/helpers/modalidades_helper.rb delete mode 100644 app/helpers/vendas_helper.rb rename app/models/{bixo.rb => bixe.rb} (76%) create mode 100644 app/models/confirmacao.rb delete mode 100644 app/models/confirmation.rb delete mode 100644 app/models/pagamento.rb delete mode 100644 app/models/venda.rb delete mode 100644 app/models/veterano.rb delete mode 100644 app/views/application/admin.html.erb rename app/views/{bixos => bixes}/_form.html.erb (62%) rename app/views/{bixos => bixes}/contatos.html.erb (66%) create mode 100644 app/views/bixes/emails.html.erb rename app/views/{bixos => bixes}/index.html.erb (67%) rename app/views/{bixos => bixes}/modalidades.html.erb (82%) create mode 100644 app/views/bixes/new.html.erb rename app/views/{bixos => bixes}/show.html.erb (66%) delete mode 100644 app/views/bixos/_bixo.json.jbuilder delete mode 100644 app/views/bixos/edit.html.erb delete mode 100644 app/views/bixos/emails.html.erb delete mode 100644 app/views/bixos/index.json.jbuilder delete mode 100644 app/views/bixos/new.html.erb delete mode 100644 app/views/bixos/show.json.jbuilder rename app/views/{confirmations => confirmacoes}/index.html.erb (72%) delete mode 100644 app/views/layouts/mailer.html.erb delete mode 100644 app/views/layouts/mailer.text.erb delete mode 100644 app/views/pagamentos/edit.html.erb delete mode 100644 app/views/vendas/edit.html.erb delete mode 100644 app/views/vendas/index.html.erb delete mode 100644 app/views/veteranos/index.html.erb delete mode 100755 bin/bundle delete mode 100755 bin/spring delete mode 100755 bin/update delete mode 100755 bin/yarn delete mode 100644 circle.yml create mode 100644 config/credentials.yml.enc delete mode 100644 config/initializers/application_controller_renderer.rb delete mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/content_security_policy.rb delete mode 100644 config/initializers/cookies_serializer.rb delete mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/permissions_policy.rb delete mode 100644 config/initializers/wrap_parameters.rb delete mode 100644 config/secrets.yml delete mode 100644 config/spring.rb create mode 100644 config/storage.yml delete mode 100644 db/migrate/20171203155057_create_bixos_modalidades_table.rb delete mode 100644 db/migrate/20180205160823_create_vendas.rb delete mode 100644 db/migrate/20180208165302_create_pagamentos.rb delete mode 100644 db/migrate/20180208185214_create_veteranos.rb delete mode 100644 db/migrate/20180208185534_add_veterano_column_to_pagamentos.rb delete mode 100644 db/migrate/20180210141332_drop_columns_from_vendas.rb delete mode 100644 db/migrate/20180210141445_create_cor_and_tamanho_columns_as_int.rb delete mode 100644 db/migrate/20180215102940_add_caneca_column_to_bixo.rb delete mode 100644 db/migrate/20180215104914_add_caneca_to_venda.rb delete mode 100644 db/migrate/20190214185449_add_tutorship_column_to_bixos.rb delete mode 100644 db/migrate/20190214193750_create_confirmations.rb rename db/migrate/{20171005172531_create_bixos.rb => 20220313221143_create_bixes.rb} (63%) rename db/migrate/{20171202232819_create_modalidades.rb => 20220313221313_create_modalidades.rb} (66%) create mode 100644 db/migrate/20220313221535_create_confirmacoes.rb create mode 100644 db/migrate/20220314002825_create_bixes_modalidades_table.rb delete mode 100644 db/test.sqlite3 create mode 100644 docker-compose.yaml create mode 100644 entrypoint.sh rename {app/assets/javascripts/channels => log}/.keep (100%) delete mode 100644 package.json delete mode 100644 process.yml create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/apple-touch-icon-precomposed.png create mode 100644 public/apple-touch-icon.png create mode 100644 public/favicon.ico create mode 100644 public/robots.txt delete mode 100644 spec/controllers/confirmations_controller_spec.rb create mode 100644 spec/factories/bixes.rb delete mode 100644 spec/factories/bixo_factories.rb create mode 100644 spec/factories/confirmacaos.rb delete mode 100644 spec/factories/confirmation_factories.rb create mode 100644 spec/factories/modalidades.rb create mode 100644 spec/helpers/bixes_helper_spec.rb create mode 100644 spec/helpers/confirmacoes_helper_spec.rb create mode 100644 spec/helpers/modalidades_helper_spec.rb create mode 100644 spec/models/bixe_spec.rb delete mode 100644 spec/models/bixo_spec.rb create mode 100644 spec/models/confirmacao_spec.rb delete mode 100644 spec/models/confirmation_spec.rb delete mode 100644 spec/models/pagamento_spec.rb delete mode 100644 spec/models/venda_spec.rb delete mode 100644 spec/models/veterano_spec.rb delete mode 100644 spec/rails_helper.rb create mode 100644 spec/requests/bixes_spec.rb create mode 100644 spec/requests/confirmacoes_spec.rb create mode 100644 spec/requests/modalidades_spec.rb delete mode 100644 spec/spec_helper.rb create mode 100644 storage/.keep create mode 100644 test/application_system_test_case.rb create mode 100644 test/channels/application_cable/connection_test.rb create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/files/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/system/.keep create mode 100644 test/test_helper.rb create mode 100644 tmp/.keep create mode 100644 tmp/pids/.keep create mode 100644 tmp/storage/.keep create mode 100644 vendor/.keep diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3b2edaa..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,59 +0,0 @@ -version: 2.1 # Use 2.1 to enable using orbs and other features. - -# Declare the orbs that we'll use in our config. -# read more about orbs: https://circleci.com/docs/2.0/using-orbs/ -orbs: - ruby: circleci/ruby@1.0 - -jobs: - build: # our first job, named "build" - docker: - - image: cimg/ruby:2.6-node # use a tailored CircleCI docker image. - steps: - - checkout # pull down our git code. - - ruby/install-deps # use the ruby orb to install dependencies - - test: # our next job, called "test" - # we run "parallel job containers" to enable speeding up our tests; - # this splits our tests across multiple containers. - parallelism: 3 - # here we set TWO docker images. - docker: - - image: cimg/ruby:2.6-node # this is our primary docker image, where step commands run. - - image: circleci/postgres:9.6.2-alpine - environment: # add POSTGRES environment variables. - POSTGRES_USER: postgres - POSTGRES_DB: kitbixo_test - POSTGRES_PASSWORD: "postgres" - # environment variables specific to Ruby/Rails, applied to the primary container. - environment: - BUNDLE_JOBS: "3" - BUNDLE_RETRY: "3" - PGHOST: 127.0.0.1 - PGUSER: postgres - PGPASSWORD: "postgres" - RAILS_ENV: test - # A series of steps to run, some are similar to those in "build". - steps: - - checkout - - ruby/install-deps - # Here we make sure that the secondary container boots - # up before we run operations on the database. - - run: - name: Wait for DB - command: dockerize -wait tcp://localhost:5432 -timeout 1m - - run: - name: Database setup - command: bundle exec rails db:schema:load --trace - # Run rspec in parallel - - ruby/rspec-test - -# We use workflows to orchestrate the jobs that we declared above. -workflows: - version: 2 - build_and_test: # The name of our workflow is "build_and_test" - jobs: # The list of jobs we run as part of this workflow. - - build # Run build first. - - test: # Then run test, - requires: # Test requires that build passes for it to run. - - build # Finally, run the build job. diff --git a/.env b/.env index eed2a7a..312a09f 100644 --- a/.env +++ b/.env @@ -1 +1,5 @@ -PRECO: 80.0 +POSTGRES_USER=development +POSTGRES_PASSWORD=development +POSTGRES_HOST=postgres +ADMIN_USER=admin +ADMIN_PASSWORD=admin \ No newline at end of file diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..a537b0e --- /dev/null +++ b/.env.sample @@ -0,0 +1,5 @@ +POSTGRES_USER= +POSTGRES_PASSWORD= +POSTGRES_DB=development +ADMIN_USER= +ADMIN_PASSWORD= \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..31eeee0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/.gitignore b/.gitignore index 2a94cea..886f714 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,35 @@ -*~ -.*.swp -*.rbc -*.sassc -.sass-cache -capybara-*.html -.rspec -.rvmrc +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. /.bundle -/vendor/bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. /log/* /tmp/* -/db/development.sqlite3 -/public/system/* -/coverage/ -/spec/tmp/* -**.orig -rerun.txt -pickle-email-*.html -.project -config/initializers/secret_token.rb -*.sublime-workspace +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore uploaded files in development. +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/.ruby-gemset b/.ruby-gemset deleted file mode 100644 index 38f2be0..0000000 --- a/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -kitbixo diff --git a/.ruby-version b/.ruby-version index 6a96205..bff6ce5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.6@kitbixo +ruby-2.7.1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6a2f6d4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ruby:2.7.1-alpine + +ENV PORT=3000 \ + APP_PATH=/usr/src/app \ + HOST=0.0.0.0 \ + RAILS_ENV=development + +WORKDIR ${APP_PATH} + +RUN apk add --update \ + build-base git bash tzdata postgresql-dev && \ + gem install rails + +COPY . ./ + +RUN bundle install + +COPY entrypoint.sh /usr/bin/ +RUN chmod +x /usr/bin/entrypoint.sh +ENTRYPOINT ["entrypoint.sh"] + +EXPOSE ${PORT} + +CMD rails server -b ${HOST} +# CMD tail -f /dev/null diff --git a/Gemfile b/Gemfile index 00f828b..c9902ff 100644 --- a/Gemfile +++ b/Gemfile @@ -1,65 +1,81 @@ -ruby '2.6.6' +source "https://rubygems.org" +git_source(:github) { |repo| "https://github.com/#{repo}.git" } -source 'https://rubygems.org' -git_source(:github) do |repo_name| - repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - "https://github.com/#{repo_name}.git" -end +ruby "2.7.1" +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 7.0.2", ">= 7.0.2.3" -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.1.4' -# Use sqlite3 as the database for Active Record -gem 'pg', '~> 0.20.0' -# Use Puma as the app server -gem 'puma', '~> 3.7' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# See https://github.com/rails/execjs#readme for more supported runtimes -gem 'therubyracer', platforms: :ruby - -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2' -# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks -gem 'turbolinks', '~> 5' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' -# Use Redis adapter to run Action Cable in production -# gem 'redis', '~> 3.0' -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' +# Use .env file +gem "dotenv-rails" + +# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] +gem "sprockets-rails" + +# Use postgresql +gem "pg" + +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", "~> 5.0" + +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails" + +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem "turbo-rails" -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem "stimulus-rails" + +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +gem "jbuilder" + +# Use Sass to process CSS +gem "sassc-rails" # User bootstrap for styles library gem 'bootstrap-sass' gem 'jquery-rails' +# Use Redis adapter to run Action Cable in production +# gem "redis", "~> 4.0" + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem "kredis" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +# gem "image_processing", "~> 1.2" + group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] - gem 'dotenv-rails' + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem 'rspec-rails', '~> 5.0.0' gem 'factory_bot_rails' - gem 'pry-rails' - gem 'rspec-rails' -end - -group :test do - gem 'shoulda-matchers' - gem 'rspec_junit_formatter' end group :development do - # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. - gem 'web-console', '>= 3.3.0' - gem 'listen', '>= 3.0.5', '< 3.2' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" + + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + # gem "rack-mini-profiler" + + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + # gem "spring" end -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "capybara" + gem "selenium-webdriver" + gem "webdrivers" +end diff --git a/Gemfile.lock b/Gemfile.lock index 060eb42..6e2e61e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,240 +1,291 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.4) - actionpack (= 5.1.4) + actioncable (7.0.2.3) + actionpack (= 7.0.2.3) + activesupport (= 7.0.2.3) nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.2.3) + actionpack (= 7.0.2.3) + activejob (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.2.3) + actionpack (= 7.0.2.3) + actionview (= 7.0.2.3) + activejob (= 7.0.2.3) + activesupport (= 7.0.2.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (5.1.4) - actionview (= 5.1.4) - activesupport (= 5.1.4) - rack (~> 2.0) + actionpack (7.0.2.3) + actionview (= 7.0.2.3) + activesupport (= 7.0.2.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.4) - activesupport (= 5.1.4) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.2.3) + actionpack (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.2.3) + activesupport (= 7.0.2.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.4) - activesupport (= 5.1.4) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.2.3) + activesupport (= 7.0.2.3) globalid (>= 0.3.6) - activemodel (5.1.4) - activesupport (= 5.1.4) - activerecord (5.1.4) - activemodel (= 5.1.4) - activesupport (= 5.1.4) - arel (~> 8.0) - activesupport (5.1.4) + activemodel (7.0.2.3) + activesupport (= 7.0.2.3) + activerecord (7.0.2.3) + activemodel (= 7.0.2.3) + activesupport (= 7.0.2.3) + activestorage (7.0.2.3) + actionpack (= 7.0.2.3) + activejob (= 7.0.2.3) + activerecord (= 7.0.2.3) + activesupport (= 7.0.2.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (8.0.0) - autoprefixer-rails (7.1.6) - execjs - bindex (0.5.0) - bootstrap-sass (3.3.7) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + autoprefixer-rails (10.4.2.0) + execjs (~> 2) + bindex (0.8.1) + bootsnap (1.11.1) + msgpack (~> 1.2) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) - builder (3.2.3) - byebug (9.1.0) - coderay (1.1.2) - coffee-rails (4.2.2) - coffee-script (>= 2.2.0) - railties (>= 4.0.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - crass (1.0.2) - diff-lcs (1.3) - dotenv (2.2.1) - dotenv-rails (2.2.1) - dotenv (= 2.2.1) - railties (>= 3.2, < 5.2) - erubi (1.6.1) - execjs (2.7.0) - factory_bot (5.0.0) - activesupport (>= 4.2.0) - factory_bot_rails (5.0.1) - factory_bot (~> 5.0.0) - railties (>= 4.2.0) - ffi (1.9.18) - globalid (0.4.0) - activesupport (>= 4.2.0) - i18n (0.8.6) - jbuilder (2.7.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - jquery-rails (4.3.1) + sassc (>= 2.0.0) + builder (3.2.4) + capybara (3.36.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + childprocess (4.1.0) + concurrent-ruby (1.1.9) + crass (1.0.6) + debug (1.4.0) + irb (>= 1.3.6) + reline (>= 0.2.7) + diff-lcs (1.5.0) + digest (3.1.0) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) + erubi (1.10.0) + execjs (2.8.1) + factory_bot (6.2.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + ffi (1.15.5) + globalid (1.0.0) + activesupport (>= 5.0) + i18n (1.10.0) + concurrent-ruby (~> 1.0) + importmap-rails (1.0.3) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + io-console (0.5.11) + io-wait (0.2.1) + irb (1.4.1) + reline (>= 0.3.0) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - libv8 (3.16.14.19) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.1.1) + loofah (2.14.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.6) - mime-types (>= 1.16, < 4) - method_source (0.9.0) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_portile2 (2.3.0) - minitest (5.10.3) - multi_json (1.12.2) - nio4r (2.1.0) - nokogiri (1.8.1) - mini_portile2 (~> 2.3.0) - pg (0.20.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-rails (0.3.6) - pry (>= 0.10.4) - puma (3.10.0) - rack (2.0.3) - rack-test (0.7.0) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.2) + matrix (0.4.2) + method_source (1.0.0) + mini_mime (1.1.2) + mini_portile2 (2.8.0) + minitest (5.15.0) + msgpack (1.4.5) + net-imap (0.2.3) + digest + net-protocol + strscan + net-pop (0.1.1) + digest + net-protocol + timeout + net-protocol (0.1.2) + io-wait + timeout + net-smtp (0.3.1) + digest + net-protocol + timeout + nio4r (2.5.8) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + pg (1.3.4) + public_suffix (4.0.6) + puma (5.6.2) + nio4r (~> 2.0) + racc (1.6.0) + rack (2.2.3) + rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.1.4) - actioncable (= 5.1.4) - actionmailer (= 5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) - activemodel (= 5.1.4) - activerecord (= 5.1.4) - activesupport (= 5.1.4) - bundler (>= 1.3.0) - railties (= 5.1.4) - sprockets-rails (>= 2.0.0) + rails (7.0.2.3) + actioncable (= 7.0.2.3) + actionmailbox (= 7.0.2.3) + actionmailer (= 7.0.2.3) + actionpack (= 7.0.2.3) + actiontext (= 7.0.2.3) + actionview (= 7.0.2.3) + activejob (= 7.0.2.3) + activemodel (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) + bundler (>= 1.15.0) + railties (= 7.0.2.3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.1.4) - actionpack (= 5.1.4) - activesupport (= 5.1.4) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) + railties (7.0.2.3) + actionpack (= 7.0.2.3) + activesupport (= 7.0.2.3) method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (12.1.0) - rb-fsevent (0.10.2) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - ref (2.0.0) - rspec-core (3.6.0) - rspec-support (~> 3.6.0) - rspec-expectations (3.6.0) + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.0.6) + regexp_parser (2.2.1) + reline (0.3.1) + io-console (~> 0.5) + rexml (3.2.5) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-mocks (3.6.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-rails (3.6.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.6.0) - rspec-expectations (~> 3.6.0) - rspec-mocks (~> 3.6.0) - rspec-support (~> 3.6.0) - rspec-support (3.6.0) - rspec_junit_formatter (0.3.0) - rspec-core (>= 2, < 4, != 2.12.0) - ruby_dep (1.5.0) - sass (3.5.2) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.6) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - shoulda-matchers (3.1.2) - activesupport (>= 4.0.0) - spring (2.0.2) - activesupport (>= 4.2) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (3.7.1) + rspec-support (~> 3.11.0) + rspec-rails (5.0.3) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.11.0) + rubyzip (2.3.2) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + selenium-webdriver (4.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) - therubyracer (0.12.3) - libv8 (~> 3.16.14.15) - ref - thor (0.20.0) - thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.0.1) - turbolinks-source (~> 5) - turbolinks-source (5.0.3) - tzinfo (1.2.3) - thread_safe (~> 0.1) - uglifier (3.2.0) - execjs (>= 0.3.0, < 3) - web-console (3.5.1) - actionview (>= 5.0) - activemodel (>= 5.0) + stimulus-rails (1.0.4) + railties (>= 6.0.0) + strscan (3.0.1) + thor (1.2.1) + tilt (2.0.10) + timeout (0.2.0) + turbo-rails (1.0.1) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + web-console (4.2.0) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) bindex (>= 0.4.0) - railties (>= 5.0) - websocket-driver (0.6.5) + railties (>= 6.0.0) + webdrivers (5.0.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.5.4) PLATFORMS ruby DEPENDENCIES + bootsnap bootstrap-sass - byebug - coffee-rails (~> 4.2) + capybara + debug dotenv-rails factory_bot_rails - jbuilder (~> 2.5) + importmap-rails + jbuilder jquery-rails - listen (>= 3.0.5, < 3.2) - pg (~> 0.20.0) - pry-rails - puma (~> 3.7) - rails (~> 5.1.4) - rspec-rails - rspec_junit_formatter - sass-rails (~> 5.0) - shoulda-matchers - spring - spring-watcher-listen (~> 2.0.0) - therubyracer - turbolinks (~> 5) + pg + puma (~> 5.0) + rails (~> 7.0.2, >= 7.0.2.3) + rspec-rails (~> 5.0.0) + sassc-rails + selenium-webdriver + sprockets-rails + stimulus-rails + turbo-rails tzinfo-data - uglifier (>= 1.3.0) - web-console (>= 3.3.0) + web-console + webdrivers RUBY VERSION - ruby 2.6.6p146 + ruby 2.7.1p83 BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/README.md b/README.md index a03872b..7db80e4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,24 @@ -[![CircleCI](https://circleci.com/gh/eozaki/kitbixo/tree/master.svg?style=svg)](https://circleci.com/gh/eozaki/kitbixo/tree/master) # README -## About the project intentions -This is a backyard project to assist our Institute's Students Union and Athetlics Association to register the fishmen/women. -Feel free to copy, fork, distribute and all that, but make sure to mention us if you do, ok? Thanks. + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/Rakefile b/Rakefile index e85f913..9a5ea73 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 2f7efbe..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-minimal \ No newline at end of file diff --git a/app.json b/app.json deleted file mode 100644 index 7d7d65e..0000000 --- a/app.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "addons": [ - { - "plan": "heroku-postgresql", - "options": { - "version": "9.5" - } - } - ], - "environments": { - "test": { - "scripts": { - "test": "bundle exec rspec" - } - } - } -} diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 82580fe..f42d47a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,23 +1,8 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's -// vendor/assets/javascripts directory can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. JavaScript code in this file should be added after the last require_* statement. -// -// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require rails-ujs -//= require turbolinks -//= require_tree . //= require jquery3 -//= require jquery_ujs +//= require bootstrap-sprockets $(function() { $('.close').on('click', function() { $('.alert').fadeOut(); }); -}); +}); \ No newline at end of file diff --git a/app/assets/javascripts/bixos.coffee b/app/assets/javascripts/bixos.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/bixos.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js deleted file mode 100644 index 739aa5f..0000000 --- a/app/assets/javascripts/cable.js +++ /dev/null @@ -1,13 +0,0 @@ -// Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the `rails generate channel` command. -// -//= require action_cable -//= require_self -//= require_tree ./channels - -(function() { - this.App || (this.App = {}); - - App.cable = ActionCable.createConsumer(); - -}).call(this); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a4f978b..b01f164 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,18 +2,17 @@ * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's * vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * compiled file so the styles you add here take precedence over styles defined in any other CSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require_tree . *= require_self */ -// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables" @import "bootstrap-sprockets"; @import "bootstrap"; @@ -39,16 +38,16 @@ .banner { background: var(--sports-red); padding: 20px; - color: var(--sports-white);; + color: var(--sports-white); margin-bottom: 30px; } [class*="list-item-"]:not(:first-of-type) { - margin-top: 5px + margin-top: 5px; } [class*="col-"] { - display: block + display: block; } .list-item-0 { @@ -63,20 +62,24 @@ h4 { padding-left: 5%; } -.team-red { - background: lightpink; +.team-orange { + background: orange; } -.team-green { - background: lightgreen; +.team-gray { + background: lightgray; } -.team-yellow { - background: yellow; +.team-pink { + background: hotpink; } -.team-blue { - background: lightblue; +.team-black { + background: black; + + a { + color: #fff !important; + } } .btn { @@ -91,3 +94,13 @@ a:hover { input { width: 100%; } + +button { + background: none; + color: inherit; + border: none; + padding: 0; + font: inherit; + cursor: pointer; + outline: inherit; +} diff --git a/app/assets/stylesheets/bixos.scss b/app/assets/stylesheets/bixos.scss deleted file mode 100644 index af5f497..0000000 --- a/app/assets/stylesheets/bixos.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the bixos controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss index 6045188..25eec40 100644 --- a/app/assets/stylesheets/scaffolds.scss +++ b/app/assets/stylesheets/scaffolds.scss @@ -7,7 +7,10 @@ body { line-height: 18px; } -p, ol, ul, td { +p, +ol, +ul, +td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; @@ -41,7 +44,8 @@ td { } div { - &.field, &.actions { + &.field, + &.actions { margin-bottom: 10px; } } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b6ba9bd..09705d1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,25 +1,2 @@ class ApplicationController < ActionController::Base - protect_from_forgery with: :exception - - # GET /admin - def admin - end - - # POST /admin/limpa_mochilas - def limpa_mochilas - Venda.all.each do |v| - v.update_column :cor, nil unless v.pago? - end - end - - # POST /admin/arruma_canecas - def arruma_canecas - Venda.all.each do |v| - if v.created_at > Time.new(2018, 2, 15, 17, 57, 12) and v.pago? - v.update_column :caneca, true - else - v.update_column :caneca, false - end - end - end end diff --git a/app/controllers/bixos_controller.rb b/app/controllers/bixes_controller.rb similarity index 51% rename from app/controllers/bixos_controller.rb rename to app/controllers/bixes_controller.rb index 9c83df0..905ba3e 100644 --- a/app/controllers/bixos_controller.rb +++ b/app/controllers/bixes_controller.rb @@ -1,29 +1,29 @@ -class BixosController < ApplicationController - before_action :set_bixo, only: [:show, :edit, :update, :destroy, :modalidades, - :modify_modalidades, :nova_venda] +class BixesController < ApplicationController + before_action :set_bixe, only: [:show, :edit, :update, :destroy, :modalidades, + :modify_modalidades] - http_basic_authenticate_with name: "comissao", password: "bixoamigonaocomida", only: [:emails] + http_basic_authenticate_with name: ENV['ADMIN_USER'], password: ENV['ADMIN_PASSWORD'], only: [:emails] - # GET /bixos - # GET /bixos.json + # GET /bixes + # GET /bixes.json def index - @bixos = Bixo.all + @bixes = Bixe.all end - # GET /bixos/emails - # GET /bixos/emails.json + # GET /bixes/emails + # GET /bixes/emails.json def emails - @emails = Bixo.all.map(&:email).uniq + @emails = Bixe.all.map(&:email).uniq end - # GET /bixos/1 - # GET /bixos/1.json + # GET /bixes/1 + # GET /bixes/1.json def show end # GET /bixos/new def new - @bixo = Bixo.new + @bixe = Bixe.new end # GET /bixos/1/edit @@ -33,26 +33,26 @@ def edit # GET /bixos/1/modalidades def modalidades @check = {} - @bixo.modalidades.each do |m| + @bixe.modalidades.each do |m| @check[m.id] = true end end # GET /bixos/contatos def contatos - @bixos = Bixo.all + @bixes = Bixe.all end # POST /bixos/1/modalidades def modify_modalidades - @bixo.modalidades = modalidades_params.to_hash.map { |k,v| Modalidade.find(k) } + @bixe.modalidades = modalidades_params.to_hash.map { |k,v| Modalidade.find(k) } respond_to do |format| - if @bixo.save - format.html { redirect_to @bixo, notice: 'Modalidades modificadas com sucesso!' } - format.json { render :show, status: :created, location: @bixo } + if @bixe.save + format.html { redirect_to @bixe, notice: 'Modalidades modificadas com sucesso!' } + format.json { render :show, status: :created, location: @bixe } else format.html { flash[:error] = 'Deu caca em alguma coisa'; render :new } - format.json { render json: @bixo.errors, status: :unprocessable_entity } + format.json { render json: @bixe.errors, status: :unprocessable_entity } end end end @@ -60,15 +60,15 @@ def modify_modalidades # POST /bixos # POST /bixos.json def create - @bixo = Bixo.new(bixo_params) + @bixe = Bixe.new(bixe_params) respond_to do |format| - if @bixo.save - format.html { redirect_to @bixo, notice: 'bixe criado com sucesso!' } - format.json { render :show, status: :created, location: @bixo } + if @bixe.save + format.html { redirect_to @bixe, notice: 'bixe criado com sucesso!' } + format.json { render :show, status: :created, location: @bixe } else - format.html { flash[:error] = 'Deu caca em alguma coisa'; render :new } - format.json { render json: @bixo.errors, status: :unprocessable_entity } + format.html { flash[:error] = 'Preencha todos os dados!'; render :new } + format.json { render json: @bixe.errors, status: :unprocessable_entity } end end end @@ -77,12 +77,12 @@ def create # PATCH/PUT /bixos/1.json def update respond_to do |format| - if @bixo.update(bixo_params) - format.html { redirect_to @bixo, notice: 'bixe atualizado com sucesso' } - format.json { render :show, status: :ok, location: @bixo } + if @bixe.update(bixe_params) + format.html { redirect_to @bixe, notice: 'bixe atualizado com sucesso' } + format.json { render :show, status: :ok, location: @bixe } else format.html { render :edit } - format.json { render json: @bixo.errors, status: :unprocessable_entity } + format.json { render json: @bixe.errors, status: :unprocessable_entity } end end end @@ -90,23 +90,23 @@ def update # DELETE /bixos/1 # DELETE /bixos/1.json def destroy - @bixo.destroy + @bixe.destroy respond_to do |format| - format.html { redirect_to bixos_url, notice: 'bixe apagado com sucesso' } + format.html { redirect_to bixes_url, notice: 'bixe apagado com sucesso' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. - def set_bixo - @bixo = Bixo.find(params[:id]) + def set_bixe + @bixe = Bixe.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. - def bixo_params - params[:bixo][:curso] = params[:bixo][:curso].to_i - params.require(:bixo).permit(:nome, :email, :telefone, :curso) + def bixe_params + params[:bixe][:curso] = params[:bixe][:curso].to_i + params.require(:bixe).permit(:nome, :email, :telefone, :curso) end def modalidades_params @@ -116,4 +116,4 @@ def modalidades_params params.require(:modalidades).permit! end end -end +end \ No newline at end of file diff --git a/app/controllers/confirmacoes_controller.rb b/app/controllers/confirmacoes_controller.rb new file mode 100644 index 0000000..0c1051d --- /dev/null +++ b/app/controllers/confirmacoes_controller.rb @@ -0,0 +1,15 @@ +class ConfirmacoesController < ApplicationController + http_basic_authenticate_with name: ENV['ADMIN_USER'], password: ENV['ADMIN_PASSWORD'] + + def index + @confirmed = Bixe.confirmed + @non_confirmed = Bixe.non_confirmed + end + + def create + Confirmacao.create(bixe_id: params[:id]) if Bixe.find(params[:id]) + redirect_to confirmacoes_path, notice: 'Bixe confirmado' + rescue ActiveRecord::RecordNotFound => exception + redirect_to confirmacoes_path, alert: exception.message + end +end diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb deleted file mode 100644 index f55380b..0000000 --- a/app/controllers/confirmations_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ConfirmationsController < ApplicationController - http_basic_authenticate_with name: "comissao", password: "bixoamigonaocomida" - - def index - @confirmed = Bixo.confirmed - @non_confirmed = Bixo.non_confirmed - end - - def create - Confirmation.create(bixo_id: params[:id]) if Bixo.find(params[:id]) - redirect_to confirmations_path, notice: 'Bixo confirmado' - rescue ActiveRecord::RecordNotFound => exception - redirect_to confirmations_path, alert: exception.message - end -end diff --git a/app/controllers/modalidades_controller.rb b/app/controllers/modalidades_controller.rb index b8f9c68..8936a16 100644 --- a/app/controllers/modalidades_controller.rb +++ b/app/controllers/modalidades_controller.rb @@ -1,6 +1,6 @@ class ModalidadesController < ApplicationController - http_basic_authenticate_with name: "comissao", password: "bixoamigonaocomida" before_action :set_modalidade, only: [:show, :edit, :update, :destroy] + http_basic_authenticate_with name: ENV['ADMIN_USER'], password: ENV['ADMIN_PASSWORD'] # GET /modalidades # GET /modalidades.json @@ -77,4 +77,4 @@ def set_modalidade def modalidade_params params.require(:modalidade).permit(:nome) end -end +end \ No newline at end of file diff --git a/app/controllers/pagamentos_controller.rb b/app/controllers/pagamentos_controller.rb deleted file mode 100644 index 4ef1770..0000000 --- a/app/controllers/pagamentos_controller.rb +++ /dev/null @@ -1,44 +0,0 @@ -class PagamentosController < ApplicationController - before_action :set_pagamento, only: [:edit, :update, :destroy] - - # GET /pagamento/1/edit - def edit - end - - # PATCH/PUT /pagamento/1 - # PATCH/PUT /pagamento/1.json - def update - respond_to do |format| - if @pagamento.update(pagamento_params) - format.html { redirect_to @bixo, notice: 'Pagamento registrado com sucesso' } - format.json { render @bixo, status: :ok } - else - format.html { render :edit } - format.json { render json: @pagamento.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /pagamentos/1 - # DELETE /pagamentos/1.json - def destroy - @pagamento.destroy - respond_to do |format| - format.html { redirect_to @bixo, notice: 'Pagamento apagado com sucesso' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_pagamento - @pagamento = Pagamento.find(params[:id]) - @venda = @pagamento.venda - @bixo = @venda.bixo - end - - # Never trust parameters from the scary internet, only allow the white list through. - def pagamento_params - params.require(:pagamento).permit(:valor, :venda_id, :veterano_id) - end -end diff --git a/app/controllers/vendas_controller.rb b/app/controllers/vendas_controller.rb deleted file mode 100644 index 6fa0d9c..0000000 --- a/app/controllers/vendas_controller.rb +++ /dev/null @@ -1,83 +0,0 @@ -class VendasController < ApplicationController - before_action :set_venda, only: [:edit, :update, :destroy, :novo_pagamento] - before_action :make_stats, only: [:index, :inadimplentes, :sem_caneca] - - # GET /vendas - # GET /vendas.json - def index - @vendas = Venda.all - end - - # GET /vendas/inadimplentes - def inadimplentes - @vendas = Venda.pendentes - render :index - end - - # GET /vendas/sem_caneca - def sem_caneca - @vendas = Venda.where(caneca: false) - render :index - end - - # GET /vendas/1/edit - def edit - end - - # PATCH/PUT /vendas/1 - # PATCH/PUT /vendas/1.json - def update - respond_to do |format| - if @venda.update(venda_params) - format.html { redirect_to @venda.bixo, notice: 'Venda atualizada com sucesso' } - format.json { render @venda.bixo, status: :ok } - else - format.html { render :edit } - format.json { render json: @venda.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /vendas/1 - # DELETE /vendas/1.json - def destroy - @venda.destroy - respond_to do |format| - format.html { redirect_to @venda.bixo, notice: 'Venda apagada com sucesso' } - format.json { head :no_content } - end - end - - # PUT /vendas/1/pagamento - def novo_pagamento - @pagamento = Pagamento.new(valor: 0.0, venda_id: @venda.id, veterano_id: Veterano.first.id) - respond_to do |format| - if @pagamento.save - format.html { redirect_to edit_pagamento_path(@pagamento) } - format.json { render :show, status: :created, location: @pagamento } - else - format.html { flash[:error] = 'Deu caca em alguma coisa'; redirect_to @bixo } - format.json { render json: @venda.errors, status: :unprocessable_entity } - end - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_venda - @venda = Venda.find(params[:id]) - @bixo = @venda.bixo - end - - def make_stats - @stats = Venda.stats - end - - # Never trust parameters from the scary internet, only allow the white list through. - def venda_params - v = params.require(:venda).permit(:tamanho, :cor, :caneca, :bixo_id) - v[:tamanho] = v[:tamanho].to_i - v[:cor] = v[:cor].to_i unless v[:cor].nil? - v - end -end diff --git a/app/controllers/veteranos_controller.rb b/app/controllers/veteranos_controller.rb deleted file mode 100644 index bad95a8..0000000 --- a/app/controllers/veteranos_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class VeteranosController < ApplicationController - - # GET /veteranos - def index - @veteranos = Veterano.all - @veterano = Veterano.new - end - - # PUT /veteranos - def create - @veterano = Veterano.new(veterano_params) - - respond_to do |format| - if @veterano.save - format.html { redirect_to veteranos_path, notice: 'veterane criade com sucesso!' } - format.json { render :show, status: :created, location: @veterano } - else - format.html { flash[:error] = 'Deu caca em alguma coisa'; render :index } - format.json { render json: @veterano.errors, status: :unprocessable_entity } - end - end - end - - private - - # Never trust parameters from the scary internet, only allow the white list through. - def veterano_params - params.require(:veterano).permit(:nome) - end - -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cf6c877..5115575 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,4 @@ module ApplicationHelper - def bootstrap_class_for flash_type { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s end @@ -14,16 +13,15 @@ def flash_messages(opts = {}) nil end - def bixos_index? - params[:controller] == "bixos" and params[:action] == "index" + def bixes_index? + params[:controller] == "bixes" and params[:action] == "index" end - def confirmations_index? - params[:controller] == "confirmations" and params[:action] == "index" + def confirmacoes_index? + params[:controller] == "confirmacoes" and params[:action] == "index" end def modalidades_index? params[:controller] == "modalidades" and params[:action] == "index" end - end diff --git a/app/helpers/bixes_helper.rb b/app/helpers/bixes_helper.rb new file mode 100644 index 0000000..e038aa7 --- /dev/null +++ b/app/helpers/bixes_helper.rb @@ -0,0 +1,2 @@ +module BixesHelper +end diff --git a/app/helpers/bixos_helper.rb b/app/helpers/bixos_helper.rb deleted file mode 100644 index 98ea89e..0000000 --- a/app/helpers/bixos_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module BixosHelper -end diff --git a/app/helpers/confirmacoes_helper.rb b/app/helpers/confirmacoes_helper.rb new file mode 100644 index 0000000..bb88c5f --- /dev/null +++ b/app/helpers/confirmacoes_helper.rb @@ -0,0 +1,2 @@ +module ConfirmacoesHelper +end diff --git a/app/helpers/modalidades_helper.rb b/app/helpers/modalidades_helper.rb new file mode 100644 index 0000000..474bfbc --- /dev/null +++ b/app/helpers/modalidades_helper.rb @@ -0,0 +1,2 @@ +module ModalidadesHelper +end diff --git a/app/helpers/vendas_helper.rb b/app/helpers/vendas_helper.rb deleted file mode 100644 index 398a640..0000000 --- a/app/helpers/vendas_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module VendasHelper - def lista_todos? - params[:action] == 'index' - end - - def lista_inadimplentes? - params[:action] == 'inadimplentes' - end - - def lista_sem_caneca? - params[:action] == 'sem_caneca' - end -end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace..d394c3d 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,7 @@ class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..3c34c81 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba..b63caeb 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,3 @@ class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true + primary_abstract_class end diff --git a/app/models/bixo.rb b/app/models/bixe.rb similarity index 76% rename from app/models/bixo.rb rename to app/models/bixe.rb index e75809e..f091cbd 100644 --- a/app/models/bixo.rb +++ b/app/models/bixe.rb @@ -1,20 +1,18 @@ -class Bixo < ApplicationRecord +class Bixe < ApplicationRecord validates :nome, presence: true validates :telefone, presence: true validates :email, presence: true validates :curso, presence: true has_and_belongs_to_many :modalidades - - has_many :vendas - has_one :confirmation + has_one :confirmacao enum curso: [:LIC, :PURA, :BCC, :ESTAT, :APLICADA, :BMAC, :LICNOTURNO].freeze - delegate :team_color, to: :confirmation + delegate :team_color, to: :confirmacao def confirmed? - confirmation.present? + confirmacao.present? end def self.confirmed diff --git a/app/models/confirmacao.rb b/app/models/confirmacao.rb new file mode 100644 index 0000000..1d5f170 --- /dev/null +++ b/app/models/confirmacao.rb @@ -0,0 +1,10 @@ +class Confirmacao < ApplicationRecord + belongs_to :bixe + + COLORS = [:YELLOW, :BLUE, :ORANGE, :GRAY, :PINK, :BLACK].freeze + + + def team_color + COLORS[id % COLORS.length()].to_s.downcase + end +end diff --git a/app/models/confirmation.rb b/app/models/confirmation.rb deleted file mode 100644 index aad2822..0000000 --- a/app/models/confirmation.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Confirmation < ApplicationRecord - belongs_to :bixo - - COLORS = [:YELLOW, :BLUE, :GREEN, :RED].freeze - - def team_color - COLORS[id % 4].to_s.downcase - end -end diff --git a/app/models/modalidade.rb b/app/models/modalidade.rb index 8dacbd1..0ec4505 100644 --- a/app/models/modalidade.rb +++ b/app/models/modalidade.rb @@ -1,4 +1,4 @@ class Modalidade < ApplicationRecord - validates :nome, presence: true - has_and_belongs_to_many :bixos + validates :nome, presence: true, uniqueness: true + has_and_belongs_to_many :bixes end diff --git a/app/models/pagamento.rb b/app/models/pagamento.rb deleted file mode 100644 index 6c1a019..0000000 --- a/app/models/pagamento.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Pagamento < ApplicationRecord - validates :valor, presence: true - belongs_to :venda - belongs_to :veterano -end diff --git a/app/models/venda.rb b/app/models/venda.rb deleted file mode 100644 index 39d94f2..0000000 --- a/app/models/venda.rb +++ /dev/null @@ -1,97 +0,0 @@ -class Venda < ApplicationRecord - validates :tamanho, presence: true, on: :update - belongs_to :bixo - has_many :pagamentos - - enum cor: { branca: 0, vermelha: 1 } - enum tamanho: [:P, :M, :G, :GG, :BabyM, :BabyG, :BabyGG] - - def self.valor - 42.71 - end - - def self.preco - Rails.configuration.x.preco - end - - def self.estoque - estoque_camisetas.each_value.sum - end - - def self.estoque_camisetas - { - P: 35, - M: 55, - G: 45, - GG: 20, - BabyM: 5, - BabyG: 20, - BabyGG: 20 - } - end - - def self.estoque_mochilas - { - branca: 40, - vermelha: 160 - } - end - - def nome - bixo.nome - end - - def total_pago - pagamentos.sum(&:valor) - end - - def pago? - total_pago >= Venda.preco - end - - def self.pagos - all.select { |v| v.pago? } - end - - def self.pendentes - all - pagos - end - - def self.estoque_tamanho t - estoque_camisetas[t.to_sym] - where(tamanho: t).count - end - - def self.estoque_cor c - estoque_mochilas[c.to_sym] - where(cor: c).count - end - - def self.stats - stats = {} - stats[:vendidos] = all.count - stats[:pagos] = pagos.count - stats[:pendentes] = pendentes.count - total_pago = 0 - total_pendente = 0 - all.each do |v| - pago = v.total_pago - total_pago += pago - total_pendente += preco - pago - end - stats[:total_pago] = total_pago - stats[:total_pendente] = total_pendente - stats[:total_esperado] = total_pago + total_pendente - stats[:balanco] = total_pago - valor*estoque - stats[:balanco_esperado] = total_pago + total_pendente - valor*estoque - camisetas = {} - tamanhos.each do |k,t| - camisetas[k] = estoque_tamanho k.to_sym - end - stats[:camisetas] = camisetas - mochilas = {} - cors.each do |k,c| - mochilas[k] = estoque_cor k.to_sym - end - stats[:mochilas] = mochilas - stats - end -end diff --git a/app/models/veterano.rb b/app/models/veterano.rb deleted file mode 100644 index 3dcd85d..0000000 --- a/app/models/veterano.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Veterano < ApplicationRecord - validates :nome, presence: true - has_many :pagamentos -end diff --git a/app/views/application/admin.html.erb b/app/views/application/admin.html.erb deleted file mode 100644 index 5339ff8..0000000 --- a/app/views/application/admin.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - -

Admin

- -
- <%= link_to 'Limpar mochilas', limpa_mochilas_path, class: 'btn btn-danger btn-lg', method: :post %> - <%= link_to 'Arrumar canecas', arruma_canecas_path, class: 'btn btn-danger btn-lg', method: :post %> -
- diff --git a/app/views/bixos/_form.html.erb b/app/views/bixes/_form.html.erb similarity index 62% rename from app/views/bixos/_form.html.erb rename to app/views/bixes/_form.html.erb index f09b781..fa748c2 100644 --- a/app/views/bixos/_form.html.erb +++ b/app/views/bixes/_form.html.erb @@ -1,37 +1,30 @@ -<%= form_with(model: bixo, local: true) do |form| %> +<%= form_with(model: bixe, local: true) do |form| %>
<%= form.label "Nome: " %> - <%= form.text_field :nome, id: :bixo_nome, autofocus: true %> + <%= form.text_field :nome, id: :bixe_nome, autofocus: true %>
<%= form.label "Email: " %> - <%= form.text_field :email, id: :bixo_email %> + <%= form.text_field :email, id: :bixe_email %>
<%= form.label "Telefone: " %> - <%= form.text_field :telefone, id: :bixo_telefone %> + <%= form.text_field :telefone, id: :bixe_telefone %>
<%= form.label "Curso: " %>
- <%= form.collection_select :curso, Bixo.cursos, :last, :first %> -
-
- -
-
- <%= form.label "Tutoria BCC: " %>
- <%= form.check_box :tutorship %> + <%= form.collection_select :curso, Bixe.cursos, :last, :first %>
@@ -39,7 +32,7 @@
- <%= link_to 'Voltar à lista', bixos_path, class: 'btn btn-danger btn-lg btn-wide' %> + <%= link_to 'Voltar à lista', bixes_path, class: 'btn btn-danger btn-lg btn-wide' %>
@@ -49,4 +42,4 @@
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/bixos/contatos.html.erb b/app/views/bixes/contatos.html.erb similarity index 66% rename from app/views/bixos/contatos.html.erb rename to app/views/bixes/contatos.html.erb index 6f41328..9cee6b9 100644 --- a/app/views/bixos/contatos.html.erb +++ b/app/views/bixes/contatos.html.erb @@ -1,11 +1,9 @@ -

Contatos

E-mails

-<% @bixos.each do |b| %>
+<% @bixes.each do |b| %>
 <%= b.email %>,
 <% end %>
-
- + \ No newline at end of file diff --git a/app/views/bixes/emails.html.erb b/app/views/bixes/emails.html.erb new file mode 100644 index 0000000..a5440a6 --- /dev/null +++ b/app/views/bixes/emails.html.erb @@ -0,0 +1 @@ +<%= @emails.join(', ') %> \ No newline at end of file diff --git a/app/views/bixos/index.html.erb b/app/views/bixes/index.html.erb similarity index 67% rename from app/views/bixos/index.html.erb rename to app/views/bixes/index.html.erb index ef52565..ae3225c 100644 --- a/app/views/bixos/index.html.erb +++ b/app/views/bixes/index.html.erb @@ -1,8 +1,7 @@ -

Bixos cadastrados

- <%= link_to 'Novo bixe', new_bixo_path, class: 'btn btn-success btn-lg' %> + <%= link_to 'Novo bixe', new_bixe_path, class: 'btn btn-success btn-lg' %>
-
+ \ No newline at end of file diff --git a/app/views/bixos/modalidades.html.erb b/app/views/bixes/modalidades.html.erb similarity index 82% rename from app/views/bixos/modalidades.html.erb rename to app/views/bixes/modalidades.html.erb index 94ce73d..765f40f 100644 --- a/app/views/bixos/modalidades.html.erb +++ b/app/views/bixes/modalidades.html.erb @@ -1,5 +1,4 @@ - -

Mudar modalidades de <%= @bixo.nome %>

+

Mudar modalidades de <%= @bixe.nome %>

<%= form_tag do %> <% Modalidade.all.each do |mod| %> @@ -12,7 +11,7 @@
- <%= link_to 'Voltar', @bixo, class: 'btn btn-danger btn-lg btn-wide' %> + <%= link_to 'Voltar', @bixe, class: 'btn btn-danger btn-lg btn-wide' %>
@@ -22,4 +21,4 @@
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/bixes/new.html.erb b/app/views/bixes/new.html.erb new file mode 100644 index 0000000..efb4f6b --- /dev/null +++ b/app/views/bixes/new.html.erb @@ -0,0 +1,3 @@ +

Novo bixe

+ +<%= render 'form', bixe: @bixe %> \ No newline at end of file diff --git a/app/views/bixos/show.html.erb b/app/views/bixes/show.html.erb similarity index 66% rename from app/views/bixos/show.html.erb rename to app/views/bixes/show.html.erb index 657aa41..6f8aa04 100644 --- a/app/views/bixos/show.html.erb +++ b/app/views/bixes/show.html.erb @@ -1,4 +1,4 @@ -

<%= @bixo.nome %>

+

<%= @bixe.nome %>

@@ -8,49 +8,49 @@

Nome

- <%= @bixo.nome %> + <%= @bixe.nome %>

E-mail

- <%= @bixo.email %> + <%= @bixe.email %>

Telefone

- <%= @bixo.telefone %> + <%= @bixe.telefone %>

Curso

- <%= @bixo.curso %> + <%= @bixe.curso %>

Modalidades

- <% if @bixo.modalidades.empty? %> + <% if @bixe.modalidades.empty? %>

Nenhuma

<% else %> - <% @bixo.modalidades.each do |mod| %> + <% @bixe.modalidades.each do |mod| %>

<%= mod.nome %>

<% end %> <% end %>
- <%= link_to 'Mudar modalidades', edit_bixo_modalidades_path(@bixo), class: 'btn btn-success btn-lg' %> + <%= link_to 'Mudar modalidades', edit_bixe_modalidades_path(@bixe), class: 'btn btn-success btn-lg' %>
- <%= link_to 'Voltar à lista', bixos_path, class: 'btn btn-danger btn-lg' %> -
+ <%= link_to 'Voltar à lista', bixes_path, class: 'btn btn-danger btn-lg' %> + \ No newline at end of file diff --git a/app/views/bixos/_bixo.json.jbuilder b/app/views/bixos/_bixo.json.jbuilder deleted file mode 100644 index b1ab77d..0000000 --- a/app/views/bixos/_bixo.json.jbuilder +++ /dev/null @@ -1,2 +0,0 @@ -json.extract! bixo, :id, :nome, :email, :telefone, :curso, :created_at, :updated_at -json.url bixo_url(bixo, format: :json) diff --git a/app/views/bixos/edit.html.erb b/app/views/bixos/edit.html.erb deleted file mode 100644 index 132545d..0000000 --- a/app/views/bixos/edit.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

Editar bixe

- -<%= render 'form', bixo: @bixo %> diff --git a/app/views/bixos/emails.html.erb b/app/views/bixos/emails.html.erb deleted file mode 100644 index 58c3330..0000000 --- a/app/views/bixos/emails.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= @emails.join(', ') %> diff --git a/app/views/bixos/index.json.jbuilder b/app/views/bixos/index.json.jbuilder deleted file mode 100644 index 3f11d3c..0000000 --- a/app/views/bixos/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @bixos, partial: 'bixos/bixo', as: :bixo diff --git a/app/views/bixos/new.html.erb b/app/views/bixos/new.html.erb deleted file mode 100644 index 1a3110c..0000000 --- a/app/views/bixos/new.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

Novo bixe

- -<%= render 'form', bixo: @bixo %> diff --git a/app/views/bixos/show.json.jbuilder b/app/views/bixos/show.json.jbuilder deleted file mode 100644 index f434ba3..0000000 --- a/app/views/bixos/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! "bixos/bixo", bixo: @bixo diff --git a/app/views/confirmations/index.html.erb b/app/views/confirmacoes/index.html.erb similarity index 72% rename from app/views/confirmations/index.html.erb rename to app/views/confirmacoes/index.html.erb index b8bb979..57a85f4 100644 --- a/app/views/confirmations/index.html.erb +++ b/app/views/confirmacoes/index.html.erb @@ -1,11 +1,11 @@
-

Bixos não confirmados

+

Bixes não confirmados

<% @non_confirmed.each_with_index do |b, i| %>

- <%= link_to b.nome, "/bixos/#{b.id}/confirmations", method: :post %> + <%= button_to b.nome, "/bixes/#{b.id}/confirmacoes", method: :post %>

<% end %> @@ -18,9 +18,9 @@ <% @confirmed.each_with_index do |b, i| %>

- <%= link_to b.nome, bixo_path(b.id) %> + <%= link_to b.nome, bixe_path(b.id) %>

<% end %>
-
+ \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4a7e07a..0c7f7e5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,11 +1,12 @@ - Kitbixo + Cadastro bixes IME-USP + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolink-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolink-track': 'reload' %> + <%= csrf_meta_tags %> - - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= csp_meta_tag %> @@ -21,19 +22,20 @@
<%= flash_messages %> + <%= yield %>
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb deleted file mode 100644 index cbd34d2..0000000 --- a/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bdd..0000000 --- a/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/app/views/modalidades/_form.html.erb b/app/views/modalidades/_form.html.erb index 46eafef..ed0d93c 100644 --- a/app/views/modalidades/_form.html.erb +++ b/app/views/modalidades/_form.html.erb @@ -19,4 +19,4 @@
<%= form.submit %>
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/modalidades/contatos.html.erb b/app/views/modalidades/contatos.html.erb index 0edc787..5b2ba33 100644 --- a/app/views/modalidades/contatos.html.erb +++ b/app/views/modalidades/contatos.html.erb @@ -1,4 +1,3 @@ -

Contatos por modalidade

E-mails

@@ -6,10 +5,9 @@
 <% @modalidades.each do |m| %>
 # <%= m.nome %>
-<% m.bixos.each do |b| %>
+<% m.bixes.each do |b| %>
 <%= b.email %>
 <% end %>
-
 <% end %>
 
@@ -18,10 +16,8 @@
 <% @modalidades.each do |m| %>
 # <%= m.nome %>
-<% m.bixos.each do |b| %>
+<% m.bixes.each do |b| %>
 <%= b.telefone %> <%= b.nome %>
 <% end %>
-
 <% end %>
-
- + \ No newline at end of file diff --git a/app/views/modalidades/edit.html.erb b/app/views/modalidades/edit.html.erb index 68e959e..9cf3b73 100644 --- a/app/views/modalidades/edit.html.erb +++ b/app/views/modalidades/edit.html.erb @@ -1,6 +1,5 @@

Editing Modalidade

<%= render 'form', modalidade: @modalidade %> - <%= link_to 'Show', @modalidade %> | -<%= link_to 'Back', modalidades_path %> +<%= link_to 'Back', modalidades_path %> \ No newline at end of file diff --git a/app/views/modalidades/index.html.erb b/app/views/modalidades/index.html.erb index 59877e8..888e604 100644 --- a/app/views/modalidades/index.html.erb +++ b/app/views/modalidades/index.html.erb @@ -1,4 +1,3 @@ -

Modalidades da AAAMat

@@ -19,4 +18,4 @@ <% end %>
<% end %> - + \ No newline at end of file diff --git a/app/views/modalidades/new.html.erb b/app/views/modalidades/new.html.erb index 53a11bc..e2444dd 100644 --- a/app/views/modalidades/new.html.erb +++ b/app/views/modalidades/new.html.erb @@ -1,5 +1,4 @@

Nova Modalidade

<%= render 'form', modalidade: @modalidade %> - -<%= link_to 'Voltar', modalidades_path %> +<%= link_to 'Voltar', modalidades_path %> \ No newline at end of file diff --git a/app/views/modalidades/show.html.erb b/app/views/modalidades/show.html.erb index f75bdd3..ea718c4 100644 --- a/app/views/modalidades/show.html.erb +++ b/app/views/modalidades/show.html.erb @@ -19,7 +19,7 @@

Bixos na modalidade

- <% @modalidade.bixos.each_with_index do |b, i| %> + <% @modalidade.bixes.each_with_index do |b, i| %>
<%= link_to bixo_path(b.id) do %>

@@ -36,5 +36,4 @@ <% end %>

<% end %> -
- + \ No newline at end of file diff --git a/app/views/pagamentos/edit.html.erb b/app/views/pagamentos/edit.html.erb deleted file mode 100644 index 2fc9c7c..0000000 --- a/app/views/pagamentos/edit.html.erb +++ /dev/null @@ -1,53 +0,0 @@ -

Editando pagamento do kit-bixo de <%= @bixo.nome %>

- -
-
-
- <%= form_with(model: @pagamento, local: true) do |form| %> - <% if @pagamento.errors.any? %> -
-

<%= pluralize(venda.errors.count, "error") %> prohibited this venda from being saved:

- -
    - <% @pagamento.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -

Valor pago

- - <%= hidden_field(:pagamento, :venda_id, value: @venda.id) %> - -
- <%= number_field(:pagamento, :valor, in: 0.0 .. Venda.preco, step: 1.0) %> -
- -

Veterane que recebeu o pagamento

- - <% Veterano.all.each do |veterano| %> -
- <%= radio_button_tag("pagamento[veterano_id]", veterano.id, (veterano.id==@pagamento.veterano_id)) %> - <%= label_tag("pagamento[veterano_id]", veterano.nome) %> -
- <% end %> - -
-
-
- <%= link_to 'Voltar', @bixo, class: 'btn btn-danger btn-lg btn-wide'%> -
-
- -
-
- <%= form.submit "Confirmar", class: 'btn btn-success btn-lg' %> -
-
-
- <% end %> -
-
-
- diff --git a/app/views/vendas/edit.html.erb b/app/views/vendas/edit.html.erb deleted file mode 100644 index 804a900..0000000 --- a/app/views/vendas/edit.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -

Editando kit-bixo de <%= @bixo.nome %>

- -
-
-
- <%= form_with(model: @venda, local: true) do |form| %> - <% if @venda.errors.any? %> -
-

<%= pluralize(venda.errors.count, "error") %> prohibited this venda from being saved:

- -
    - <% @venda.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -

Tamanho da camiseta

- - <% Venda.tamanhos.each do |k, v| %> -
- <%= radio_button_tag("venda[tamanho]", v, (k == @venda.tamanho)) %> - <%= label_tag("venda[tamanho]", k) %> -
- <% end %> - -

Cor da mochila

- - <% Venda.cors.each do |k, v| %> -
- <%= radio_button_tag("venda[cor]", v, (k == @venda.cor)) %> - <%= label_tag("venda[cor]", k) %> -
- <% end %> - -
-
-

Caneca:

- Já recebeu <%= form.check_box :caneca %> -
-
- -
-
-
- <%= link_to 'Voltar', @bixo, class: 'btn btn-danger btn-lg btn-wide' %> -
-
- -
-
- <%= form.submit "Confirmar", class: 'btn btn-success btn-lg' %> -
-
-
- <% end %> -
-
-
- diff --git a/app/views/vendas/index.html.erb b/app/views/vendas/index.html.erb deleted file mode 100644 index c195046..0000000 --- a/app/views/vendas/index.html.erb +++ /dev/null @@ -1,102 +0,0 @@ - -

Venda de kits

- -
-
-

Kits vendidos

-

- <%= @stats[:pagos] %> pagos -

-

- <%= @stats[:pendentes] %> pendentes -

-

- <%= @stats[:vendidos] %> no total -

-
-
-

Arrecadação

-

- R$ <%= "%.2f" % @stats[:total_pago] %> pago -

-

- R$ <%= "%.2f" % @stats[:total_pendente] %> pendente -

-

- R$ <%= "%.2f" % @stats[:total_esperado] %> esperado no total -

-

- <% if @stats[:balanco] < 0 %><% else%><% end %> - R$ <%= "%.2f" % @stats[:balanco] %> de balanço real - -

-

- <% if @stats[:balanco_esperado] < 0 %><% else%><% end %> - R$ <%= "%.2f" % @stats[:balanco_esperado] %> de balanço esperado - -

-
-
-

Estoque de camisetas

-
- <% @stats[:camisetas].each do |tamanho,count| %> -
-

- <%= count %> <%= tamanho %> -

-
- <% end %> -
-
-
-

Estoque de mochilas

-
- <% @stats[:mochilas].each do |cor,count| %> -
-

- <%= count %> <%= cor.pluralize %> -

-
- <% end %> -
-
-
- -
-
- -
-
- -
- <% @vendas.each_with_index do |v, i| %> -
-

-
- <%= link_to v.nome, bixo_path(v.bixo.id) %> -
-
- <%= v.cor.nil? ? "---" : v.cor %> -
-
- <%= v.tamanho %> -
-
- <% if v.pago? %><% else %><% end %> - <%= v.total_pago %> - -
-

-
- <% end %> -
diff --git a/app/views/veteranos/index.html.erb b/app/views/veteranos/index.html.erb deleted file mode 100644 index 0f028a0..0000000 --- a/app/views/veteranos/index.html.erb +++ /dev/null @@ -1,49 +0,0 @@ - - -
-
-
-

Veteranes

-
- <% @veteranos.each_with_index do |b, i| %> -
-
- <%= b.nome %> -
-
- <% end %> -
-
-
-
- -
- -
-
-
- <%= form_with(model: @veterano, local: true) do |form| %> - <% if @veterano.errors.any? %> -
-

<%= pluralize(venda.errors.count, "error") %> prohibited this venda from being saved:

- -
    - <% @veterano.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= text_field(:veterano, :nome) %> -
- -
- <%= form.submit "Cadastrar veterane", class: 'btn btn-success' %> -
- <% end %> -
-
-
- diff --git a/bin/bundle b/bin/bundle deleted file mode 100755 index 66e9889..0000000 --- a/bin/bundle +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails index 5badb2f..efc0377 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index d87d5f5..4fbf10b 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 78c4e86..ec47b79 100755 --- a/bin/setup +++ b/bin/setup @@ -1,38 +1,33 @@ #!/usr/bin/env ruby -require 'pathname' -require 'fileutils' -include FileUtils +require "fileutils" # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -chdir APP_ROOT do - # This script is a starting point to setup your application. +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - # Install JavaScript dependencies if using Yarn - # system('bin/yarn') - + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/bin/spring b/bin/spring deleted file mode 100755 index fb2ec2e..0000000 --- a/bin/spring +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby - -# This file loads spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require 'rubygems' - require 'bundler' - - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == "spring" } - if spring - Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem 'spring', spring.version - require 'spring/binstub' - end -end diff --git a/bin/update b/bin/update deleted file mode 100755 index a8e4462..0000000 --- a/bin/update +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -require 'pathname' -require 'fileutils' -include FileUtils - -# path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) - -def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") -end - -chdir APP_ROOT do - # This script is a way to update your development environment automatically. - # Add necessary update steps to this file. - - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - puts "\n== Updating database ==" - system! 'bin/rails db:migrate' - - puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' - - puts "\n== Restarting application server ==" - system! 'bin/rails restart' -end diff --git a/bin/yarn b/bin/yarn deleted file mode 100755 index c2bacef..0000000 --- a/bin/yarn +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env ruby -VENDOR_PATH = File.expand_path('..', __dir__) -Dir.chdir(VENDOR_PATH) do - begin - exec "yarnpkg #{ARGV.join(" ")}" - rescue Errno::ENOENT - $stderr.puts "Yarn executable was not detected in the system." - $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" - exit 1 - end -end diff --git a/circle.yml b/circle.yml deleted file mode 100644 index b628884..0000000 --- a/circle.yml +++ /dev/null @@ -1,12 +0,0 @@ -steps: - - run: bundle exec rspec --format documentation - -deployment: - staging: - branch: master - heroku: - appname: kitbixo-imeusp - commands: - - rspec - - git push git@heroku.com:kitbixo-imeusp.git $CIRCLE_SHA1:master - - heroku run rake db:migrate --app kitbixo-imeusp diff --git a/config.ru b/config.ru index f7ba0b5..4a3c09a 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,6 @@ # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index dc41907..08827dd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,33 +1,22 @@ -require_relative 'boot' +require_relative "boot" -require "rails" -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "action_cable/engine" +require "rails/all" require "sprockets/railtie" -# require "rails/test_unit/railtie" - # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Kitbixo +module App class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.1 - - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Don't generate system test files. - config.generators.system_tests = nil + config.load_defaults 7.0 - config.x.preco = ENV['PRECO'].to_f + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") end end diff --git a/config/boot.rb b/config/boot.rb index 30f5120..988a5dd 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml index a733b67..f39dc04 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -2,9 +2,9 @@ development: adapter: async test: - adapter: async + adapter: test production: adapter: redis - url: redis://localhost:6379/1 - channel_prefix: kitbixo_production + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: app_production diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000..22e0266 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +OubihX29sdtvfH5D3iff+MmJPsG/eVhWuUkk1yYr38u4KucJylvi8oiCe9o+GRvSnbsPiNo7Xlk9XqHa49OQQwL88Ji2Emyn7WTp+mKZr+QBpMzAjXs8FyfOMa46rK4Sq+JsjP9UoH1lS6vZgQjhjT1z4tBj83MsgNk2/LJYP5TreZJItDtWw07SAZwpPgvvX9mgKKU/7IFCIILhwij+y4bb+Qaod+Yizmb3mQiUx4epVeN1O/5tkCgEv+4z5T0dghOXWtgj8hS09OU31wZsIjbrav65Hg69luJ2cxs0NzYw1PDH5wv+GzXPPja97gt4bSORBImxJxvNGzC5i64NXKEw1tFx2cD3hASIoZdmghpey6Dg6c9T07gejLcrV3gpQF/BTeuis04nJdnq95YK51S/0Crrgox2mzQb--oXco45FN53bP66WV--lFYlwWy96g1qN0iZBomjOA== \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index b2effdc..a6e6b34 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,10 +1,16 @@ +# SQLite. Versions 3.8.0 and up are supported. +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem "sqlite3" +# default: &default - host: localhost adapter: postgresql - username: postgres - password: postgres + encoding: unicode + host: <%= ENV['POSTGRES_HOST'] %> + username: <%= ENV['POSTGRES_USER'] %> + password: <%= ENV['POSTGRES_PASSWORD'] %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 development: <<: *default @@ -15,7 +21,7 @@ development: # Do not set this db to the same as development or production. test: <<: *default - database: kitbixo_test + database: test production: <<: *default diff --git a/config/environment.rb b/config/environment.rb index 426333b..cac5315 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 5187e22..8500f45 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,8 +1,10 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false @@ -12,13 +14,18 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. - if Rails.root.join('tmp/caching-dev.txt').exist? + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -26,6 +33,9 @@ config.cache_store = :null_store end + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -34,21 +44,27 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true # Suppress logger output for asset requests. config.assets.quiet = true - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 3c08832..ab507d3 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -14,43 +16,42 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Attempt to read encrypted secrets from `config/secrets.yml.enc`. - # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or - # `config/secrets.yml.key`. - config.read_encrypted_secrets = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.initialize_on_precompile = false + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local - # Mount Action Cable outside main process or domain + # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] @@ -58,9 +59,10 @@ # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment) + # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "kitbixo_#{Rails.env}" + # config.active_job.queue_name_prefix = "app_production" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -71,15 +73,15 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify + # Don't log any deprecations. + config.active_support.report_deprecations = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. - # require 'syslog/logger' - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) diff --git a/config/environments/test.rb b/config/environments/test.rb index 8e5cbde..6ea4d1e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,32 +1,41 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -37,6 +46,15 @@ # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb deleted file mode 100644 index 89d2efa..0000000 --- a/config/initializers/application_controller_renderer.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# ActiveSupport::Reloader.to_prepare do -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) -# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 4b828e8..2eeef96 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,12 +1,10 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb deleted file mode 100644 index 59385cd..0000000 --- a/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..3621f97 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,26 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report CSP violations to a specified URI. See: +# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb deleted file mode 100644 index 5a6a32d..0000000 --- a/config/initializers/cookies_serializer.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Specify a serializer for the signed and encrypted cookie jars. -# Valid options are :json, :marshal, and :hybrid. -Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1..adc6568 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf..66b741e 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,17 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end +ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.irregular "bixe", "bixes" + inflect.irregular "confirmacao", "confirmacoes" +end \ No newline at end of file diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb deleted file mode 100644 index dc18996..0000000 --- a/config/initializers/mime_types.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 0000000..00f64d7 --- /dev/null +++ b/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb deleted file mode 100644 index bbfc396..0000000 --- a/config/initializers/wrap_parameters.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# This file contains settings for ActionController::ParamsWrapper which -# is enabled by default. - -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] -end - -# To enable root element in JSON for ActiveRecord objects. -# ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true -# end diff --git a/config/locales/en.yml b/config/locales/en.yml index decc5a8..8ca56fc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4,11 +4,11 @@ # # To use the locales, use `I18n.t`: # -# I18n.t 'hello' +# I18n.t "hello" # # In views, this is aliased to just `t`: # -# <%= t('hello') %> +# <%= t("hello") %> # # To use a different locale, set it with `I18n.locale`: # @@ -24,10 +24,10 @@ # Instead, surround them with single quotes. # # en: -# 'true': 'foo' +# "true": "foo" # # To learn more, please read the Rails Internationalization guide -# available at http://guides.rubyonrails.org/i18n.html. +# available at https://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb index 1e19380..daaf036 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,19 +4,28 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -threads threads_count, threads_count +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + # Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together +# Workers are forked web server processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). @@ -26,31 +35,9 @@ # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. +# process behavior so workers use less memory. # # preload_app! -# If you are preloading your application and using Active Record, it's -# recommended that you close any connections to the database before workers -# are forked to prevent connection leakage. -# -# before_fork do -# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) -# end - -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted, this block will be run. If you are using the `preload_app!` -# option, you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, as Ruby -# cannot share connections between processes. -# -# on_worker_boot do -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -# end -# - -# Allow puma to be restarted by `rails restart` command. +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb index 38b7037..b4ab8af 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,30 +1,21 @@ Rails.application.routes.draw do - root to: 'bixos#index' - - resources :bixos, only: [] do + root to: 'bixes#index' + resources :bixes, only: [] do collection do - resources :confirmations, only: %i(index) + resources :confirmacoes, only: %i(index) get :emails end member do - resources :confirmations, only: %i(create) + resources :confirmacoes, only: %i(create) end end - get '/bixos/contatos' => 'bixos#contatos', as: :contatos - get '/bixos/:id/modalidades' => 'bixos#modalidades', as: :edit_bixo_modalidades - post '/bixos/:id/modalidades' => 'bixos#modify_modalidades', as: :modify_bixo_modalidades + get '/bixes/contatos' => 'bixes#contatos', as: :contatos + get '/bixes/:id/modalidades' => 'bixes#modalidades', as: :edit_bixe_modalidades + post '/bixes/:id/modalidades' => 'bixes#modify_modalidades', as: :modify_bixe_modalidades get '/modalidades/contatos' => 'modalidades#contatos', as: :contato_modalidades - - get '/admin' => 'application#admin', as: :admin - post '/admin/limpar_mochilas' => 'application#limpa_mochilas', as: :limpa_mochilas - post '/admin/arruma_canecas' => 'application#arruma_canecas', as: :arruma_canecas - - resources :bixos, except: [:edit] - resources :veteranos, except: [:show, :new] + resources :bixes, except: [:edit] resources :modalidades - resources :vendas, except: [:show, :new, :create] - resources :pagamentos, except: [:show, :index, :new, :create] end diff --git a/config/secrets.yml b/config/secrets.yml deleted file mode 100644 index c2d15c2..0000000 --- a/config/secrets.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rails secret` to generate a secure secret key. - -# Make sure the secrets in this file are kept private -# if you're sharing your code publicly. - -# Shared secrets are available across all environments. - -# shared: -# api_key: a1B2c3D4e5F6 - -# Environmental secrets are only available for that specific environment. - -development: - secret_key_base: e5cfd2678b6da1f420b8f1abc39a668dbc8f5d1290d3c0bcef7424185fa87b0f6ef846f4666011efba49e661add014020cb4cc18c19a545c60c128eaee9cfb91 - -test: - secret_key_base: b6ac52715ce5d25711677f9290c15d8d0b325bb8c50f0a1ace59b8257b5994ff7d6d800a533f749e4e43c0ea81aa1d5fdd657ee6e7d9821c91512ea76eec7f0f - -# Do not keep production secrets in the unencrypted secrets file. -# Instead, either read values from the environment. -# Or, use `bin/rails secrets:setup` to configure encrypted secrets -# and move the `production:` environment over there. - -production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/spring.rb b/config/spring.rb deleted file mode 100644 index c9119b4..0000000 --- a/config/spring.rb +++ /dev/null @@ -1,6 +0,0 @@ -%w( - .ruby-version - .rbenv-vars - tmp/restart.txt - tmp/caching-dev.txt -).each { |path| Spring.watch(path) } diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000..4942ab6 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20171203155057_create_bixos_modalidades_table.rb b/db/migrate/20171203155057_create_bixos_modalidades_table.rb deleted file mode 100644 index 936e253..0000000 --- a/db/migrate/20171203155057_create_bixos_modalidades_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateBixosModalidadesTable < ActiveRecord::Migration[5.1] - def change - create_table :bixos_modalidades, id: false do |t| - t.belongs_to :bixo, index: true - t.belongs_to :modalidade, index: true - end - end -end diff --git a/db/migrate/20180205160823_create_vendas.rb b/db/migrate/20180205160823_create_vendas.rb deleted file mode 100644 index dfc0780..0000000 --- a/db/migrate/20180205160823_create_vendas.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateVendas < ActiveRecord::Migration[5.1] - def change - create_table :vendas do |t| - t.string :tamanho, default: "M", null: false - t.string :cor, default: "Vermelha", null: false - t.belongs_to :bixo, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20180208165302_create_pagamentos.rb b/db/migrate/20180208165302_create_pagamentos.rb deleted file mode 100644 index 3782066..0000000 --- a/db/migrate/20180208165302_create_pagamentos.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreatePagamentos < ActiveRecord::Migration[5.1] - def change - create_table :pagamentos do |t| - t.decimal :valor - t.belongs_to :venda, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20180208185214_create_veteranos.rb b/db/migrate/20180208185214_create_veteranos.rb deleted file mode 100644 index 90abf3b..0000000 --- a/db/migrate/20180208185214_create_veteranos.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateVeteranos < ActiveRecord::Migration[5.1] - def change - create_table :veteranos do |t| - t.string :nome - - t.timestamps - end - end -end diff --git a/db/migrate/20180208185534_add_veterano_column_to_pagamentos.rb b/db/migrate/20180208185534_add_veterano_column_to_pagamentos.rb deleted file mode 100644 index 56f1aed..0000000 --- a/db/migrate/20180208185534_add_veterano_column_to_pagamentos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddVeteranoColumnToPagamentos < ActiveRecord::Migration[5.1] - def change - add_reference :pagamentos, :veterano, foreign_key: true - end -end diff --git a/db/migrate/20180210141332_drop_columns_from_vendas.rb b/db/migrate/20180210141332_drop_columns_from_vendas.rb deleted file mode 100644 index ffe8022..0000000 --- a/db/migrate/20180210141332_drop_columns_from_vendas.rb +++ /dev/null @@ -1,6 +0,0 @@ -class DropColumnsFromVendas < ActiveRecord::Migration[5.1] - def change - remove_column :vendas, :cor - remove_column :vendas, :tamanho - end -end diff --git a/db/migrate/20180210141445_create_cor_and_tamanho_columns_as_int.rb b/db/migrate/20180210141445_create_cor_and_tamanho_columns_as_int.rb deleted file mode 100644 index 58e0c36..0000000 --- a/db/migrate/20180210141445_create_cor_and_tamanho_columns_as_int.rb +++ /dev/null @@ -1,6 +0,0 @@ -class CreateCorAndTamanhoColumnsAsInt < ActiveRecord::Migration[5.1] - def change - add_column :vendas, :cor, :integer - add_column :vendas, :tamanho, :integer - end -end diff --git a/db/migrate/20180215102940_add_caneca_column_to_bixo.rb b/db/migrate/20180215102940_add_caneca_column_to_bixo.rb deleted file mode 100644 index ab7fe90..0000000 --- a/db/migrate/20180215102940_add_caneca_column_to_bixo.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCanecaColumnToBixo < ActiveRecord::Migration[5.1] - def change - add_column :bixos, :caneca, :boolean, default: false - end -end diff --git a/db/migrate/20180215104914_add_caneca_to_venda.rb b/db/migrate/20180215104914_add_caneca_to_venda.rb deleted file mode 100644 index e1a84a6..0000000 --- a/db/migrate/20180215104914_add_caneca_to_venda.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCanecaToVenda < ActiveRecord::Migration[5.1] - def change - remove_column :bixos, :caneca - add_column :vendas, :caneca, :boolean - end -end diff --git a/db/migrate/20190214185449_add_tutorship_column_to_bixos.rb b/db/migrate/20190214185449_add_tutorship_column_to_bixos.rb deleted file mode 100644 index 73d24cc..0000000 --- a/db/migrate/20190214185449_add_tutorship_column_to_bixos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTutorshipColumnToBixos < ActiveRecord::Migration[5.1] - def change - add_column :bixos, :tutorship, :boolean, default: false - end -end diff --git a/db/migrate/20190214193750_create_confirmations.rb b/db/migrate/20190214193750_create_confirmations.rb deleted file mode 100644 index 5d27e81..0000000 --- a/db/migrate/20190214193750_create_confirmations.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateConfirmations < ActiveRecord::Migration[5.1] - def change - create_table :confirmations do |t| - t.references :bixo, foreign_key: true - - t.timestamps - end - end -end diff --git a/db/migrate/20171005172531_create_bixos.rb b/db/migrate/20220313221143_create_bixes.rb similarity index 63% rename from db/migrate/20171005172531_create_bixos.rb rename to db/migrate/20220313221143_create_bixes.rb index 8cd61b8..51abc80 100644 --- a/db/migrate/20171005172531_create_bixos.rb +++ b/db/migrate/20220313221143_create_bixes.rb @@ -1,6 +1,6 @@ -class CreateBixos < ActiveRecord::Migration[5.1] +class CreateBixes < ActiveRecord::Migration[7.0] def change - create_table :bixos do |t| + create_table :bixes do |t| t.string :nome t.string :email t.string :telefone diff --git a/db/migrate/20171202232819_create_modalidades.rb b/db/migrate/20220313221313_create_modalidades.rb similarity index 66% rename from db/migrate/20171202232819_create_modalidades.rb rename to db/migrate/20220313221313_create_modalidades.rb index ca2e2b1..1c51dba 100644 --- a/db/migrate/20171202232819_create_modalidades.rb +++ b/db/migrate/20220313221313_create_modalidades.rb @@ -1,4 +1,4 @@ -class CreateModalidades < ActiveRecord::Migration[5.1] +class CreateModalidades < ActiveRecord::Migration[7.0] def change create_table :modalidades do |t| t.string :nome diff --git a/db/migrate/20220313221535_create_confirmacoes.rb b/db/migrate/20220313221535_create_confirmacoes.rb new file mode 100644 index 0000000..573caa5 --- /dev/null +++ b/db/migrate/20220313221535_create_confirmacoes.rb @@ -0,0 +1,9 @@ +class CreateConfirmacoes < ActiveRecord::Migration[7.0] + def change + create_table :confirmacoes do |t| + t.references :bixe, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20220314002825_create_bixes_modalidades_table.rb b/db/migrate/20220314002825_create_bixes_modalidades_table.rb new file mode 100644 index 0000000..49420c0 --- /dev/null +++ b/db/migrate/20220314002825_create_bixes_modalidades_table.rb @@ -0,0 +1,10 @@ +class CreateBixesModalidadesTable < ActiveRecord::Migration[7.0] + def change + create_table :bixes_modalidades do |t| + t.references :bixe, null: false, foreign_key: true, index: true + t.references :modalidade, null: false, foreign_key: true, index: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 7058796..da47878 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,75 +2,50 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190214193750) do - +ActiveRecord::Schema[7.0].define(version: 2022_03_14_002825) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "bixos", force: :cascade do |t| + create_table "bixes", force: :cascade do |t| t.string "nome" t.string "email" t.string "telefone" t.integer "curso" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "tutorship", default: false - end - - create_table "bixos_modalidades", id: false, force: :cascade do |t| - t.bigint "bixo_id" - t.bigint "modalidade_id" - t.index ["bixo_id"], name: "index_bixos_modalidades_on_bixo_id" - t.index ["modalidade_id"], name: "index_bixos_modalidades_on_modalidade_id" - end - - create_table "confirmations", force: :cascade do |t| - t.bigint "bixo_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["bixo_id"], name: "index_confirmations_on_bixo_id" end - create_table "modalidades", force: :cascade do |t| - t.string "nome" + create_table "bixes_modalidades", force: :cascade do |t| + t.bigint "bixe_id", null: false + t.bigint "modalidade_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["bixe_id"], name: "index_bixes_modalidades_on_bixe_id" + t.index ["modalidade_id"], name: "index_bixes_modalidades_on_modalidade_id" end - create_table "pagamentos", force: :cascade do |t| - t.decimal "valor" - t.bigint "venda_id" + create_table "confirmacoes", force: :cascade do |t| + t.bigint "bixe_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.bigint "veterano_id" - t.index ["venda_id"], name: "index_pagamentos_on_venda_id" - t.index ["veterano_id"], name: "index_pagamentos_on_veterano_id" + t.index ["bixe_id"], name: "index_confirmacoes_on_bixe_id" end - create_table "vendas", force: :cascade do |t| - t.bigint "bixo_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "cor" - t.integer "tamanho" - t.boolean "caneca" - t.index ["bixo_id"], name: "index_vendas_on_bixo_id" - end - - create_table "veteranos", force: :cascade do |t| + create_table "modalidades", force: :cascade do |t| t.string "nome" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - add_foreign_key "confirmations", "bixos" - add_foreign_key "pagamentos", "veteranos" + add_foreign_key "bixes_modalidades", "bixes" + add_foreign_key "bixes_modalidades", "modalidades" + add_foreign_key "confirmacoes", "bixes" end diff --git a/db/seeds.rb b/db/seeds.rb index b900844..bc25fce 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,9 +1,7 @@ # This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # # Examples: # -# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) -# Character.create(name: 'Luke', movie: movies.first) - -Veterano.create(nome: 'Wil') +# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) +# Character.create(name: "Luke", movie: movies.first) diff --git a/db/test.sqlite3 b/db/test.sqlite3 deleted file mode 100644 index 0a85486e8940ed1e61d51847f462474c9adae25e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeHNPjlNu6xV8PD^8nKE$L_i!$eUAsHP3EWGivX46OlA8=5$6nsmr8;8E>uqQRC^ zTS>#vi<3LOF#P}=_yP<}&zw38rye)}pP@6oaLI*TNw%ff32FYgraVpTtbR|s@9ppH z+gH8lZ(p{kHn|9it1UUz-`_twmlK^J2{j4B>S1H9JC!pp3lijTWgG%mU^mBQR_nyLApf^HU7;|)>%QtKM@5KwC%JfJk^Sw8>e|8;#4B?T{71oE#>jAy9AfG3nw( zwCpOc-7nFkcD_dLuM@jKcHQET;$6ZEwpk{ZXic?VK!PMmX#1U3hg>81P<_v3$1;9N z*|bW*0qu|yxmU5ngM7VOt0;|rA9>Wn`v3BC9n=5@UKa)i@Q3vH?*Yf(M!%zZ?g4&` zzwJWb>P!8CG(3#9qweIoLF}Sg^S%ed)2jy_YJTmodK_tsz$V*DH8}S=X4$k?Thp;x zkHiJ(#we<*fwg(fT%n7K?a-YB-92m&hg40QEzB*!X}{B1Tdr?gX0}T4u#a1UL-~2bEHSqf zNx>?cCF&)2%&@)EaV?W>n@zVhn^kF~{L+PJIYAY0{&#}pLes!Nk23)A-{TGf^MHX9 zWB`8upCGx=G%(QP48Z!|;|>DzfPoWa0M`E#Bo~?n26~)<0sa}y|L<`4G5-gDo`1yc zpx=7jn>?2Yi*b*D$zDfU<7>t-sq z`4U3#y#{usY?ju;$=xHp!EjBCNuL{ta}WLfytcXSRNVV~CqwgECv<3Yz)R(ixWv>7 zt28s6FIy{B)3GXctqnLErld{o7W|{oLnXuJO{7^ZF<9!!p^^_oeFpTQ)K>o%{gt1JJpV#t$LBAKF z%u(C3UdG0QS^pZTF_o?Var`BRpX0yqulNc60e^?L@EV2S0tSGABQYSxc~wtnQ<|Pg zYKD<8ro=uMNhfqIp{2BBQWu2=l1OW5L)TJbEPzZJ$%HOO14!C1k|{CLL=0^*k=BzU zb`hpa*OPi$n-+N=NhAzyN;i_4h#IwA?WvT(e*eeu9S;AApW-|CC;SLM#NT5JKR;5( zp)xS=KW5+@R#7 + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..c19f78a --- /dev/null +++ b/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb deleted file mode 100644 index 4a1a0cf..0000000 --- a/spec/controllers/confirmations_controller_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -RSpec.describe ConfirmationsController, type: :controller do - describe '#create' do - before do - request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('comissao', 'bixoamigonaocomida') - end - - context 'when the given bixo exists' do - let(:bixo) { FactoryBot.create(:bixo) } - - it 'creates a confirmation for the given bixo' do - expect { post :create, params: { id: bixo.id } }.to change { Confirmation.count }.by(1) - end - it 'sets a success flash message' do - post :create, params: { id: bixo.id } - - expect(flash[:notice]).not_to be_blank - expect(flash[:alert]).to be_blank - end - end - - context 'when the given bixo is nowhere to be found' do - it 'creates nothing' do - expect { post :create, params: { id: 1 } }.not_to change { Confirmation.count } - end - - it 'sets a success flash message' do - post :create, params: { id: 1 } - - expect(flash[:notice]).to be_blank - expect(flash[:alert]).not_to be_blank - end - end - end -end diff --git a/spec/factories/bixes.rb b/spec/factories/bixes.rb new file mode 100644 index 0000000..7d50e3e --- /dev/null +++ b/spec/factories/bixes.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :bixe do + nome { "MyString" } + email { "MyString" } + telefone { "MyString" } + curso { 1 } + end +end diff --git a/spec/factories/bixo_factories.rb b/spec/factories/bixo_factories.rb deleted file mode 100644 index fb6f863..0000000 --- a/spec/factories/bixo_factories.rb +++ /dev/null @@ -1,9 +0,0 @@ -FactoryBot.define do - factory :bixo do - nome { 'Erick Cordeiro Ozaki' } - email { 'erick.ozaki@usp.br' } - telefone { '11111111111' } - curso { Bixo.cursos[:LIC] } - tutorship { true } - end -end diff --git a/spec/factories/confirmacaos.rb b/spec/factories/confirmacaos.rb new file mode 100644 index 0000000..fe0e8b2 --- /dev/null +++ b/spec/factories/confirmacaos.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :confirmacao do + bixe { nil } + end +end diff --git a/spec/factories/confirmation_factories.rb b/spec/factories/confirmation_factories.rb deleted file mode 100644 index 650a02b..0000000 --- a/spec/factories/confirmation_factories.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryBot.define do - factory :confirmation do - association :bixo, factory: :bixo - end -end diff --git a/spec/factories/modalidades.rb b/spec/factories/modalidades.rb new file mode 100644 index 0000000..c73349e --- /dev/null +++ b/spec/factories/modalidades.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :modalidade do + name { "MyString" } + end +end diff --git a/spec/helpers/bixes_helper_spec.rb b/spec/helpers/bixes_helper_spec.rb new file mode 100644 index 0000000..e0698c8 --- /dev/null +++ b/spec/helpers/bixes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the BixesHelper. For example: +# +# describe BixesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe BixesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/confirmacoes_helper_spec.rb b/spec/helpers/confirmacoes_helper_spec.rb new file mode 100644 index 0000000..7ad7015 --- /dev/null +++ b/spec/helpers/confirmacoes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ConfirmacoesHelper. For example: +# +# describe ConfirmacoesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ConfirmacoesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/modalidades_helper_spec.rb b/spec/helpers/modalidades_helper_spec.rb new file mode 100644 index 0000000..8b44c1e --- /dev/null +++ b/spec/helpers/modalidades_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ModalidadesHelper. For example: +# +# describe ModalidadesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ModalidadesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/bixe_spec.rb b/spec/models/bixe_spec.rb new file mode 100644 index 0000000..afae1fb --- /dev/null +++ b/spec/models/bixe_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Bixe, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/bixo_spec.rb b/spec/models/bixo_spec.rb deleted file mode 100644 index 9a5a819..0000000 --- a/spec/models/bixo_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe Bixo do - it { should validate_presence_of(:nome) } - it { should validate_presence_of(:telefone) } - it { should validate_presence_of(:email) } - it { should validate_presence_of(:curso) } - it { should have_one(:confirmation) } - - describe '#confirmed?' do - let(:bixo) { create(:bixo) } - context 'when a confirmation for given bixo exists' do - before { create(:confirmation, bixo: bixo) } - - it 'returns true' do - expect(bixo.confirmed?).to be true - end - end - - context 'when a confirmation for given bixo does not exist' do - it 'returns false' do - expect(bixo.confirmed?).to be false - end - end - end -end diff --git a/spec/models/confirmacao_spec.rb b/spec/models/confirmacao_spec.rb new file mode 100644 index 0000000..9961456 --- /dev/null +++ b/spec/models/confirmacao_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Confirmacao, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/confirmation_spec.rb b/spec/models/confirmation_spec.rb deleted file mode 100644 index 4085cbf..0000000 --- a/spec/models/confirmation_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Confirmation, type: :model do - it { should belong_to(:bixo) } -end diff --git a/spec/models/modalidade_spec.rb b/spec/models/modalidade_spec.rb index 847ff23..d348b17 100644 --- a/spec/models/modalidade_spec.rb +++ b/spec/models/modalidade_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' RSpec.describe Modalidade, type: :model do - it { should validate_presence_of(:nome) } + pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/pagamento_spec.rb b/spec/models/pagamento_spec.rb deleted file mode 100644 index 4ae0b44..0000000 --- a/spec/models/pagamento_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Pagamento, type: :model do - it { should validate_presence_of(:valor) } -end diff --git a/spec/models/venda_spec.rb b/spec/models/venda_spec.rb deleted file mode 100644 index 7050c3b..0000000 --- a/spec/models/venda_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -RSpec.describe Venda, type: :model do - context `on update` do - let(:venda) { Venda.create(bixo_id: 1) } - - it 'should contain errors and not save' do - expect(venda.update(tamanho: nil, cor: 1)).to be_falsey - expect(venda.errors).not_to be_nil - end - - it 'should contain errors and not save' do - expect(venda.update(cor: nil, tamanho: 1)).to be_falsey - expect(venda.errors).not_to be_nil - end - end -end diff --git a/spec/models/veterano_spec.rb b/spec/models/veterano_spec.rb deleted file mode 100644 index 8d70714..0000000 --- a/spec/models/veterano_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Veterano, type: :model do - it { should validate_presence_of(:nome) } -end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb deleted file mode 100644 index 13de769..0000000 --- a/spec/rails_helper.rb +++ /dev/null @@ -1,63 +0,0 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -require 'spec_helper' -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) -# Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? -require 'rspec/rails' -require 'shoulda-matchers' -# Add additional requires below this line. Rails is not loaded until this point! - -# Requires supporting ruby files with custom matchers and macros, etc, in -# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are -# run as spec files by default. This means that files in spec/support that end -# in _spec.rb will both be required and run as specs, causing the specs to be -# run twice. It is recommended that you do not name files matching this glob to -# end with _spec.rb. You can configure this pattern with the --pattern -# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. -# -# The following line is provided for convenience purposes. It has the downside -# of increasing the boot-up time by auto-requiring all files in the support -# directory. Alternatively, in the individual `*_spec.rb` files, manually -# require only the support files necessary. -# -# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } - -# Checks for pending migration and applies them before tests are run. -# If you are not using ActiveRecord, you can remove this line. -ActiveRecord::Migration.maintain_test_schema! - -RSpec.configure do |config| - config.include(Shoulda::Matchers::ActiveModel, type: :model) - config.include(Shoulda::Matchers::ActiveRecord, type: :model) - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, :type => :controller do - # # ... - # end - # - # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! - - # Filter lines from Rails gems in backtraces. - config.filter_rails_from_backtrace! - # arbitrary gems may also be filtered via: - # config.filter_gems_from_backtrace("gem name") - - # Configures RSpec to know and use FactoryBot methods - config.include FactoryBot::Syntax::Methods -end diff --git a/spec/requests/bixes_spec.rb b/spec/requests/bixes_spec.rb new file mode 100644 index 0000000..9c374ea --- /dev/null +++ b/spec/requests/bixes_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Bixes", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end diff --git a/spec/requests/confirmacoes_spec.rb b/spec/requests/confirmacoes_spec.rb new file mode 100644 index 0000000..b376831 --- /dev/null +++ b/spec/requests/confirmacoes_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Confirmacoes", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end diff --git a/spec/requests/modalidades_spec.rb b/spec/requests/modalidades_spec.rb new file mode 100644 index 0000000..4d945c7 --- /dev/null +++ b/spec/requests/modalidades_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Modalidades", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index ce33d66..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,96 +0,0 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end -end diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb new file mode 100644 index 0000000..800405f --- /dev/null +++ b/test/channels/application_cable/connection_test.rb @@ -0,0 +1,11 @@ +require "test_helper" + +class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end +end diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/system/.keep b/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..d713e37 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +class ActiveSupport::TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tmp/pids/.keep b/tmp/pids/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tmp/storage/.keep b/tmp/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000..e69de29 From ca18ab6b038a1b27a258fa1410069b203020fbb6 Mon Sep 17 00:00:00 2001 From: Thiago Guerrero Date: Sun, 13 Mar 2022 23:00:36 -0300 Subject: [PATCH 02/20] hotfix: Remove .env file Signed-off-by: Thiago Guerrero --- .env | 5 ----- .gitignore | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 312a09f..0000000 --- a/.env +++ /dev/null @@ -1,5 +0,0 @@ -POSTGRES_USER=development -POSTGRES_PASSWORD=development -POSTGRES_HOST=postgres -ADMIN_USER=admin -ADMIN_PASSWORD=admin \ No newline at end of file diff --git a/.gitignore b/.gitignore index 886f714..4647e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' +.env # Ignore bundler config. /.bundle From be88d564a3a207931b6ac6e4e0b66a7b39af37d6 Mon Sep 17 00:00:00 2001 From: Thiago Guerrero Date: Sun, 13 Mar 2022 23:08:33 -0300 Subject: [PATCH 03/20] hotfix: add env vars to db name Signed-off-by: Thiago Guerrero --- .env.sample | 1 + config/database.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.env.sample b/.env.sample index a537b0e..2dfc1d6 100644 --- a/.env.sample +++ b/.env.sample @@ -1,5 +1,6 @@ POSTGRES_USER= POSTGRES_PASSWORD= +POSTGRES_HOST=postgres POSTGRES_DB=development ADMIN_USER= ADMIN_PASSWORD= \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index a6e6b34..8b8c6b9 100644 --- a/config/database.yml +++ b/config/database.yml @@ -14,7 +14,7 @@ default: &default development: <<: *default - database: development + database: <%= ENV['POSTGRES_DB'] %> # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". @@ -25,4 +25,4 @@ test: production: <<: *default - database: production + database: <%= ENV['POSTGRES_DB'] %> From 3d92e4ba8f86ac729aebfdd80cb1292436a5b773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Comiss=C3=A3o=20de=20Recep=C3=A7=C3=A3o=20IME-USP?= <74839089+comissaoimeusp@users.noreply.github.com> Date: Mon, 14 Mar 2022 08:19:14 -0300 Subject: [PATCH 04/20] *hotfix: adicionar cores amarelo e azul --- app/assets/stylesheets/application.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index b01f164..9ad31f3 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -82,6 +82,14 @@ h4 { } } +.team-blue { + background: lightskyblue; +} + +.team-yellow { + background: yellow; +} + .btn { color: #fff !important; } From b551584e0bf48a6df4791c3f330916664e5b19d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Comiss=C3=A3o=20de=20Recep=C3=A7=C3=A3o=20IME-USP?= <74839089+comissaoimeusp@users.noreply.github.com> Date: Mon, 21 Mar 2022 22:51:19 -0300 Subject: [PATCH 05/20] =?UTF-8?q?*hotfix:=20corrigir=20erro=20da=20vari?= =?UTF-8?q?=C3=A1vel=20bixe=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Essa correção possibilita a visualização dos bixes com interesse em uma dada modalidade, assim como seus respectivos contatos. --- app/views/modalidades/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/modalidades/show.html.erb b/app/views/modalidades/show.html.erb index ea718c4..9bcf4cd 100644 --- a/app/views/modalidades/show.html.erb +++ b/app/views/modalidades/show.html.erb @@ -21,7 +21,7 @@
<% @modalidade.bixes.each_with_index do |b, i| %>
- <%= link_to bixo_path(b.id) do %> + <%= link_to bixe_path(b.id) do %>

<%= b.nome %> @@ -36,4 +36,4 @@ <% end %>
<% end %> -

\ No newline at end of file +
From baea56da96f2d3f4c3a81e1ca838a187ec611cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Wed, 8 Mar 2023 05:48:48 -0300 Subject: [PATCH 06/20] =?UTF-8?q?Adiciona=20compatibilidade=20com=20vers?= =?UTF-8?q?=C3=B5es=20ARM=20do=20container?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a2f6d4..4607d70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV PORT=3000 \ WORKDIR ${APP_PATH} RUN apk add --update \ - build-base git bash tzdata postgresql-dev && \ + build-base git bash tzdata postgresql-dev gcompat && \ gem install rails COPY . ./ From cb6d0300a395183795b636d479a2f933d9c02681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Wed, 8 Mar 2023 05:49:11 -0300 Subject: [PATCH 07/20] Modifica cores das equipes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/assets/stylesheets/application.scss | 26 ++++++++++--------------- app/models/confirmacao.rb | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 9ad31f3..7fa88ae 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -62,32 +62,26 @@ h4 { padding-left: 5%; } -.team-orange { - background: orange; -} +// Team colors -.team-gray { - background: lightgray; +.team-purple { + background: #c185e4; } -.team-pink { - background: hotpink; +.team-orange { + background: #eb963c; } -.team-black { - background: black; - - a { - color: #fff !important; - } +.team-green { + background: #a8bd56; } .team-blue { - background: lightskyblue; + background: #20b1ba; } -.team-yellow { - background: yellow; +.team-gold { + background: #ffd700; } .btn { diff --git a/app/models/confirmacao.rb b/app/models/confirmacao.rb index 1d5f170..431956f 100644 --- a/app/models/confirmacao.rb +++ b/app/models/confirmacao.rb @@ -1,7 +1,7 @@ class Confirmacao < ApplicationRecord belongs_to :bixe - COLORS = [:YELLOW, :BLUE, :ORANGE, :GRAY, :PINK, :BLACK].freeze + COLORS = [:PURPLE, :ORANGE, :GREEN, :BLUE, :GOLD].freeze def team_color From 45b97ef87f74984566fe1db8a0c97d78f52ddd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Wed, 8 Mar 2023 22:26:58 -0300 Subject: [PATCH 08/20] Adiciona gerenciamento de produtos comprados MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/controllers/bixes_controller.rb | 34 +++++++- app/controllers/items_controller.rb | 85 +++++++++++++++++++ app/helpers/application_helper.rb | 4 + app/models/bixe.rb | 1 + app/models/item.rb | 5 ++ app/views/bixes/items.html.erb | 24 ++++++ app/views/bixes/show.html.erb | 17 +++- app/views/items/_form.html.erb | 37 ++++++++ app/views/items/contatos.html.erb | 23 +++++ app/views/items/edit.html.erb | 3 + app/views/items/index.html.erb | 27 ++++++ app/views/items/new.html.erb | 3 + app/views/items/planilha.html.erb | 25 ++++++ app/views/items/show.html.erb | 39 +++++++++ app/views/layouts/application.html.erb | 3 + config/routes.rb | 7 ++ db/migrate/20230308204741_items.rb | 10 +++ ...20230308205332_create_bixes_items_table.rb | 10 +++ db/schema.rb | 20 ++++- 19 files changed, 373 insertions(+), 4 deletions(-) create mode 100644 app/controllers/items_controller.rb create mode 100644 app/models/item.rb create mode 100644 app/views/bixes/items.html.erb create mode 100644 app/views/items/_form.html.erb create mode 100644 app/views/items/contatos.html.erb create mode 100644 app/views/items/edit.html.erb create mode 100644 app/views/items/index.html.erb create mode 100644 app/views/items/new.html.erb create mode 100644 app/views/items/planilha.html.erb create mode 100644 app/views/items/show.html.erb create mode 100644 db/migrate/20230308204741_items.rb create mode 100644 db/migrate/20230308205332_create_bixes_items_table.rb diff --git a/app/controllers/bixes_controller.rb b/app/controllers/bixes_controller.rb index 905ba3e..38b024b 100644 --- a/app/controllers/bixes_controller.rb +++ b/app/controllers/bixes_controller.rb @@ -1,6 +1,6 @@ class BixesController < ApplicationController before_action :set_bixe, only: [:show, :edit, :update, :destroy, :modalidades, - :modify_modalidades] + :modify_modalidades, :items, :modify_items] http_basic_authenticate_with name: ENV['ADMIN_USER'], password: ENV['ADMIN_PASSWORD'], only: [:emails] @@ -38,6 +38,14 @@ def modalidades end end + # GET /bixos/1/items + def items + @check = {} + @bixe.items.each do |i| + @check[i.id] = true + end + end + # GET /bixos/contatos def contatos @bixes = Bixe.all @@ -57,6 +65,20 @@ def modify_modalidades end end + # POST /bixos/1/items + def modify_items + @bixe.items = items_params.to_hash.map { |k,v| Item.find(k) } + respond_to do |format| + if @bixe.save + format.html { redirect_to @bixe, notice: 'Itens modificados com sucesso!' } + format.json { render :show, status: :created, location: @bixe } + else + format.html { flash[:error] = 'Deu caca em alguma coisa'; render :new } + format.json { render json: @bixe.errors, status: :unprocessable_entity } + end + end + end + # POST /bixos # POST /bixos.json def create @@ -116,4 +138,12 @@ def modalidades_params params.require(:modalidades).permit! end end -end \ No newline at end of file + + def items_params + if params[:items].nil? or params[:items].empty? + params[:items] = {} + else + params.require(:items).permit! + end + end +end diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb new file mode 100644 index 0000000..93307b9 --- /dev/null +++ b/app/controllers/items_controller.rb @@ -0,0 +1,85 @@ +class ItemsController < ApplicationController + before_action :set_item, only: [:show, :edit, :update, :destroy] + http_basic_authenticate_with name: ENV['ADMIN_USER'], password: ENV['ADMIN_PASSWORD'] + + # GET /items + # GET /items.json + def index + @items = Item.all + end + + # GET /items/1 + # GET /items/1.json + def show + end + + # GET /items/contatos + def contatos + @items = Item.all + end + + # GET /items/planilha + def planilha + @items = Item.all + end + + # GET /items/new + def new + @item = Item.new + end + + # GET /items/1/edit + def edit + end + + # POST /items + # POST /items.json + def create + @item = Item.new(item_params) + + respond_to do |format| + if @item.save + format.html { redirect_to @item, notice: 'O produto foi adicionado com sucesso!' } + format.json { render :show, status: :created, location: @item } + else + format.html { render :new } + format.json { render json: @item.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /items/1 + # PATCH/PUT /items/1.json + def update + respond_to do |format| + if @item.update(item_params) + format.html { redirect_to @item, notice: 'O produto foi atualizado com sucesso.' } + format.json { render :show, status: :ok, location: @item } + else + format.html { render :edit } + format.json { render json: @item.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /items/1 + # DELETE /items/1.json + def destroy + @item.destroy + respond_to do |format| + format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_item + @item = Item.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def item_params + params.require(:item).permit(:nome, :preco) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5115575..de50530 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -24,4 +24,8 @@ def confirmacoes_index? def modalidades_index? params[:controller] == "modalidades" and params[:action] == "index" end + + def items_index? + params[:controller] == "items" and params[:action] == "index" + end end diff --git a/app/models/bixe.rb b/app/models/bixe.rb index f091cbd..caa493a 100644 --- a/app/models/bixe.rb +++ b/app/models/bixe.rb @@ -5,6 +5,7 @@ class Bixe < ApplicationRecord validates :curso, presence: true has_and_belongs_to_many :modalidades + has_and_belongs_to_many :items has_one :confirmacao enum curso: [:LIC, :PURA, :BCC, :ESTAT, :APLICADA, :BMAC, :LICNOTURNO].freeze diff --git a/app/models/item.rb b/app/models/item.rb new file mode 100644 index 0000000..001e2c5 --- /dev/null +++ b/app/models/item.rb @@ -0,0 +1,5 @@ +class Item < ApplicationRecord + validates :nome, presence: true, uniqueness: true + validates :preco, presence: true + has_and_belongs_to_many :bixes +end diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb new file mode 100644 index 0000000..5591857 --- /dev/null +++ b/app/views/bixes/items.html.erb @@ -0,0 +1,24 @@ +

Mudar compras de <%= @bixe.nome %>

+ +<%= form_tag do %> + <% Item.all.each do |it| %> +
+ <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true) %> + <%= label_tag("items[#{it.id}]", it.nome) %> +
+ <% end %> + +
+
+
+ <%= link_to 'Voltar', @bixe, class: 'btn btn-danger btn-lg btn-wide' %> +
+
+ +
+
+ <%= submit_tag 'Confirmar', class: 'btn btn-success btn-lg' %> +
+
+
+<% end %> diff --git a/app/views/bixes/show.html.erb b/app/views/bixes/show.html.erb index 6f8aa04..1cd1934 100644 --- a/app/views/bixes/show.html.erb +++ b/app/views/bixes/show.html.erb @@ -49,8 +49,23 @@ <%= link_to 'Mudar modalidades', edit_bixe_modalidades_path(@bixe), class: 'btn btn-success btn-lg' %> +
+

Produtos

+ <% if @bixe.items.empty? %> +

Nenhum

+ <% else %> + <% @bixe.items.each do |it| %> +

+ <%= it.nome %> +

+ <% end %> + <% end %> +
+ <%= link_to 'Modificar compras', edit_bixe_items_path(@bixe), class: 'btn btn-success btn-lg' %> +
+
<%= link_to 'Voltar à lista', bixes_path, class: 'btn btn-danger btn-lg' %> -
\ No newline at end of file + diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb new file mode 100644 index 0000000..55851f8 --- /dev/null +++ b/app/views/items/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: item, local: true) do |form| %> + <% if item.errors.any? %> +
+

<%= pluralize(item.errors.count, "error") %> erro(s) impediram a operação:

+ +
    + <% item.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :nome, 'Nome' %> + <%= form.text_field :nome, id: :item_nome %> +
+ +
+ <%= form.label :preco, 'Preço' %> + <%= form.text_field :preco, id: :item_preco %> +
+ +
+
+
+ <%= link_to 'Voltar à lista', items_path, class: 'btn btn-danger btn-lg btn-wide' %> +
+
+ +
+
+ <%= form.submit (form.object.new_record? ? 'Inserir' : 'Editar'), class: 'btn btn-success btn-lg' %> +
+
+
+<% end %> diff --git a/app/views/items/contatos.html.erb b/app/views/items/contatos.html.erb new file mode 100644 index 0000000..00b00ff --- /dev/null +++ b/app/views/items/contatos.html.erb @@ -0,0 +1,23 @@ +

Contatos por produto

+ +

E-mails

+ +
+<% @items.each do |i| %>
+# <%= i.nome %>
+<% i.bixes.each do |b| %>
+<%= b.email %>
+<% end %>
+<% end %>
+
+ +

Telefones

+ +
+<% @items.each do |i| %>
+# <%= i.nome %>
+<% i.bixes.each do |b| %>
+<%= b.telefone %> <%= b.nome %>
+<% end %>
+<% end %>
+
diff --git a/app/views/items/edit.html.erb b/app/views/items/edit.html.erb new file mode 100644 index 0000000..5cc2fa9 --- /dev/null +++ b/app/views/items/edit.html.erb @@ -0,0 +1,3 @@ +

Modificação de Produto - <%= @item.nome %>

+ +<%= render 'form', item: @item %> diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb new file mode 100644 index 0000000..abedbc7 --- /dev/null +++ b/app/views/items/index.html.erb @@ -0,0 +1,27 @@ +

Produtos

+ +
+
+ <%= link_to 'Novo Produto', new_item_path, class: 'btn btn-success btn-lg' %> +
+
+ +
+ <% @items.each_with_index do |p, i| %> +
+ <%= link_to item_path(p.id) do %> +

+
+ <%= p.nome %> +
+

+ <% end %> +
+ <% end %> +
+ +
+
+ <%= link_to 'Planilha', planilha_items_path, class: 'btn btn-primary btn-lg' %> +
+
diff --git a/app/views/items/new.html.erb b/app/views/items/new.html.erb new file mode 100644 index 0000000..8ef9f23 --- /dev/null +++ b/app/views/items/new.html.erb @@ -0,0 +1,3 @@ +

Novo Produto

+ +<%= render 'form', item: @item %> diff --git a/app/views/items/planilha.html.erb b/app/views/items/planilha.html.erb new file mode 100644 index 0000000..47812cc --- /dev/null +++ b/app/views/items/planilha.html.erb @@ -0,0 +1,25 @@ +

Planilha em CSV dos produtos

+ +

Relação bixe-produto

+
+produto,bixe,telefone,email
+<% @items.each do |i| %>
+<% i.bixes.each do |b| %>
+<%= i.nome %>,<%= b.nome %>,<%= b.telefone %>,<%= b.email %>
+<% end %>
+<% end %>
+
+ +

Relação produto-preço

+
+produto,preço
+<% @items.each do |i| %>
+<%= i.nome %>,<%= i.preco %>
+<% end %>
+
+ +
+
+ <%= link_to 'Voltar', items_path, class: 'btn btn-danger btn-lg' %> +
+
diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb new file mode 100644 index 0000000..e7b9744 --- /dev/null +++ b/app/views/items/show.html.erb @@ -0,0 +1,39 @@ +

<%= notice %>

+ +

<%= @item.nome %>

+ +
+
+
+ <%= link_to 'Voltar à lista', items_path, class: 'btn btn-danger btn-lg' %> +
+
+ +
+
+ <%= link_to 'Editar', edit_item_path(@item), class: 'btn btn-success btn-lg' %> +
+
+
+ +

Bixes que compraram o produto

+ +
+ <% @item.bixes.each_with_index do |b, i| %> +
+ <%= link_to bixe_path(b.id) do %> +

+
+ <%= b.nome %> +
+
+ <%= b.email %> +
+
+ <%= b.telefone %> +
+

+ <% end %> +
+ <% end %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0c7f7e5..7bd6e18 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,6 +28,9 @@ <% if modalidades_index? %>
  • <% else %>
  • <% end %> <%= link_to 'modalidades', modalidades_path %>
  • + <% if items_index? %>
  • <% else %>
  • <% end %> + <%= link_to 'produtos', items_path %> +
  • <% if confirmacoes_index? %>
  • <% else %>
  • <% end %> <%= link_to 'confirmações', confirmacoes_path %>
  • diff --git a/config/routes.rb b/config/routes.rb index b4ab8af..336ecba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,9 +13,16 @@ get '/bixes/contatos' => 'bixes#contatos', as: :contatos get '/bixes/:id/modalidades' => 'bixes#modalidades', as: :edit_bixe_modalidades + get '/bixes/:id/items' => 'bixes#items', as: :edit_bixe_items post '/bixes/:id/modalidades' => 'bixes#modify_modalidades', as: :modify_bixe_modalidades + post '/bixes/:id/items' => 'bixes#modify_items', as: :modify_bixe_items get '/modalidades/contatos' => 'modalidades#contatos', as: :contato_modalidades + + get '/items/:id/bixes' => 'items#bixes', as: :edit_item_bixes + get '/items/contatos' => 'items#contatos', as: :contato_items + get '/items/planilha' => 'items#planilha', as: :planilha_items resources :bixes, except: [:edit] resources :modalidades + resources :items end diff --git a/db/migrate/20230308204741_items.rb b/db/migrate/20230308204741_items.rb new file mode 100644 index 0000000..01a4290 --- /dev/null +++ b/db/migrate/20230308204741_items.rb @@ -0,0 +1,10 @@ +class Items < ActiveRecord::Migration[7.0] + def change + create_table :items do |t| + t.string :nome + t.numeric :preco + + t.timestamps + end + end +end diff --git a/db/migrate/20230308205332_create_bixes_items_table.rb b/db/migrate/20230308205332_create_bixes_items_table.rb new file mode 100644 index 0000000..deb9a9a --- /dev/null +++ b/db/migrate/20230308205332_create_bixes_items_table.rb @@ -0,0 +1,10 @@ +class CreateBixesItemsTable < ActiveRecord::Migration[7.0] + def change + create_table :bixes_items do |t| + t.references :bixe, null: false, foreign_key: true, index: true + t.references :item, null: false, foreign_key: true, index: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index da47878..2225c37 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_03_14_002825) do +ActiveRecord::Schema[7.0].define(version: 2023_03_08_205332) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -23,6 +23,15 @@ t.datetime "updated_at", null: false end + create_table "bixes_items", force: :cascade do |t| + t.bigint "bixe_id", null: false + t.bigint "item_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["bixe_id"], name: "index_bixes_items_on_bixe_id" + t.index ["item_id"], name: "index_bixes_items_on_item_id" + end + create_table "bixes_modalidades", force: :cascade do |t| t.bigint "bixe_id", null: false t.bigint "modalidade_id", null: false @@ -39,12 +48,21 @@ t.index ["bixe_id"], name: "index_confirmacoes_on_bixe_id" end + create_table "items", force: :cascade do |t| + t.string "nome" + t.decimal "preco" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "modalidades", force: :cascade do |t| t.string "nome" t.datetime "created_at", null: false t.datetime "updated_at", null: false end + add_foreign_key "bixes_items", "bixes" + add_foreign_key "bixes_items", "items" add_foreign_key "bixes_modalidades", "bixes" add_foreign_key "bixes_modalidades", "modalidades" add_foreign_key "confirmacoes", "bixes" From e4024262a59adabb19a98c44dd2fa898935b00c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 11 Mar 2023 04:22:09 -0300 Subject: [PATCH 09/20] =?UTF-8?q?Modifica=20aviso=20de=20remo=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20produto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/controllers/items_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 93307b9..76351b1 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -67,7 +67,7 @@ def update def destroy @item.destroy respond_to do |format| - format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' } + format.html { redirect_to items_url, notice: 'O produto foi removido com sucesso.' } format.json { head :no_content } end end From fa2d192bae8f0169fc066e2a980b25cdeb2c3c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 11 Mar 2023 04:23:59 -0300 Subject: [PATCH 10/20] =?UTF-8?q?Adiciona=20m=C3=B3dulo=20helper=20dos=20p?= =?UTF-8?q?rodutos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/helpers/items_helper.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/helpers/items_helper.rb diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb new file mode 100644 index 0000000..cff0c9f --- /dev/null +++ b/app/helpers/items_helper.rb @@ -0,0 +1,2 @@ +module ItemsHelper +end From 9865e7d1875999631c3ff893df844f1a4858c33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 11 Mar 2023 07:09:46 -0300 Subject: [PATCH 11/20] =?UTF-8?q?Adiciona=20quantidades=20e=20vari=C3=A1ve?= =?UTF-8?q?l=20de=20indica=C3=A7=C3=A3o=20do=20Kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/controllers/bixes_controller.rb | 1 + app/controllers/items_controller.rb | 2 +- app/models/item.rb | 3 + app/views/bixes/items.html.erb | 65 +++++++++++++++++-- app/views/items/_form.html.erb | 10 +++ app/views/items/index.html.erb | 38 ++++++++--- app/views/items/planilha.html.erb | 6 +- db/migrate/20230308204741_items.rb | 2 + ...20230308205332_create_bixes_items_table.rb | 3 +- db/schema.rb | 3 + 10 files changed, 114 insertions(+), 19 deletions(-) diff --git a/app/controllers/bixes_controller.rb b/app/controllers/bixes_controller.rb index 38b024b..a8ae3b9 100644 --- a/app/controllers/bixes_controller.rb +++ b/app/controllers/bixes_controller.rb @@ -46,6 +46,7 @@ def items end end + # GET /bixos/contatos def contatos @bixes = Bixe.all diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 76351b1..1188407 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -80,6 +80,6 @@ def set_item # Never trust parameters from the scary internet, only allow the white list through. def item_params - params.require(:item).permit(:nome, :preco) + params.require(:item).permit(:nome, :preco, :quantidade, :eh_do_kit) end end diff --git a/app/models/item.rb b/app/models/item.rb index 001e2c5..007191e 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -1,5 +1,8 @@ class Item < ApplicationRecord validates :nome, presence: true, uniqueness: true validates :preco, presence: true + validates :quantidade, presence: true + validates :eh_do_kit, inclusion: { in: [true, false] } + has_and_belongs_to_many :bixes end diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb index 5591857..be26ccc 100644 --- a/app/views/bixes/items.html.erb +++ b/app/views/bixes/items.html.erb @@ -1,12 +1,34 @@

    Mudar compras de <%= @bixe.nome %>

    <%= form_tag do %> - <% Item.all.each do |it| %> -
    - <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true) %> - <%= label_tag("items[#{it.id}]", it.nome) %> +

    Produtos do Kit Bixe

    +
    +
    + +
    - <% end %> +
    + <% Item.all.each do |it| %> + <% if it.eh_do_kit %> +
    + <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true, data: { "eh-do-kit": it.eh_do_kit }) %> + <%= label_tag("items[#{it.id}]", it.nome) %> +
    + <% end %> + <% end %> +
    + +

    Produtos Separados

    +
    + <% Item.all.each do |it| %> + <% unless it.eh_do_kit %> +
    + <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true, data: { "eh-do-kit": it.eh_do_kit }) %> + <%= label_tag("items[#{it.id}]", it.nome) %> +
    + <% end %> + <% end %> +
    @@ -22,3 +44,36 @@
    <% end %> + + diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb index 55851f8..c2fc8d2 100644 --- a/app/views/items/_form.html.erb +++ b/app/views/items/_form.html.erb @@ -21,6 +21,16 @@ <%= form.text_field :preco, id: :item_preco %>
    +
    + <%= form.label :quantidade, 'Quantidade' %> + <%= form.text_field :quantidade, id: :item_quantidade %> +
    + +
    + <%= form.label :eh_do_kit, 'Este produto faz parte do Kit Bixe' %> + <%= form.check_box :eh_do_kit, id: :item_eh_do_kit %> +
    +
    diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb index abedbc7..2e1502c 100644 --- a/app/views/items/index.html.erb +++ b/app/views/items/index.html.erb @@ -6,17 +6,37 @@
    +

    Kit Bixe

    <% @items.each_with_index do |p, i| %> -
    - <%= link_to item_path(p.id) do %> -

    -
    - <%= p.nome %> -
    -

    - <% end %> -
    + <% if p.eh_do_kit %> +
    + <%= link_to item_path(p.id) do %> +

    +
    + <%= p.nome %> +
    +

    + <% end %> +
    + <% end %> + <% end %> +
    + +

    Separados

    +
    + <% @items.each_with_index do |p, i| %> + <% unless p.eh_do_kit %> +
    + <%= link_to item_path(p.id) do %> +

    +
    + <%= p.nome %> +
    +

    + <% end %> +
    + <% end %> <% end %>
    diff --git a/app/views/items/planilha.html.erb b/app/views/items/planilha.html.erb index 47812cc..fab33e6 100644 --- a/app/views/items/planilha.html.erb +++ b/app/views/items/planilha.html.erb @@ -5,16 +5,16 @@ produto,bixe,telefone,email <% @items.each do |i| %> <% i.bixes.each do |b| %> -<%= i.nome %>,<%= b.nome %>,<%= b.telefone %>,<%= b.email %> +"<%= i.nome %>","<%= b.nome %>","<%= b.telefone %>","<%= b.email %>" <% end %> <% end %>

    Relação produto-preço

    -produto,preço
    +produto,preço,estoque,eh_do_kit,num_bixes_que_compraram
     <% @items.each do |i| %>
    -<%= i.nome %>,<%= i.preco %>
    + "<%= i.nome %>",<%= i.preco %>,<%= i.quantidade %>,<%= i.eh_do_kit %>,<%= i.bixes.count %>
     <% end %>
     
    diff --git a/db/migrate/20230308204741_items.rb b/db/migrate/20230308204741_items.rb index 01a4290..d9f5cb1 100644 --- a/db/migrate/20230308204741_items.rb +++ b/db/migrate/20230308204741_items.rb @@ -3,6 +3,8 @@ def change create_table :items do |t| t.string :nome t.numeric :preco + t.numeric :quantidade + t.boolean :eh_do_kit t.timestamps end diff --git a/db/migrate/20230308205332_create_bixes_items_table.rb b/db/migrate/20230308205332_create_bixes_items_table.rb index deb9a9a..a3f107b 100644 --- a/db/migrate/20230308205332_create_bixes_items_table.rb +++ b/db/migrate/20230308205332_create_bixes_items_table.rb @@ -3,7 +3,8 @@ def change create_table :bixes_items do |t| t.references :bixe, null: false, foreign_key: true, index: true t.references :item, null: false, foreign_key: true, index: true - + + t.integer :quantity, null: false, default: 0 t.timestamps end end diff --git a/db/schema.rb b/db/schema.rb index 2225c37..53828d5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -26,6 +26,7 @@ create_table "bixes_items", force: :cascade do |t| t.bigint "bixe_id", null: false t.bigint "item_id", null: false + t.integer "quantity", default: 0, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["bixe_id"], name: "index_bixes_items_on_bixe_id" @@ -51,6 +52,8 @@ create_table "items", force: :cascade do |t| t.string "nome" t.decimal "preco" + t.decimal "quantidade" + t.boolean "eh_do_kit" t.datetime "created_at", null: false t.datetime "updated_at", null: false end From 783b035953a6c396450ab1e59a460727b6356de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Thu, 11 Jan 2024 03:14:27 -0400 Subject: [PATCH 12/20] Fix some gems compatibility issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4607d70..e049cb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,9 @@ ENV PORT=3000 \ WORKDIR ${APP_PATH} RUN apk add --update \ - build-base git bash tzdata postgresql-dev gcompat && \ + build-base git bash tzdata libxml2 postgresql-dev gcompat && \ + gem install nokogiri -v '1.15.5' && \ + gem install net-imap -v '0.3.7' && \ gem install rails COPY . ./ From 1ed09408927ccc91003b36e8321a9caa6b0a1601 Mon Sep 17 00:00:00 2001 From: Renata Date: Wed, 7 Feb 2024 15:04:36 -0300 Subject: [PATCH 13/20] adicionado suporte para quantidade de itens --- app/controllers/bixes_controller.rb | 17 +++- app/models/bixe.rb | 3 +- app/models/bixe_item.rb | 6 ++ app/models/item.rb | 3 +- app/views/bixes/items.html.erb | 77 ++++++++++--------- app/views/bixes/show.html.erb | 4 +- app/views/items/show.html.erb | 26 ++++--- db/migrate/20240206184442_create_bixe_item.rb | 11 +++ db/schema.rb | 14 +++- 9 files changed, 108 insertions(+), 53 deletions(-) create mode 100644 app/models/bixe_item.rb create mode 100644 db/migrate/20240206184442_create_bixe_item.rb diff --git a/app/controllers/bixes_controller.rb b/app/controllers/bixes_controller.rb index a8ae3b9..d5e689a 100644 --- a/app/controllers/bixes_controller.rb +++ b/app/controllers/bixes_controller.rb @@ -40,9 +40,9 @@ def modalidades # GET /bixos/1/items def items - @check = {} - @bixe.items.each do |i| - @check[i.id] = true + @quantities = {} + @bixe.bixe_items.each do |i| + @quantities[i.item_id] = i.quantity end end @@ -68,7 +68,16 @@ def modify_modalidades # POST /bixos/1/items def modify_items - @bixe.items = items_params.to_hash.map { |k,v| Item.find(k) } + items_params.each do |item_id, quantity| + bixe_item = @bixe.bixe_items.find_or_create_by(item_id: item_id) + if quantity.to_i > 0 + bixe_item.quantity = quantity + bixe_item.save + else + bixe_item.destroy + end + end + respond_to do |format| if @bixe.save format.html { redirect_to @bixe, notice: 'Itens modificados com sucesso!' } diff --git a/app/models/bixe.rb b/app/models/bixe.rb index caa493a..e4e323d 100644 --- a/app/models/bixe.rb +++ b/app/models/bixe.rb @@ -5,7 +5,8 @@ class Bixe < ApplicationRecord validates :curso, presence: true has_and_belongs_to_many :modalidades - has_and_belongs_to_many :items + has_many :bixe_items + has_many :items, through: :bixe_items has_one :confirmacao enum curso: [:LIC, :PURA, :BCC, :ESTAT, :APLICADA, :BMAC, :LICNOTURNO].freeze diff --git a/app/models/bixe_item.rb b/app/models/bixe_item.rb new file mode 100644 index 0000000..2b3aa23 --- /dev/null +++ b/app/models/bixe_item.rb @@ -0,0 +1,6 @@ +class BixeItem < ApplicationRecord + validates :quantity, presence: true + + belongs_to :bixe + belongs_to :item +end diff --git a/app/models/item.rb b/app/models/item.rb index 007191e..4e490f6 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -4,5 +4,6 @@ class Item < ApplicationRecord validates :quantidade, presence: true validates :eh_do_kit, inclusion: { in: [true, false] } - has_and_belongs_to_many :bixes + has_many :bixe_items + has_many :bixes, through: :bixe_items end diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb index be26ccc..6928600 100644 --- a/app/views/bixes/items.html.erb +++ b/app/views/bixes/items.html.erb @@ -1,35 +1,50 @@

    Mudar compras de <%= @bixe.nome %>

    +
    <%= form_tag do %>

    Produtos do Kit Bixe

    -
    - - +
    + + + + + + + + + + + +

    <% Item.all.each do |it| %> <% if it.eh_do_kit %> -
    - <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true, data: { "eh-do-kit": it.eh_do_kit }) %> - <%= label_tag("items[#{it.id}]", it.nome) %> +
    + <%= label_tag("items[#{it.id}]", it.nome) %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px; margin-right: 35em;") %> + +
    <% end %> <% end %>
    - +

    Produtos Separados

    <% Item.all.each do |it| %> <% unless it.eh_do_kit %> -
    - <%= check_box_tag("items[#{it.id}]", it.nome, @check[it.id] == true, data: { "eh-do-kit": it.eh_do_kit }) %> - <%= label_tag("items[#{it.id}]", it.nome) %> +
    + <%= label_tag("items[#{it.id}]", it.nome) %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px; margin-right: 35em;") %> + +
    <% end %> <% end %>
    - +
    @@ -47,33 +62,25 @@ diff --git a/app/views/bixes/show.html.erb b/app/views/bixes/show.html.erb index 1cd1934..786067d 100644 --- a/app/views/bixes/show.html.erb +++ b/app/views/bixes/show.html.erb @@ -54,9 +54,9 @@ <% if @bixe.items.empty? %>

    Nenhum

    <% else %> - <% @bixe.items.each do |it| %> + <% @bixe.bixe_items.each do |it| %>

    - <%= it.nome %> + <%= it.item.nome %> - <%= it.quantity %>

    <% end %> <% end %> diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index e7b9744..61ebf2b 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -19,21 +19,29 @@

    Bixes que compraram o produto

    - <% @item.bixes.each_with_index do |b, i| %> -
    - <%= link_to bixe_path(b.id) do %> + + <% @item.bixe_items.each_with_index do |b, i| %> + +
    + <%= link_to bixe_path(b.bixe.id) do %>

    -
    - <%= b.nome %> +
    + <%= b.bixe.nome %> +
    +
    + <%= b.bixe.email %>
    -
    - <%= b.email %> +
    + <%= b.bixe.telefone %>
    -
    - <%= b.telefone %> +
    + <%= b.quantity %>
    +

    + <% end %>
    + <% end %>
    diff --git a/db/migrate/20240206184442_create_bixe_item.rb b/db/migrate/20240206184442_create_bixe_item.rb new file mode 100644 index 0000000..88527db --- /dev/null +++ b/db/migrate/20240206184442_create_bixe_item.rb @@ -0,0 +1,11 @@ +class CreateBixeItem < ActiveRecord::Migration[7.0] + def change + create_table :bixe_items do |t| + t.references :bixe, foreign_key: true + t.references :item, foreign_key: true + t.integer :quantity, null: false, default: 1 + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 53828d5..bc2c44c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_08_205332) do +ActiveRecord::Schema[7.0].define(version: 2024_02_06_184442) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "bixe_items", force: :cascade do |t| + t.bigint "bixe_id" + t.bigint "item_id" + t.integer "quantity", default: 1, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["bixe_id"], name: "index_bixe_items_on_bixe_id" + t.index ["item_id"], name: "index_bixe_items_on_item_id" + end + create_table "bixes", force: :cascade do |t| t.string "nome" t.string "email" @@ -64,6 +74,8 @@ t.datetime "updated_at", null: false end + add_foreign_key "bixe_items", "bixes" + add_foreign_key "bixe_items", "items" add_foreign_key "bixes_items", "bixes" add_foreign_key "bixes_items", "items" add_foreign_key "bixes_modalidades", "bixes" From 96f3154a1a1bc1c35ab5d5495850698bd0dff610 Mon Sep 17 00:00:00 2001 From: Renata Date: Wed, 7 Feb 2024 19:20:08 -0300 Subject: [PATCH 14/20] adicionado suporte para quantidade de produtos --- app/views/items/planilha.html.erb | 6 +++--- app/views/items/show.html.erb | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/views/items/planilha.html.erb b/app/views/items/planilha.html.erb index fab33e6..6744c37 100644 --- a/app/views/items/planilha.html.erb +++ b/app/views/items/planilha.html.erb @@ -2,10 +2,10 @@

    Relação bixe-produto

    -produto,bixe,telefone,email
    +produto,bixe,quantidade,telefone,email
     <% @items.each do |i| %>
    -<% i.bixes.each do |b| %>
    -"<%= i.nome %>","<%= b.nome %>","<%= b.telefone %>","<%= b.email %>"
    +<% i.bixe_items.each do |b| %>
    +"<%= i.nome %>","<%= b.bixe.nome %>",<%= b.quantity %>,"<%= b.bixe.telefone %>","<%= b.bixe.email %>"
     <% end %>
     <% end %>
     
    diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index 61ebf2b..e313e7f 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -19,7 +19,30 @@

    Bixes que compraram o produto

    - + <% @item.bixe_items.each_with_index do |b, i| %>
    From b6d2ad1079fe31b22581d381ad91e70f23261fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 10 Feb 2024 09:16:26 -0400 Subject: [PATCH 15/20] Add container and remove spacings with margins and tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/views/bixes/items.html.erb | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb index 6928600..6137335 100644 --- a/app/views/bixes/items.html.erb +++ b/app/views/bixes/items.html.erb @@ -4,26 +4,17 @@ <%= form_tag do %>

    Produtos do Kit Bixe

    -
    - - - - - - - - - - - - +
    + + +

    <% Item.all.each do |it| %> <% if it.eh_do_kit %> -
    +
    <%= label_tag("items[#{it.id}]", it.nome) %> - <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px; margin-right: 35em;") %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px;") %>
    @@ -35,9 +26,9 @@
    <% Item.all.each do |it| %> <% unless it.eh_do_kit %> -
    +
    <%= label_tag("items[#{it.id}]", it.nome) %> - <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px; margin-right: 35em;") %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px;") %>
    @@ -84,3 +75,13 @@ }); + + From 13c9ff970ed6cbd6a96e96dbeb946876d8acbf7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 10 Feb 2024 09:53:15 -0400 Subject: [PATCH 16/20] Update user interaction and design to increment and decrement buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/views/bixes/items.html.erb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb index 6137335..37986e5 100644 --- a/app/views/bixes/items.html.erb +++ b/app/views/bixes/items.html.erb @@ -5,9 +5,9 @@

    Produtos do Kit Bixe

    - - - + + +

    <% Item.all.each do |it| %> @@ -84,4 +84,9 @@ padding: 0px 20px; max-width: 675px; } + +.square-button { + min-width: 40px; + min-height: 40px; +} From c4fd2bed13e400bc174d54b50b51bb1979265ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Sat, 10 Feb 2024 11:31:43 -0400 Subject: [PATCH 17/20] Add highlight to number input if quantity is greater than 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/views/bixes/items.html.erb | 58 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/app/views/bixes/items.html.erb b/app/views/bixes/items.html.erb index 37986e5..7e6fb47 100644 --- a/app/views/bixes/items.html.erb +++ b/app/views/bixes/items.html.erb @@ -13,10 +13,8 @@ <% Item.all.each do |it| %> <% if it.eh_do_kit %>
    - <%= label_tag("items[#{it.id}]", it.nome) %> - <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px;") %> - - + <%= label_tag("items[#{it.id}]", it.nome) %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, class: "quantity-input") %>
    <% end %> <% end %> @@ -27,10 +25,8 @@ <% Item.all.each do |it| %> <% unless it.eh_do_kit %>
    - <%= label_tag("items[#{it.id}]", it.nome) %> - <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, style: "width: 55px;") %> - - + <%= label_tag("items[#{it.id}]", it.nome) %> + <%= number_field_tag("items[#{it.id}]", it.nome, value: @quantities[it.id], min: 0, data: { "eh-do-kit": it.eh_do_kit }, class: "quantity-input") %>
    <% end %> <% end %> @@ -56,23 +52,44 @@ var increaseByOne = document.querySelector("#increase-one"); var decreaseByOne = document.querySelector("#decrease-one"); var numberInputs = document.querySelectorAll("input[type='number'][data-eh-do-kit='true']"); + var allNumberInputs = document.querySelectorAll("input[type='number']"); + + function highlightInput(input) { + if (parseInt(input.value) > 0) { + input.classList.add("selected-item"); + } else { + input.classList.remove("selected-item"); + } + } increaseByOne.addEventListener("click", function() { for (var i = 0; i < numberInputs.length; i++) { - if (numberInputs[i].value == "") { - numberInputs[i].value = "0"; - } + if (numberInputs[i].value == "") { + numberInputs[i].value = "0"; + } numberInputs[i].value = parseInt(numberInputs[i].value) + 1; + highlightInput(numberInputs[i]); } }); decreaseByOne.addEventListener("click", function() { for (var i = 0; i < numberInputs.length; i++) { - if (numberInputs[i].value > 0) { - numberInputs[i].value = parseInt(numberInputs[i].value) - 1; - } } + if (numberInputs[i].value > 0) { + numberInputs[i].value = parseInt(numberInputs[i].value) - 1; + highlightInput(numberInputs[i]); + } + } }); + for (var i = 0; i < allNumberInputs.length; i++) { + allNumberInputs[i].addEventListener("input", function() { + highlightInput(this); + }); + if (allNumberInputs[i].value == "") { + allNumberInputs[i].value = "0"; + } + highlightInput(allNumberInputs[i]); + } }); @@ -89,4 +106,17 @@ min-width: 40px; min-height: 40px; } + +.selected-item { + background-color: #5da355; + border-radius: 5px; + color: white; +} + +.quantity-input { + padding: 5px 0px 5px 10px; + max-width: 70px; + border-radius: 5px; + border: 1px solid #ccc; +} From ad0f40ebb8664ba3db0dfccb17828808a7964706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Wed, 21 Feb 2024 00:30:38 -0400 Subject: [PATCH 18/20] Change team colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/assets/stylesheets/application.scss | 4 ++-- app/models/confirmacao.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 7fa88ae..2171263 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -80,8 +80,8 @@ h4 { background: #20b1ba; } -.team-gold { - background: #ffd700; +.team-brown { + background: #a36026; } .btn { diff --git a/app/models/confirmacao.rb b/app/models/confirmacao.rb index 431956f..d935976 100644 --- a/app/models/confirmacao.rb +++ b/app/models/confirmacao.rb @@ -1,7 +1,7 @@ class Confirmacao < ApplicationRecord belongs_to :bixe - COLORS = [:PURPLE, :ORANGE, :GREEN, :BLUE, :GOLD].freeze + COLORS = [:PURPLE, :ORANGE, :GREEN, :BLUE, :BROWN].freeze def team_color From 71f9b6ec98426a283ba98c1bfdafbcf4d57c9cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Wed, 21 Feb 2024 00:48:10 -0400 Subject: [PATCH 19/20] Fix team colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/assets/stylesheets/application.scss | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 2171263..bb6dabf 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -65,23 +65,23 @@ h4 { // Team colors .team-purple { - background: #c185e4; + background: #cd9ce9; } .team-orange { - background: #eb963c; + background: #f49f3f; } .team-green { - background: #a8bd56; + background: #a9c831; } .team-blue { - background: #20b1ba; + background: #35bfdb; } .team-brown { - background: #a36026; + background: #bf8a5d; } .btn { From 947989fc6a3a751a713790a1a0768f4c6bc2eaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas=20Silva=20Mayer?= Date: Thu, 22 Feb 2024 15:12:20 -0400 Subject: [PATCH 20/20] Add stock restriction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Lucas Silva Mayer --- app/controllers/bixes_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/bixes_controller.rb b/app/controllers/bixes_controller.rb index d5e689a..635bf8a 100644 --- a/app/controllers/bixes_controller.rb +++ b/app/controllers/bixes_controller.rb @@ -71,6 +71,13 @@ def modify_items items_params.each do |item_id, quantity| bixe_item = @bixe.bixe_items.find_or_create_by(item_id: item_id) if quantity.to_i > 0 + already_bought = BixeItem.where(item_id: item_id).map(&:quantity).sum - bixe_item.quantity + item = Item.find(item_id) + if quantity.to_i > item.quantidade - already_bought + flash[:error] = "Não há quantidade suficiente do item #{item.nome} em estoque" + redirect_to action: "items", id: @bixe.id and return + end + bixe_item.quantity = quantity bixe_item.save else