From f2c1e0198ef4d39a1d6523042421f9df3fcf38c4 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 25 Oct 2024 14:17:42 +0300 Subject: [PATCH 01/33] 920 Added seeds for categories --- db/seeds.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 99495cd83..e3d78a3de 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -30,3 +30,47 @@ end FactoryBot.create(:product, :diaper) unless Product.exists?(title: "diaper") + +# Categories +def create_category_with_periods(en_name, uk_name, periods) + unless Category.exists?(en_name: en_name) + category = Category.create!(en_name: en_name, uk_name: uk_name) + + periods.each do |period_data| + DiapersPeriod.create!(period_data.merge(category: category)) + end + end +end + +# Budgetary category periods +create_category_with_periods("Budgetary", "Бюджетна", [ + { period_start: 1, period_end: 3, usage_amount: 10, price: 5.96 }, + { period_start: 4, period_end: 6, usage_amount: 8, price: 6.35 }, + { period_start: 7, period_end: 9, usage_amount: 6, price: 6.35 }, + { period_start: 10, period_end: 12, usage_amount: 6, price: 6.45 }, + { period_start: 13, period_end: 18, usage_amount: 4, price: 6.45 }, + { period_start: 19, period_end: 24, usage_amount: 4, price: 7.6 }, + { period_start: 25, period_end: 30, usage_amount: 2, price: 7.6 } +]) + +# Medium category periods +create_category_with_periods("Medium", "Середня", [ + { period_start: 1, period_end: 3, usage_amount: 10, price: 8.03 }, + { period_start: 4, period_end: 6, usage_amount: 8, price: 8.33 }, + { period_start: 7, period_end: 9, usage_amount: 6, price: 8.65 }, + { period_start: 10, period_end: 12, usage_amount: 6, price: 10.07 }, + { period_start: 13, period_end: 18, usage_amount: 4, price: 10.07 }, + { period_start: 19, period_end: 24, usage_amount: 4, price: 11.13 }, + { period_start: 25, period_end: 30, usage_amount: 2, price: 11.13 } +]) + +# Premium category periods +create_category_with_periods("Premium", "Преміум", [ + { period_start: 1, period_end: 3, usage_amount: 10, price: 11.41 }, + { period_start: 4, period_end: 6, usage_amount: 8, price: 12.59 }, + { period_start: 7, period_end: 9, usage_amount: 6, price: 14.18 }, + { period_start: 10, period_end: 12, usage_amount: 6, price: 18.52 }, + { period_start: 13, period_end: 18, usage_amount: 4, price: 18.52 }, + { period_start: 19, period_end: 24, usage_amount: 4, price: 18.62 }, + { period_start: 25, period_end: 30, usage_amount: 2, price: 18.62 } +]) From f471776f2738f41cf74aa95739b365e37c0f0f3f Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 1 Nov 2024 18:00:46 +0200 Subject: [PATCH 02/33] Restrict input to two decimal places in price input fields --- app/javascript/controllers/price_form_controller.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/javascript/controllers/price_form_controller.js b/app/javascript/controllers/price_form_controller.js index 9ecdf8479..8e2262e64 100644 --- a/app/javascript/controllers/price_form_controller.js +++ b/app/javascript/controllers/price_form_controller.js @@ -13,6 +13,7 @@ export default class extends Controller { this.priceInputTargets.forEach(input => { input.addEventListener('input', this.validatePriceInput.bind(this)); + input.addEventListener('keydown', this.restrictDecimalInput.bind(this)); }); } @@ -57,4 +58,13 @@ export default class extends Controller { target.style.borderColor = ""; } } + + restrictDecimalInput(event) { + const target = event.target; + const inputValue = target.value; + + if (inputValue.includes('.') && inputValue.split('.')[1].length >= 2 && !["Backspace", "Delete"].includes(event.key)) { + event.preventDefault(); + } + } } From 0a0654ef7edbf3ab4d5d19ea0fa1a6526425466f Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 00:44:04 +0200 Subject: [PATCH 03/33] creates show page for calculators --- .../stylesheets/application.tailwind.css | 1 + .../components/showpage_calculator.css | 17 +++++++++++ .../account/calculators_controller.rb | 2 +- app/views/account/calculators/show.html.erb | 29 +++++++++++++++++++ config/locales/en/en.yml | 6 ++++ config/locales/uk/uk.yml | 6 ++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/components/showpage_calculator.css create mode 100644 app/views/account/calculators/show.html.erb diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index f73f37afc..9a85acf0b 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -10,5 +10,6 @@ @import "/components/pagination"; @import "/components/breadcrumbs.scss"; @import "/components/description_block"; +@import "/components/showpage_calculator"; @import "/utilities/custom-utilities"; @import "/pages/under_construction" diff --git a/app/assets/stylesheets/components/showpage_calculator.css b/app/assets/stylesheets/components/showpage_calculator.css new file mode 100644 index 000000000..700449958 --- /dev/null +++ b/app/assets/stylesheets/components/showpage_calculator.css @@ -0,0 +1,17 @@ +@layer base { + .main-show-container { + @apply flex flex-col bg-white rounded-lg shadow-md w-full p-6 text-left mt-4; + } + .back-arrow { + @apply rounded mb-4 px-2 flex items-center; + } + .calc-details { + @apply flex flex-col mb-4 px-2; + } + .showpage-buttons { + @apply flex justify-start w-full space-x-4; + } + .showpage-text { + @apply text-gray-900; + } + } \ No newline at end of file diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index 0c85b334e..d0156447b 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Account::CalculatorsController < Account::BaseController - before_action :calculator, only: [:edit, :update, :destroy] + before_action :calculator, only: [:show, :edit, :update, :destroy] load_and_authorize_resource def index diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb new file mode 100644 index 000000000..450da2e0d --- /dev/null +++ b/app/views/account/calculators/show.html.erb @@ -0,0 +1,29 @@ +
+ <%= link_to account_calculators_path, class: "back-arrow" do %> + <%= inline_svg "icons/arrow-left.svg", class: "z-1 mr-2 mb-0.5" %> + <%= t('buttons.back') %> + <% end %> + +
+ <%= t('.name') %>: +

<%= @calculator.name %>

+
+ +
+ <%= t('.slug') %>: +

<%= @calculator.slug %>

+
+ +
+ <%= link_to t('.edit'), + edit_account_calculator_path(@calculator.slug, locale: I18n.locale), + class: "btn btn-green" %> + + <%= button_to account_calculator_path(@calculator.slug, locale: I18n.locale), + method: :delete, + data: { turbo_confirm: t('.confirm_delete') }, + class: "btn btn-danger" do %> + <%= t('.delete') %> + <% end %> +
+
\ No newline at end of file diff --git a/config/locales/en/en.yml b/config/locales/en/en.yml index 1828133a0..a1950fcbb 100644 --- a/config/locales/en/en.yml +++ b/config/locales/en/en.yml @@ -439,6 +439,12 @@ en: update_calculator_button: "Update calculator" new: create_calculator_button: "Create calculator" + show: + confirm_delete: "Are you sure you want to delete this calculator?" + name: "Name" + slug: "Slug" + edit: "Edit" + delete: "Delete" feature_flags: submit_button: "Save" new_calculator_design: diff --git a/config/locales/uk/uk.yml b/config/locales/uk/uk.yml index 57ecc3936..67f265a04 100644 --- a/config/locales/uk/uk.yml +++ b/config/locales/uk/uk.yml @@ -326,6 +326,12 @@ uk: prohibited_to_update: " перешкоджають оновленню калькулятора" prohibited_to_save: " перешкоджають збереженню калькулятора" error: "помилки" + show: + confirm_delete: "Ви впевнені, що хочете видалити цей калькулятор?" + name: "Назва" + slug: "Шлях" + edit: "Редагувати" + delete: "Видалити" site_settings: edit: meta-title: "Налаштування сайту" From c2a2fc8688d00563bb784b433e382a20d204bd9d Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 00:47:16 +0200 Subject: [PATCH 04/33] updated spaces in files --- app/assets/stylesheets/components/showpage_calculator.css | 3 ++- app/views/account/calculators/show.html.erb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/components/showpage_calculator.css b/app/assets/stylesheets/components/showpage_calculator.css index 700449958..3fa30a41d 100644 --- a/app/assets/stylesheets/components/showpage_calculator.css +++ b/app/assets/stylesheets/components/showpage_calculator.css @@ -14,4 +14,5 @@ .showpage-text { @apply text-gray-900; } - } \ No newline at end of file + } + \ No newline at end of file diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb index 450da2e0d..ae104c9c5 100644 --- a/app/views/account/calculators/show.html.erb +++ b/app/views/account/calculators/show.html.erb @@ -26,4 +26,4 @@ <%= t('.delete') %> <% end %> - \ No newline at end of file + From b24232416950e8f1d19e3caca44a763456319657 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 00:48:54 +0200 Subject: [PATCH 05/33] updated spaces in files --- app/assets/stylesheets/components/showpage_calculator.css | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/components/showpage_calculator.css b/app/assets/stylesheets/components/showpage_calculator.css index 3fa30a41d..8e3e79c3a 100644 --- a/app/assets/stylesheets/components/showpage_calculator.css +++ b/app/assets/stylesheets/components/showpage_calculator.css @@ -15,4 +15,3 @@ @apply text-gray-900; } } - \ No newline at end of file From 69409c7d72a4480b5da3390e47effe5c34c128ca Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 01:16:19 +0200 Subject: [PATCH 06/33] updated css file --- .../components/showpage_calculator.css | 36 ++++++++++--------- app/views/account/calculators/show.html.erb | 4 +-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/components/showpage_calculator.css b/app/assets/stylesheets/components/showpage_calculator.css index 8e3e79c3a..c106a4e6e 100644 --- a/app/assets/stylesheets/components/showpage_calculator.css +++ b/app/assets/stylesheets/components/showpage_calculator.css @@ -1,17 +1,21 @@ -@layer base { - .main-show-container { - @apply flex flex-col bg-white rounded-lg shadow-md w-full p-6 text-left mt-4; - } - .back-arrow { - @apply rounded mb-4 px-2 flex items-center; - } - .calc-details { - @apply flex flex-col mb-4 px-2; - } - .showpage-buttons { - @apply flex justify-start w-full space-x-4; - } - .showpage-text { - @apply text-gray-900; - } +@layer components { + .main-show-container { + @apply flex flex-col bg-white rounded-lg shadow-md w-full p-6 text-left mt-4; } + + .back-arrow { + @apply rounded mb-4 px-2 flex items-center; + } + + .calc-details { + @apply flex flex-col mb-4 px-2; + } + + .showpage-buttons { + @apply flex justify-start w-full space-x-4; + } + + .showpage-text { + @apply text-slate-600 text-sm; + } +} diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb index ae104c9c5..9a6fdaaa9 100644 --- a/app/views/account/calculators/show.html.erb +++ b/app/views/account/calculators/show.html.erb @@ -5,12 +5,12 @@ <% end %>
- <%= t('.name') %>: + <%= t('.name') %>:

<%= @calculator.name %>

- <%= t('.slug') %>: + <%= t('.slug') %>:

<%= @calculator.slug %>

From 7ffda2b4809ba162dabd0756c62888c8dca7d55b Mon Sep 17 00:00:00 2001 From: OlexanderVanzuriak <48361492+olexandervanzuriak@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:36:49 +0200 Subject: [PATCH 07/33] 906 Fix scroll bug (#919) * Fix scroll bug * make scrolling smooth --- app/javascript/controllers/results_controller.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/controllers/results_controller.js b/app/javascript/controllers/results_controller.js index 2fc4578ed..f66dbcc75 100644 --- a/app/javascript/controllers/results_controller.js +++ b/app/javascript/controllers/results_controller.js @@ -20,5 +20,7 @@ export default class extends Controller { this.willBuyDiapersPluralizeTarget.innerHTML = result.to_be_diapers_amount_pluralize; this.boughtDiapersPluralizeTarget.innerHTML = result.used_diapers_amount_pluralize; + + this.element.scrollIntoView({ behavior: "smooth" }); } } From 150cb68d9d60872bced6fbc46e07041a42a70e7b Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 13:55:51 +0200 Subject: [PATCH 08/33] updated yml file and seeds --- db/data/categories.yml | 36 +++++++++++++++++++++++++++++ db/seeds.rb | 51 ++++++++++-------------------------------- 2 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 db/data/categories.yml diff --git a/db/data/categories.yml b/db/data/categories.yml new file mode 100644 index 000000000..8c845fa64 --- /dev/null +++ b/db/data/categories.yml @@ -0,0 +1,36 @@ +categories: + - en_name: Budgetary + uk_name: Бюджетна + priority: 1 + periods: + - {period_start: 1, period_end: 3, usage_amount: 10, price: 5.96} + - {period_start: 4, period_end: 6, usage_amount: 8, price: 6.35} + - {period_start: 7, period_end: 9, usage_amount: 6, price: 6.35} + - {period_start: 10, period_end: 12, usage_amount: 6, price: 6.45} + - {period_start: 13, period_end: 18, usage_amount: 4, price: 6.45} + - {period_start: 19, period_end: 24, usage_amount: 4, price: 7.6} + - {period_start: 25, period_end: 30, usage_amount: 2, price: 7.6} + + - en_name: Medium + uk_name: Середня + priority: 2 + periods: + - {period_start: 1, period_end: 3, usage_amount: 10, price: 8.03} + - {period_start: 4, period_end: 6, usage_amount: 8, price: 8.33} + - {period_start: 7, period_end: 9, usage_amount: 6, price: 8.65} + - {period_start: 10, period_end: 12, usage_amount: 6, price: 10.07} + - {period_start: 13, period_end: 18, usage_amount: 4, price: 10.07} + - {period_start: 19, period_end: 24, usage_amount: 4, price: 11.13} + - {period_start: 25, period_end: 30, usage_amount: 2, price: 11.13} + + - en_name: Premium + uk_name: Преміум + priority: 3 + periods: + - {period_start: 1, period_end: 3, usage_amount: 10, price: 11.41} + - {period_start: 4, period_end: 6, usage_amount: 8, price: 12.59} + - {period_start: 7, period_end: 9, usage_amount: 6, price: 14.18} + - {period_start: 10, period_end: 12, usage_amount: 6, price: 18.52} + - {period_start: 13, period_end: 18, usage_amount: 4, price: 18.52} + - {period_start: 19, period_end: 24, usage_amount: 4, price: 18.62} + - {period_start: 25, period_end: 30, usage_amount: 2, price: 18.62} \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index e3d78a3de..4719c18c8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -32,45 +32,18 @@ FactoryBot.create(:product, :diaper) unless Product.exists?(title: "diaper") # Categories -def create_category_with_periods(en_name, uk_name, periods) - unless Category.exists?(en_name: en_name) - category = Category.create!(en_name: en_name, uk_name: uk_name) +categories_data = YAML.load_file(Rails.root.join("db", "data", "categories.yml")) - periods.each do |period_data| - DiapersPeriod.create!(period_data.merge(category: category)) - end - end -end - -# Budgetary category periods -create_category_with_periods("Budgetary", "Бюджетна", [ - { period_start: 1, period_end: 3, usage_amount: 10, price: 5.96 }, - { period_start: 4, period_end: 6, usage_amount: 8, price: 6.35 }, - { period_start: 7, period_end: 9, usage_amount: 6, price: 6.35 }, - { period_start: 10, period_end: 12, usage_amount: 6, price: 6.45 }, - { period_start: 13, period_end: 18, usage_amount: 4, price: 6.45 }, - { period_start: 19, period_end: 24, usage_amount: 4, price: 7.6 }, - { period_start: 25, period_end: 30, usage_amount: 2, price: 7.6 } -]) +def create_category_with_periods(*args) + en_name, uk_name, priority, periods = args + return if Category.exists?(en_name: en_name) -# Medium category periods -create_category_with_periods("Medium", "Середня", [ - { period_start: 1, period_end: 3, usage_amount: 10, price: 8.03 }, - { period_start: 4, period_end: 6, usage_amount: 8, price: 8.33 }, - { period_start: 7, period_end: 9, usage_amount: 6, price: 8.65 }, - { period_start: 10, period_end: 12, usage_amount: 6, price: 10.07 }, - { period_start: 13, period_end: 18, usage_amount: 4, price: 10.07 }, - { period_start: 19, period_end: 24, usage_amount: 4, price: 11.13 }, - { period_start: 25, period_end: 30, usage_amount: 2, price: 11.13 } -]) + category = Category.create!(en_name:, uk_name:, priority:) + periods.each { |period| DiapersPeriod.create!(period.merge(category:)) } +end -# Premium category periods -create_category_with_periods("Premium", "Преміум", [ - { period_start: 1, period_end: 3, usage_amount: 10, price: 11.41 }, - { period_start: 4, period_end: 6, usage_amount: 8, price: 12.59 }, - { period_start: 7, period_end: 9, usage_amount: 6, price: 14.18 }, - { period_start: 10, period_end: 12, usage_amount: 6, price: 18.52 }, - { period_start: 13, period_end: 18, usage_amount: 4, price: 18.52 }, - { period_start: 19, period_end: 24, usage_amount: 4, price: 18.62 }, - { period_start: 25, period_end: 30, usage_amount: 2, price: 18.62 } -]) +categories_data["categories"].each do |category_data| + create_category_with_periods( + *category_data.slice("en_name", "uk_name", "priority", "periods").values + ) +end From 02f38d7a12686bd50cdeaf2a2230bd6ca1fd54eb Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 13:57:43 +0200 Subject: [PATCH 09/33] updates spaces in yaml file --- db/data/categories.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/data/categories.yml b/db/data/categories.yml index 8c845fa64..d392be94c 100644 --- a/db/data/categories.yml +++ b/db/data/categories.yml @@ -33,4 +33,4 @@ categories: - {period_start: 10, period_end: 12, usage_amount: 6, price: 18.52} - {period_start: 13, period_end: 18, usage_amount: 4, price: 18.52} - {period_start: 19, period_end: 24, usage_amount: 4, price: 18.62} - - {period_start: 25, period_end: 30, usage_amount: 2, price: 18.62} \ No newline at end of file + - {period_start: 25, period_end: 30, usage_amount: 2, price: 18.62} From aec0e74972701465209bca2e460b4fc5f5326c60 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 8 Nov 2024 14:36:39 +0200 Subject: [PATCH 10/33] updated seeds --- db/seeds.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 4719c18c8..5c502c8c7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -33,13 +33,12 @@ # Categories categories_data = YAML.load_file(Rails.root.join("db", "data", "categories.yml")) - def create_category_with_periods(*args) en_name, uk_name, priority, periods = args return if Category.exists?(en_name: en_name) - category = Category.create!(en_name:, uk_name:, priority:) - periods.each { |period| DiapersPeriod.create!(period.merge(category:)) } + category = Category.create!(en_name: en_name, uk_name: uk_name, priority: priority) + periods.each { |period| DiapersPeriod.create!(period.merge(category: category)) } end categories_data["categories"].each do |category_data| From 9d84572f18684e6c87387c46f5fd88be6d2f06a4 Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:31:59 +0200 Subject: [PATCH 11/33] 931 fix selflock bug (#937) * closes #931-fix-selflock-bug * added validation in controller and test * added request test * before_action added * Update app/controllers/account/users_controller.rb Co-authored-by: Ivan Marynych <49816584+loqimean@users.noreply.github.com> * guard style return * Update app/controllers/account/users_controller.rb Co-authored-by: Ivan Marynych <49816584+loqimean@users.noreply.github.com> * Update users_controller.rb * dig * Update users_controller.rb * Update users_controller.rb * Update users_controller.rb --------- Co-authored-by: Ivan Marynych <49816584+loqimean@users.noreply.github.com> --- app/controllers/account/users_controller.rb | 11 +++++++++ app/views/account/users/index.html.erb | 10 +++++--- config/locales/en/en.yml | 1 + config/locales/uk/uk.yml | 1 + spec/features/account/users_spec.rb | 13 ++++++++++ spec/requests/account/users_spec.rb | 27 +++++++++++++++++++++ 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/app/controllers/account/users_controller.rb b/app/controllers/account/users_controller.rb index e36afe64d..4fc589e74 100644 --- a/app/controllers/account/users_controller.rb +++ b/app/controllers/account/users_controller.rb @@ -6,6 +6,7 @@ class Account::UsersController < Account::BaseController layout "account" before_action :set_paper_trail_whodunnit + before_action :blocking_admin, only: :update load_and_authorize_resource @@ -71,6 +72,16 @@ def user_params prms end + def blocking_admin + @user = resource + + return if params.dig(:user, :blocked).blank? || !@user.admin? + + flash[:alert] = t("errors.messages.blocked_user_cannot_be_admin") + + redirect_to account_users_path + end + def collection User.ordered_by_email end diff --git a/app/views/account/users/index.html.erb b/app/views/account/users/index.html.erb index 588018bc4..77d2448f3 100644 --- a/app/views/account/users/index.html.erb +++ b/app/views/account/users/index.html.erb @@ -38,10 +38,12 @@ <%= link_to icon("fa-solid", "eye"), account_user_path(id: user.id) %> <%= link_to icon("fa-solid", "edit"), edit_account_user_path(id: user.id) %> - <%= button_to account_user_path(id: user, user: toggle_block_param(user)), - method: :patch, - data: { turbo_confirm: toggle_confirm(user) } do %> - <%= icon("fa-solid", toggle_class(user)) %> + <% unless user.admin? %> + <%= button_to account_user_path(id: user, user: toggle_block_param(user)), + method: :patch, + data: { turbo_confirm: toggle_confirm(user) } do %> + <%= icon("fa-solid", toggle_class(user)) %> + <% end %> <% end %> diff --git a/config/locales/en/en.yml b/config/locales/en/en.yml index a1950fcbb..00f2143e6 100644 --- a/config/locales/en/en.yml +++ b/config/locales/en/en.yml @@ -822,6 +822,7 @@ en: messages: accepted: "must be accepted" blank: "can't be blank" + blocked_user_cannot_be_admin: "Admin cannot be blocked" confirmation: "doesn't match %{attribute}" empty: "can't be empty" equal_to: "must be equal to %{count}" diff --git a/config/locales/uk/uk.yml b/config/locales/uk/uk.yml index 67f265a04..c77646f31 100644 --- a/config/locales/uk/uk.yml +++ b/config/locales/uk/uk.yml @@ -846,6 +846,7 @@ uk: messages: accepted: "може бути прийнятим" blank: "не може бути порожнім" + blocked_user_cannot_be_admin: "Неможливо заблокувати адміна" confirmation: "не збігається з підтвердженням" empty: "не може бути порожнім" equal_to: "мусить дорівнювати %{count}" diff --git a/spec/features/account/users_spec.rb b/spec/features/account/users_spec.rb index 4ba06de8a..36ce41d8f 100644 --- a/spec/features/account/users_spec.rb +++ b/spec/features/account/users_spec.rb @@ -8,6 +8,7 @@ create(:user, email: "test1@gmail.com", password: "12345878", last_sign_in_at: time_login) end + let!(:admin_user) { create(:user, role: :admin) } include_context :authorize_admin @@ -63,6 +64,7 @@ end accept_confirm { "Are you sure you want to block this user?" } + sleep 3 expect(page).to have_current_path(account_user_path(id: another_user.id)) expect(page).to have_content "Blocked" end @@ -79,11 +81,22 @@ end accept_confirm { "Are you sure you want to unblock this user?" } + sleep 3 expect(page).to have_current_path(account_user_path(id: another_user.id)) expect(page).to have_content "Unblocked" end end + context "when trying to block an admin user" do + it "shows an alert message and redirects to account users path" do + visit account_users_path + + within(:css, "#user-info-#{admin_user.id}") do + expect(page).not_to have_selector("svg.fa-lock-open") # Expect the lock-open button not to be present + end + end + end + context "when edit user`s info correctly" do it "redirects to user info page" do visit edit_account_user_path(id: another_user.id) diff --git a/spec/requests/account/users_spec.rb b/spec/requests/account/users_spec.rb index 2bda4e4e8..05f2afa50 100644 --- a/spec/requests/account/users_spec.rb +++ b/spec/requests/account/users_spec.rb @@ -6,6 +6,7 @@ include_context :authorize_admin let!(:user) { create(:user, last_sign_in_at: Time.current) } + let!(:admin_user) { create(:user, role: :admin) } describe "GET #index" do let(:csv_content) do @@ -117,6 +118,32 @@ end end + describe "PATCH /account/users/:id" do + context "when trying to block an admin user" do + it "sets an alert message and redirects to the admin user account page" do + patch account_user_path(admin_user), params: { user: { blocked: true }} + + expect(response).to redirect_to(account_users_path) + + follow_redirect! + + expect(flash[:alert]).to eq I18n.t("errors.messages.blocked_user_cannot_be_admin") + expect(response.body).to include(I18n.t("errors.messages.blocked_user_cannot_be_admin")) + end + end + + context "when trying to block a non-admin user" do + it "blocks the user successfully" do + patch account_user_path(user), params: { user: { blocked: true }} + + expect(response).to redirect_to(account_user_path(user)) + + follow_redirect! + expect(user.reload.blocked).to be_truthy + end + end + end + describe "DELETE #destroy" do it "destroys the user and redirects to index page" do expect do From 5b84f4da7de2b2307c912d0345a12b64b6218305 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Thu, 14 Nov 2024 19:19:08 +0200 Subject: [PATCH 12/33] updated yml file --- db/data/categories.yml | 105 ++++++++++++++++++++++++++++++++--------- db/seeds.rb | 16 +++---- 2 files changed, 90 insertions(+), 31 deletions(-) diff --git a/db/data/categories.yml b/db/data/categories.yml index d392be94c..c1f24f8ff 100644 --- a/db/data/categories.yml +++ b/db/data/categories.yml @@ -3,34 +3,97 @@ categories: uk_name: Бюджетна priority: 1 periods: - - {period_start: 1, period_end: 3, usage_amount: 10, price: 5.96} - - {period_start: 4, period_end: 6, usage_amount: 8, price: 6.35} - - {period_start: 7, period_end: 9, usage_amount: 6, price: 6.35} - - {period_start: 10, period_end: 12, usage_amount: 6, price: 6.45} - - {period_start: 13, period_end: 18, usage_amount: 4, price: 6.45} - - {period_start: 19, period_end: 24, usage_amount: 4, price: 7.6} - - {period_start: 25, period_end: 30, usage_amount: 2, price: 7.6} + - period_start: 1 + period_end: 3 + usage_amount: 10 + price: 5.96 + - period_start: 4 + period_end: 6 + usage_amount: 8 + price: 6.35 + - period_start: 7 + period_end: 9 + usage_amount: 6 + price: 6.35 + - period_start: 10 + period_end: 12 + usage_amount: 6 + price: 6.45 + - period_start: 13 + period_end: 18 + usage_amount: 4 + price: 6.45 + - period_start: 19 + period_end: 24 + usage_amount: 4 + price: 7.6 + - period_start: 25 + period_end: 30 + usage_amount: 2 + price: 7.6 - en_name: Medium uk_name: Середня priority: 2 periods: - - {period_start: 1, period_end: 3, usage_amount: 10, price: 8.03} - - {period_start: 4, period_end: 6, usage_amount: 8, price: 8.33} - - {period_start: 7, period_end: 9, usage_amount: 6, price: 8.65} - - {period_start: 10, period_end: 12, usage_amount: 6, price: 10.07} - - {period_start: 13, period_end: 18, usage_amount: 4, price: 10.07} - - {period_start: 19, period_end: 24, usage_amount: 4, price: 11.13} - - {period_start: 25, period_end: 30, usage_amount: 2, price: 11.13} + - period_start: 1 + period_end: 3 + usage_amount: 10 + price: 8.03 + - period_start: 4 + period_end: 6 + usage_amount: 8 + price: 8.33 + - period_start: 7 + period_end: 9 + usage_amount: 6 + price: 8.65 + - period_start: 10 + period_end: 12 + usage_amount: 6 + price: 10.07 + - period_start: 13 + period_end: 18 + usage_amount: 4 + price: 10.07 + - period_start: 19 + period_end: 24 + usage_amount: 4 + price: 11.13 + - period_start: 25 + period_end: 30 + usage_amount: 2 + price: 11.13 - en_name: Premium uk_name: Преміум priority: 3 periods: - - {period_start: 1, period_end: 3, usage_amount: 10, price: 11.41} - - {period_start: 4, period_end: 6, usage_amount: 8, price: 12.59} - - {period_start: 7, period_end: 9, usage_amount: 6, price: 14.18} - - {period_start: 10, period_end: 12, usage_amount: 6, price: 18.52} - - {period_start: 13, period_end: 18, usage_amount: 4, price: 18.52} - - {period_start: 19, period_end: 24, usage_amount: 4, price: 18.62} - - {period_start: 25, period_end: 30, usage_amount: 2, price: 18.62} + - period_start: 1 + period_end: 3 + usage_amount: 10 + price: 11.41 + - period_start: 4 + period_end: 6 + usage_amount: 8 + price: 12.59 + - period_start: 7 + period_end: 9 + usage_amount: 6 + price: 14.18 + - period_start: 10 + period_end: 12 + usage_amount: 6 + price: 18.52 + - period_start: 13 + period_end: 18 + usage_amount: 4 + price: 18.52 + - period_start: 19 + period_end: 24 + usage_amount: 4 + price: 18.62 + - period_start: 25 + period_end: 30 + usage_amount: 2 + price: 18.62 \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 5c502c8c7..39c27156f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -31,18 +31,14 @@ FactoryBot.create(:product, :diaper) unless Product.exists?(title: "diaper") -# Categories categories_data = YAML.load_file(Rails.root.join("db", "data", "categories.yml")) -def create_category_with_periods(*args) - en_name, uk_name, priority, periods = args + +categories_data["categories"].each do |category_data| return if Category.exists?(en_name: en_name) - category = Category.create!(en_name: en_name, uk_name: uk_name, priority: priority) - periods.each { |period| DiapersPeriod.create!(period.merge(category: category)) } -end + category = Category.create!(category_data.slice("en_name", "uk_name", "priority")) -categories_data["categories"].each do |category_data| - create_category_with_periods( - *category_data.slice("en_name", "uk_name", "priority", "periods").values - ) + period_records = category_data["periods"].map { |period_data| period_data.merge("category_id" => category.id) } + + DiapersPeriod.insert_all(period_records) end From 03b2931074c08aae3758fcbe27ff48855f4c2044 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 15 Nov 2024 00:00:53 +0200 Subject: [PATCH 13/33] changed seeds for categories --- db/seeds.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 39c27156f..10c85e359 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -31,14 +31,15 @@ FactoryBot.create(:product, :diaper) unless Product.exists?(title: "diaper") +# Categories categories_data = YAML.load_file(Rails.root.join("db", "data", "categories.yml")) categories_data["categories"].each do |category_data| - return if Category.exists?(en_name: en_name) + next if Category.exists?(en_name: category_data["en_name"]) - category = Category.create!(category_data.slice("en_name", "uk_name", "priority")) + periods = category_data.delete("periods") + category = Category.create!(**category_data) - period_records = category_data["periods"].map { |period_data| period_data.merge("category_id" => category.id) } - - DiapersPeriod.insert_all(period_records) + periods.map! { |period_data| period_data.merge(category_id: category.id) } + periods.each { |period_data| DiapersPeriod.create!(**period_data) } end From c135b4730f7586bf87b24b39311daab741283b52 Mon Sep 17 00:00:00 2001 From: alexy78 Date: Fri, 15 Nov 2024 00:05:12 +0200 Subject: [PATCH 14/33] added extra space to yml file --- db/data/categories.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/data/categories.yml b/db/data/categories.yml index c1f24f8ff..c939cf1b1 100644 --- a/db/data/categories.yml +++ b/db/data/categories.yml @@ -96,4 +96,4 @@ categories: - period_start: 25 period_end: 30 usage_amount: 2 - price: 18.62 \ No newline at end of file + price: 18.62 From e974077de2007cd3139f0f1e8a5f2513997b7fa8 Mon Sep 17 00:00:00 2001 From: SleekMutt <84468904+SleekMutt@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:01:42 +0200 Subject: [PATCH 15/33] 910 Created menstrual hygiene products calculator (#924) * Created menstrual hygiene calculator. Created corresponding to it view, api controller, service and validator. Also added new corresponding action to render mhc calculator to calculators controller. * Fixed link and rubocop offences * Updated rubocop target version and extracted methods in pad usage service * Deleted redundant skip * Added tests for api controller * Fixed some files * Removed redundant code from controllers action * Added smooth scroll * Fixed localization with links * Fixed rubocops target version * Fixed typo * Fixed CI * Refactored code for a better style * Added tests for validator * Fixed offenses * Added tests for each of the validate param method * Retrieved shared example to separate file * Added before hook for blank param --------- Co-authored-by: Ivan Marynych <49816584+loqimean@users.noreply.github.com> Co-authored-by: loqimean --- .rubocop.yml | 2 +- app/assets/images/pad_scales.png | Bin 0 -> 23169 bytes app/assets/images/pads_bought.png | Bin 0 -> 4761 bytes app/assets/images/pads_to_buy.png | Bin 0 -> 5005 bytes .../api/v1/pad_calculators_controller.rb | 20 ++++ app/controllers/calculators_controller.rb | 5 + app/helpers/calculators_helper.rb | 9 ++ .../controllers/mhc_calculator_controller.js | 71 +++++++++++++ .../controllers/pad_results_controller.js | 21 ++++ app/services/calculators/pad_usage_service.rb | 52 ++++++++++ app/validators/mhc_calculator_validator.rb | 55 +++++++++++ app/views/calculators/mhc_calculator.erb | 93 ++++++++++++++++++ .../layouts/_mhc_description_block.html.erb | 14 +++ config/locales/en/en.yml | 43 ++++++-- config/locales/uk/uk.yml | 43 ++++++-- config/routes.rb | 3 + spec/features/account/users_spec.rb | 2 +- spec/requests/calculators_spec.rb | 10 ++ spec/requests/pad_calculators_spec.rb | 45 +++++++++ .../calculators/pad_usage_service_spec.rb | 29 ++++++ .../shared/presence_validation_example.rb | 17 ++++ .../mhc_calculator_validator_spec.rb | 65 ++++++++++++ 22 files changed, 577 insertions(+), 22 deletions(-) create mode 100644 app/assets/images/pad_scales.png create mode 100644 app/assets/images/pads_bought.png create mode 100644 app/assets/images/pads_to_buy.png create mode 100644 app/controllers/api/v1/pad_calculators_controller.rb create mode 100644 app/javascript/controllers/mhc_calculator_controller.js create mode 100644 app/javascript/controllers/pad_results_controller.js create mode 100644 app/services/calculators/pad_usage_service.rb create mode 100644 app/validators/mhc_calculator_validator.rb create mode 100644 app/views/calculators/mhc_calculator.erb create mode 100644 app/views/layouts/_mhc_description_block.html.erb create mode 100644 spec/requests/pad_calculators_spec.rb create mode 100644 spec/services/calculators/pad_usage_service_spec.rb create mode 100644 spec/support/shared/presence_validation_example.rb create mode 100644 spec/validators/mhc_calculator_validator_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 51dec8a54..0d435ded4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,7 +18,7 @@ inherit_gem: AllCops: SuggestExtensions: true NewCops: enable - TargetRubyVersion: 3.0.6 + TargetRubyVersion: 3.2 Layout/SpaceInsideHashLiteralBraces: Enabled: true diff --git a/app/assets/images/pad_scales.png b/app/assets/images/pad_scales.png new file mode 100644 index 0000000000000000000000000000000000000000..bae34308887bc2059324a671555d0653f70ccbfd GIT binary patch literal 23169 zcmeFZRa70@w*EVDn7D`F7Tnz>A-KD1aCd^cLy$0W2%6yTPH=a3c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=U~-GJ5@ZZxN&^@LRTu=7*7$&Jv%t`(-_Ts2A8v;O&R>PjxeAUs>eD?pd-p z$KYCf@4Ox|YV_LGfi1E!BjWy{U(s<52~WCdjjBx6_u>Oqm+gxsMX|%rnWp3)CFVF5 z$xR*$`Wg3p?5qbV@7lX2DfPmeSUkaUQyBLct1@nW!S4k1@{|xzA7#HQaY~-)XfZy3 zed}x=$`Gp<5uH*g8B$nLV-RssF-vZs6gNwcYd72x&g_JzLKo zkw(YR4AFFQ&+^CMIta7Gdo7~JqD+OH`2x)269poTPdCme<TX(5M+S~M+OU8`jSRiHP-MPaGN%2{X^iZ33}Yr>?-dqk>yFJ ztM!Yxyh|QqiGRvPhfh28KZ!G5ZV;pYRv)E+on2{NQtClAuC5<(s$}3dk!r}<9t3G) zD&tpFR*ea;rSf1kGDpF2_+Yt6jJkT8Ip`wykH2J}-Nhe*j92u>O(!RIDDQe=lZVrM z>NOMRwZ*_(0eh5vJm0iL{mUPLC$2wfrDej=g!o9XL^mAWy7*wR8V?b=c44MRxLga&yAILR<;D|_ket95VO;Q+ zZhj^C^N0a=-;x#QL}+kJoIBbMbfu-Y>>#i+VIuk}ZgVMT8o8dYw;G2bTH3EV zkC&Bb1E;kqB@Sc@4+|b%gD;uGByNK`rNc{;!%YCHz)Sd(Yg`A8&%I1RfI9j&^?0~s zGq`&kV29a727urI>-sVw?A)Krl31_~O=R8Cpb1FllmRn4jCF4B&n1x?yxsr)_`gEc ayLX>r4wl5D9=bDtpRvA$-g6yS!v6uzY>xu~ literal 0 HcmV?d00001 diff --git a/app/assets/images/pads_bought.png b/app/assets/images/pads_bought.png new file mode 100644 index 0000000000000000000000000000000000000000..7a864b55a8b355eddb94bb6ca41a78100054f907 GIT binary patch literal 4761 zcmV;K5@zj*P)Px{Q%OWYRCr$9U3+j`)p`HUz1NagYdtL4#>RsBfwYo|1IEyjHn!HpYNCWDq?u%r zHhs`(O4ERAgG?VGW0Oe}8oz*)0h*)@oe9abe?Wp`QRLv2orF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=m{_dw`u+T{o1*6=k)se`a1yN zAFOZHD+m_zVpLIA_#wRCwxZ)J>MC&^*5CL|f1R;d3~Mpx9ay#^QAIF|+sr<_y}c+N zwaLlJH5C;VhcHtu5=!JQPBgoGlQ@?jea6qTiJ+*COIap6N`j-5($BTDw7fE3!SV%| zlWtqNa^)S2vA;p!M1w?B^71ASxx$P1+kQ^PoF-mEm^W;wP6@v%)N80;47KrFc6L*a*IfO z4kSN8BU*U!1Bh`>uBUR}JNbAflX>X$>C-2dEn7y{ty`DD^xk|2%eP2$(`{B>%}j)* z)9Ez;u-Pz-zt4Sj6@KOKEUpm8lcOlye?lO|uL@Cdq4n8|l+qtfO-((NPN&bNQYqTe z(P4_f-xRPy0gMw}5|eq~t+KL`EM2Ix#UpEuau24iuZuIx94h=z-g?iRlK6j*gN@B!ZzX{8pXXMT-{UcR6p? zG;KX01YhvTzjQl4tfccWY&6OkdkFyWJ2^%#T)1#-dU`rFH8o|j?!}82Sw}|)2g;PV zzX>9+q<~4>#{Zr9>Z2KVzyuEesi>$RhGCe0XEGU+=$T9gfh%xg@f*?+4D5%$RU2jF n#*O&7_%pAZVLOSV`uzU^Y@79#i`g-Z00000NkvXXu0mjfV;Un% literal 0 HcmV?d00001 diff --git a/app/assets/images/pads_to_buy.png b/app/assets/images/pads_to_buy.png new file mode 100644 index 0000000000000000000000000000000000000000..0fcf41cda70e8e3a161c4df2ec15f9990196b105 GIT binary patch literal 5005 zcmV;86LRc{P)Px|M@d9MRCr$9T?=qj*LnW`doOw|LIMHdWtWGgm58y8DV@4CS_vdl61$GuX`4=y zH0d;r-PDAK1Z_=f>|`7#5*X6@)g(>p$vAD&X|NNc7=g7Cu`^SbfbAk7Bs<{vL5Ph6 zLaW#AIn{r)XE}Rx-@AfU?~F#$J?Eas|DFGR&bJX{}ymp!N^QS%h<(4G2c6 zA>>2AwRbqcf1m;T8fv5OJ9UDAMiAhkuCA^cMEtm>X*YAuYXUTp_6Qo zRYfyxZz`T|jz-qP7(4?2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gqa@-g^a$wzV89R9b#qDm}Do@ z&dBgG_N&EJG!_}Gl!%!)(|w?#qT&y79W2wVmx-F>G82zzG>QVWix)4J<>%+OAmS=f z-)b8Hm8nq-E6{wLeDs33r#kXtGbf%D>*F8rIWaOavVPU7RrJ2ZoaU}cfJyqyEFJ}(;od_WL zXr`EKX=%|*OG~w~va(%_G4oB7!sJ(@-F6)3mEb|@$%c^xOzIf0aMpEQ|3-Ov`8HB( z$$B|23Oxa4!EIV+XQy`Y;zfPVoH_Raz~3dms+Sflmb2AY13207m35Uoj^y9;rN4%7 zI81vnryW?fBGGDfO9lz~Y9t=D;o;%sd3kvUDN`*IN(M;~%`V^MN8ibH#d$Uv6szM> zNt2x4GfC?V#= zZwnDk-&%P%kx1-cxpHNKz?u%$pq)wxbfQqvZF);f3nf68<>%+$KmOYEPYV4Z2Y9U< zZ&l}5JttzB0;uG|G3O(IRz;sEV~jm<`SRt5LZQ$F0oHWWSt@XW0JGw@&dyH#{Q2|R z+_`g?8HREH_&dkUoLWj*N*~mbqT*(;EG}iyDo)VI7M?l*InF8c6aYLEkH;T7fByWN z^XJcJD_5?hmvEVe#dPK_-y+dXwL#V+*s_p?o#Hkl&u{|i`I0Zb5G5tC*RnS8hW{Cu1@ zZ{E#`MB-D3csn`Xw(@x*rk4U%h*a6JmP2BQc$9Pg(|A07G#-z43=R&mBv90d0E$m{ zu1b?scEk&EU$!KZ&zo+**|TS{u&|IqUG$R2l9@AS(zl$eHBDQEh}R`KFzw~Qiq503 z(OJ&<>i|ICjgOmkxC3+V&~Jx9N-`dzbT4c(W2roFDRqwoI# XI}cf { + const targetKey = errorKey.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase()); + const feedbackDiv = document.createElement('div'); + + feedbackDiv.className = 'invalid-feedback'; + feedbackDiv.textContent = errors[errorKey]; + + this[`${targetKey}Target`].classList.add("is-invalid"); + this[`${targetKey}Target`].insertAdjacentElement('afterend', feedbackDiv); + }); + } + + clearErrors(){ + this.constructor.targets.forEach(targetKey => { + const targetElement = this[`${targetKey}Target`]; + targetElement.classList.remove("is-invalid"); + + const feedbackDiv = targetElement.nextElementSibling; + if (feedbackDiv && feedbackDiv.classList.contains('invalid-feedback')) { + feedbackDiv.remove(); + } + }); + } +} diff --git a/app/javascript/controllers/pad_results_controller.js b/app/javascript/controllers/pad_results_controller.js new file mode 100644 index 000000000..a998666df --- /dev/null +++ b/app/javascript/controllers/pad_results_controller.js @@ -0,0 +1,21 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + static targets = [ + "padsUsed", + "padsToBeUsed", + "moneySpent", + "moneyWillBeSpent" + ]; + + showResults(data) { + let result = data; + + this.moneySpentTarget.innerHTML = Math.ceil(result.already_used_products_cost); + this.moneyWillBeSpentTarget.innerHTML = Math.ceil(result.products_to_be_used_cost); + this.padsUsedTarget.innerHTML = Math.ceil(result.already_used_products); + this.padsToBeUsedTarget.innerHTML = Math.ceil(result.products_to_be_used); + + this.element.scrollIntoView({ behavior: "smooth" }); + } +} diff --git a/app/services/calculators/pad_usage_service.rb b/app/services/calculators/pad_usage_service.rb new file mode 100644 index 000000000..5de628434 --- /dev/null +++ b/app/services/calculators/pad_usage_service.rb @@ -0,0 +1,52 @@ +class Calculators::PadUsageService + attr_accessor :user_age, :menstruation_age, :menopause_age, + :average_menstruation_cycle_duration, + :pads_per_cycle, :pad_category + + PAD_PRICES = { + budget: 2, + average: 4, + premium: 7 + } + + def initialize(user_age:, menstruation_age:, menopause_age:, average_menstruation_cycle_duration:, + pads_per_cycle:, pad_category:) + @user_age = user_age + @menstruation_age = menstruation_age + @menopause_age = menopause_age || 48.7 + @average_menstruation_cycle_duration = average_menstruation_cycle_duration + @pads_per_cycle = pads_per_cycle + @pad_category = (pad_category || :budget).to_sym + end + + def calculate + { + already_used_products:, + already_used_products_cost:, + products_to_be_used:, + products_to_be_used_cost: + } + end + + private + + def already_used_products + menstruations_from_age_range(menstruation_age, user_age) * pads_per_cycle + end + + def products_to_be_used + menstruations_from_age_range(user_age, menopause_age) * pads_per_cycle + end + + def already_used_products_cost + already_used_products * PAD_PRICES[pad_category] + end + + def products_to_be_used_cost + products_to_be_used * PAD_PRICES[pad_category] + end + + def menstruations_from_age_range(from_age, till_age) + (till_age - from_age) * (365 / average_menstruation_cycle_duration) + end +end diff --git a/app/validators/mhc_calculator_validator.rb b/app/validators/mhc_calculator_validator.rb new file mode 100644 index 000000000..cd5e21bfe --- /dev/null +++ b/app/validators/mhc_calculator_validator.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +class MhcCalculatorValidator + attr_reader :params, :errors + + def initialize(params) + @params = params + @errors = {} + end + + def valid? + validate_user_age + validate_menstruation_age + validate_menopause_age + validate_average_menstruation_cycle_duration + validate_pads_per_cycle + validate_pad_category + + errors.empty? + end + + private + + def validate_user_age + presence_valid?(:user_age) + end + + def validate_menstruation_age + presence_valid?(:menstruation_age) + end + + def validate_menopause_age + presence_valid?(:menopause_age) + end + + def validate_average_menstruation_cycle_duration + presence_valid?(:average_menstruation_cycle_duration) + end + + def validate_pads_per_cycle + presence_valid?(:pads_per_cycle) + end + + def validate_pad_category + presence_valid?(:pad_category) + end + + def presence_valid?(param) + return true if @params[param].present? + + @errors[param] = I18n.t("calculators.errors.presence_error_msg", field: I18n.t("calculators.mhc_calculator.form.#{param}")) + + false + end +end diff --git a/app/views/calculators/mhc_calculator.erb b/app/views/calculators/mhc_calculator.erb new file mode 100644 index 000000000..16cd4d748 --- /dev/null +++ b/app/views/calculators/mhc_calculator.erb @@ -0,0 +1,93 @@ +

+

<%= t(".calculator_name") %>

+
+ <%= simple_form_for(:pad, url: "#", html: { class: "simple_form_calculator", + data: { controller: "mhc-calculator", + mhc_calculator_url_value: api_v1_pad_calculators_url, + mhc_calculator_pad_results_outlet: ".result" } }) do |form| %> +
+ +
+ <%= label_tag "child_product_category", t(".form.user_age") %> +
+ + <%= form.input_field :user_age, + type: "number", + class: "form_fild price_select rounded w-100 form-control mb-0", + data: { mhc_calculator_target: "userAge" } %> + +
+ <%= label_tag "child_product_category", t(".form.menstruation_age") %> +
+ + <%= form.input_field :menstruation_age, + type: "number", + class: "form_fild price_select rounded w-100 form-control mb-0 ", + data: { mhc_calculator_target: "menstruationAge" } %> + +
+ <%= label_tag "child_product_category", t(".form.menopause_age") %> +
+ + <%= form.input_field :menopause_age, + type: "number", + class: "form_fild price_select rounded w-100 form-control mb-0", + data: { mhc_calculator_target: "menopauseAge" } %> + +
+ <%= label_tag "child_product_category", t(".form.average_menstruation_cycle_duration") %> +
+ + <%= form.input_field :average_menstruation_cycle_duration, + type: "number", + class: "form_fild price_select rounded w-100 form-control mb-0", + data: { mhc_calculator_target: "averageMenstruationCycleDuration" } %> + +
+ <%= label_tag "child_product_category", t(".form.pads_per_cycle") %> +
+ + <%= form.input_field :pads_per_cycle, + type: "number", + class: "form_fild price_select rounded w-100 form-control mb-0", + data: { mhc_calculator_target: "padsPerCycle" } %> + +
+ <%= label_tag "child_product_category", t(".form.pad_category") %> +
+ + <%= form.input_field :product_category, + collection: [[t(".form.budgetary"), :budget], [t(".form.average"), :average], [t(".form.premium"), :premium]], + selected: "Budget", + class: "form_fild price_select rounded w-100 form-control mb-0", + data: { mhc_calculator_target: "padCategory" } %> + + <%= form.submit t("calculators.buttons.calculate"), + class: "calculate-btn result-btn mt-6", + data: { action: "mhc-calculator#submit" } %> +
+ <% end %> + + <%= image_tag "pad_scales.png", class: "scales_img", alt: "Scales" %> +
+
+ +
+ <% mhc_calculator_items.each do |item| %> + <% if item == "arrow" %> +
+ <%= image_tag "icons/vector_5.png", class: "vector", alt: "horizontal arrow" %> + <%= image_tag "icons/vector_2.png", class: "vector-mobile", alt: "vertical arrow" %> +
+ <% else %> +
+ <%= image_tag item[:image], class: "img-margin", alt: "icon" %> +

0

+

<%= item[:unit] %>

+

<%= item[:text] %>

+
+ <% end %> + <% end %> +
+ +<%= render "layouts/mhc_description_block" %> diff --git a/app/views/layouts/_mhc_description_block.html.erb b/app/views/layouts/_mhc_description_block.html.erb new file mode 100644 index 000000000..51d89f1b9 --- /dev/null +++ b/app/views/layouts/_mhc_description_block.html.erb @@ -0,0 +1,14 @@ +
+
+
+

+ <%= t(".mhc_description_block_html", + information_link: link_to_external(text: t(".information_link_text"), url: t(".information_link") , class: 'description-link'), + contact_link: link_to_external(text: t(".contact_link_text"), url: t(".contact_link"), class: 'description-link')) %> +

+
+
+ <%= link_to_external(text: t('.use_less'), url: t(".use_less_link"), class: 'action-button btn-green') %> +
+
+
diff --git a/config/locales/en/en.yml b/config/locales/en/en.yml index 00f2143e6..4a624b943 100644 --- a/config/locales/en/en.yml +++ b/config/locales/en/en.yml @@ -52,6 +52,24 @@ en: calculators: index: meta-title: "Calculators" + mhc_calculator: + calculator_name: "Menstrual hygiene products calculator" + form: + user_age: "Your age" + menstruation_age: "Age at First Menstruation" + menopause_age: "Age at Menopause" + average_menstruation_cycle_duration: "Average Menstrual Cycle Duration (days)" + pads_per_cycle: "Average Products Used Per Cycle" + pad_category: "Product Category" + budgetary: "Budgetary" + average: "Average" + premium: "Premium" + bought_products: "already used" + will_buy_products: "to be used in the future" + money_spent: "already spent on menstrual hygiene products" + money_will_be_spent: "yet to be spent on menstrual hygiene products" + pieces: "pcs." + unit: "uah" new_calculator: diaper_сalculator: "Diaper calculator" form: @@ -81,6 +99,7 @@ en: year_and_month_error_msg: "Please, select years and months" year_error_msg: "Please, select years" month_error_msg: "Please, select month" + presence_error_msg: "%{field} is missing" show: welcome_header: "Welcome to ZeroWaste" buttons: @@ -127,6 +146,20 @@ en: method_link: https://zerowastelviv.org.ua/diaper-calculator-method-en/ contact_link: https://zerowastelviv.org.ua/contacts/ use_less_link: https://zerowastelviv.org.ua/en/zero-waste-nappies-en/ + mhc_description_block: + mhc_description_block_html: + "These data are approximate, and exact values may vary depending on your individual needs and habits. + Using reusable menstrual products can significantly reduce waste and serve as a cost-effective alternative to disposable options. + You can optimize the use of these products at any stage, which will help lower expenses and increase comfort. + We recommend exploring methods for the effective use of reusable menstrual products and learning about their benefits. + More %{information_link} about the calculations regarding the quantity and cost of these products can be found in our materials + or by %{contact_link} with your questions." + information_link_text: "detailed information" + contact_link_text: "contacting us" + information_link: "https://docs.google.com/document/d/1xu6cch-Ner9OEpU4_TV5suIUsuVcWpgiUuX6QrOgaL4" + contact_link: "https://zerowastelviv.org.ua/en/contacts/" + use_less: "HOW TO USE LESS" + use_less_link: "https://zerowastelviv.org.ua/en/zero-waste-period/" homepage: homepage_title: "Welcome to the diaper calculator" description: @@ -439,12 +472,6 @@ en: update_calculator_button: "Update calculator" new: create_calculator_button: "Create calculator" - show: - confirm_delete: "Are you sure you want to delete this calculator?" - name: "Name" - slug: "Slug" - edit: "Edit" - delete: "Delete" feature_flags: submit_button: "Save" new_calculator_design: @@ -461,9 +488,6 @@ en: email: "Email" password: "Password" shared: - navigation: - donate: "DONATE" - donate_link: "https://zerowastelviv.org.ua/pidtrymaty/" links: forgot_your_password: "Forgot your password?" log_in: "Log In" @@ -822,7 +846,6 @@ en: messages: accepted: "must be accepted" blank: "can't be blank" - blocked_user_cannot_be_admin: "Admin cannot be blocked" confirmation: "doesn't match %{attribute}" empty: "can't be empty" equal_to: "must be equal to %{count}" diff --git a/config/locales/uk/uk.yml b/config/locales/uk/uk.yml index c77646f31..0b52f53aa 100644 --- a/config/locales/uk/uk.yml +++ b/config/locales/uk/uk.yml @@ -21,6 +21,24 @@ uk: calculators: index: meta-title: "Калькулятори" + mhc_calculator: + calculator_name: "Калькулятор менструальних гігієнічних засобів" + form: + user_age: "Ваш вік" + menstruation_age: "Вік початку менструації" + menopause_age: "Вік настання менопаузи" + average_menstruation_cycle_duration: "Середня тривалість менструального циклу (дні)" + pads_per_cycle: "Середня кількість засобів гігієни за цикл" + pad_category: "Категорія засобів гігієни" + budgetary: "Бюджетна" + average: "Середня" + premium: "Преміум" + bought_products: "ви вже використали" + will_buy_products: "ви ще використаєте" + money_spent: "ви вже витратили" + money_will_be_spent: "ви ще витратите" + pieces: "шт." + unit: "грн" new_calculator: diaper_сalculator: "Калькулятор підгузків" form: @@ -58,6 +76,7 @@ uk: year_and_month_error_msg: "Будь ласка, виберіть, скільки років та місяців дитині" year_error_msg: "Будь ласка, виберіть, скільки років дитині" month_error_msg: "Будь ласка, виберіть, скільки місяців дитині" + presence_error_msg: "Поле \"%{field}\" відсутнє" show: welcome_header: "Ласкаво просимо до ZeroWaste" calculate_result_button: "Pозрахувати" @@ -109,6 +128,20 @@ uk: method_link: "https://zerowastelviv.org.ua/diaper-calculator-method/" contact_link: "https://zerowastelviv.org.ua/kontakty/" use_less_link: "https://zerowastelviv.org.ua/zero-waste-nappies/" + mhc_description_block: + mhc_description_block_html: + "Ці дані є орієнтовними, і точні значення можуть варіюватися залежно від ваших індивідуальних потреб та звичок. + Використання багаторазових менструальних засобів може значно зменшити кількість відходів і стати економічно + вигідною альтернативою одноразовим продуктам. Ви можете оптимізувати використання цих засобів на будь-якому етапі, + що дозволить знизити витрати та підвищити комфорт. Ми рекомендуємо ознайомитися з методами ефективного використання + багаторазових менструальних продуктів та їх перевагами. Більш %{information_link} про розрахунки кількості та вартості + цих продуктів можна знайти в наших матеріалах або звернувшись %{contact_link} з вашими питаннями." + information_link_text: "детальну інформацію" + contact_link_text: "до нас" + information_link: "https://docs.google.com/document/d/1xu6cch-Ner9OEpU4_TV5suIUsuVcWpgiUuX6QrOgaL4" + contact_link: "https://zerowastelviv.org.ua/kontakty/" + use_less: "ЯК ЗМЕНШИТИ ВИКОРИСТАННЯ" + use_less_link: "https://zerowastelviv.org.ua/reuse-zero-waste-menstruatsii/" homepage: homepage_title: "Вас вітає калькулятор підгузків" description: "Цей калькулятор дає змогу порахувати, скільки одноразових підгузків ваша дитина вже використала та ще використає до того часу, як перейде на звичайну білизну. А також визначити вартість уже куплених підгузків та суму, яку ви витратите на них у майбутньому." @@ -326,12 +359,6 @@ uk: prohibited_to_update: " перешкоджають оновленню калькулятора" prohibited_to_save: " перешкоджають збереженню калькулятора" error: "помилки" - show: - confirm_delete: "Ви впевнені, що хочете видалити цей калькулятор?" - name: "Назва" - slug: "Шлях" - edit: "Редагувати" - delete: "Видалити" site_settings: edit: meta-title: "Налаштування сайту" @@ -421,9 +448,6 @@ uk: email: "Електронна пошта" password: "Пароль" shared: - navigation: - donate: "Підтримати" - donate_link: "https://zerowastelviv.org.ua/pidtrymaty/" links: forgot_your_password: "Забули пароль?" log_in: "Увійти" @@ -846,7 +870,6 @@ uk: messages: accepted: "може бути прийнятим" blank: "не може бути порожнім" - blocked_user_cannot_be_admin: "Неможливо заблокувати адміна" confirmation: "не збігається з підтвердженням" empty: "не може бути порожнім" equal_to: "мусить дорівнювати %{count}" diff --git a/config/routes.rb b/config/routes.rb index 7de991fc5..c4ef467b8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,7 @@ get "/sitemap", to: "sitemap#index" get "/calculator", to: "calculators#calculator" + get "/mhc_calculator", to: "calculators#mhc_calculator" post "/receive_recomendations", to: "calculators#receive_recomendations" get "about-us", to: "home#about", as: "about" @@ -78,6 +79,8 @@ end post "/diaper_calculators", to: "diaper_calculators#calculate" + post "/pad_calculators", + to: "pad_calculators#calculate" end namespace :v2 do resources :calculators, only: [] do diff --git a/spec/features/account/users_spec.rb b/spec/features/account/users_spec.rb index 36ce41d8f..d9c51f171 100644 --- a/spec/features/account/users_spec.rb +++ b/spec/features/account/users_spec.rb @@ -92,7 +92,7 @@ visit account_users_path within(:css, "#user-info-#{admin_user.id}") do - expect(page).not_to have_selector("svg.fa-lock-open") # Expect the lock-open button not to be present + expect(page).to have_no_css("svg.fa-lock-open") # Expect the lock-open button not to be present end end end diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index dacbea773..2be0577e0 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -110,6 +110,16 @@ end end + describe "GET /mhc_calculator" do + it "renders pad calculator" do + get mhc_calculator_path + + expect(response).to be_successful + expect(response).to render_template(:mhc_calculator) + expect(response.body).to include("results") + end + end + describe "POST #create" do include_context :authorize_admin diff --git a/spec/requests/pad_calculators_spec.rb b/spec/requests/pad_calculators_spec.rb new file mode 100644 index 000000000..c2787f9ea --- /dev/null +++ b/spec/requests/pad_calculators_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe Api::V1::PadCalculatorsController, type: :request do + let(:expected_result) do + { + already_used_products: 4420, + already_used_products_cost: 8840, + products_to_be_used: 5460, + products_to_be_used_cost: 10920 + } + end + + let(:valid_params) do + { + user_age: 30, + menstruation_age: 13, + menopause_age: 51, + average_menstruation_cycle_duration: 28, + pads_per_cycle: 20, + pad_category: :budget + } + end + + describe "POST /pad_calculators" do + context "when params are valid" do + it "return expected results" do + post api_v1_pad_calculators_path, params: valid_params, as: :json + + expect(response).to be_successful + expect(response.body).to eq(expected_result.to_json) + end + end + + context "when params are invalid" do + it "return errors" do + post api_v1_pad_calculators_path + + expect(response).to be_unprocessable + expect(JSON.parse(response.body, symbolize_names: true)).to have_key(:errors) + end + end + end +end diff --git a/spec/services/calculators/pad_usage_service_spec.rb b/spec/services/calculators/pad_usage_service_spec.rb new file mode 100644 index 000000000..3948cef44 --- /dev/null +++ b/spec/services/calculators/pad_usage_service_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Calculators::PadUsageService do + describe "#calculate" do + let!(:service) do + described_class.new( + user_age: 30, + menstruation_age: 13, + menopause_age: 51, + pads_per_cycle: 20, + average_menstruation_cycle_duration: 28, + pad_category: :budget + ) + end + + before do + service.calculate + end + + let(:result) { service.calculate } + + it "calculates the correct values" do + expect(result[:already_used_products]).to eq(4_420.0) + expect(result[:already_used_products_cost]).to eq(8_840.0) + expect(result[:products_to_be_used]).to eq(5_460.0) + expect(result[:products_to_be_used_cost]).to eq(10_920.0) + end + end +end diff --git a/spec/support/shared/presence_validation_example.rb b/spec/support/shared/presence_validation_example.rb new file mode 100644 index 000000000..7138d9d5d --- /dev/null +++ b/spec/support/shared/presence_validation_example.rb @@ -0,0 +1,17 @@ +shared_examples "presence validation" do |attribute| + it "#{attribute} is valid when present" do + expect(validator.send(:"validate_#{attribute}")).to be true + expect(validator.errors[attribute]).to be_nil + end + + context "#{attribute} is not present" do + before do + validator.params[attribute] = nil + end + + it "#{attribute} is invalid when blank" do + expect(validator.send(:"validate_#{attribute}")).to be false + expect(validator.errors[attribute]).to eq(I18n.t("#{local_error_prefix}.presence_error_msg", field: I18n.t("#{local_field_prefix}.#{attribute}"))) + end + end +end diff --git a/spec/validators/mhc_calculator_validator_spec.rb b/spec/validators/mhc_calculator_validator_spec.rb new file mode 100644 index 000000000..8c4dc67b8 --- /dev/null +++ b/spec/validators/mhc_calculator_validator_spec.rb @@ -0,0 +1,65 @@ +# spec/validators/mhc_calculator_validator_spec.rb + +require "rails_helper" + +RSpec.describe MhcCalculatorValidator do + let(:valid_params) do + { + user_age: 30, + menstruation_age: 13, + menopause_age: 50, + average_menstruation_cycle_duration: 28, + pads_per_cycle: 10, + pad_category: "budget" + } + end + let!(:validator) { described_class.new(valid_params) } + + let(:local_error_prefix) { "calculators.errors" } + let(:local_field_prefix) { "calculators.mhc_calculator.form" } + + describe "#valid?" do + context "when all parameters are valid" do + it "returns true" do + expect(validator.valid?).to be true + expect(validator.errors).to be_empty + end + end + + context "when some parameter is missing" do + let(:invalid_params_validator) { described_class.new(valid_params.except(:user_age)) } + + it "returns false" do + expect(invalid_params_validator.valid?).to be false + expect(invalid_params_validator.errors).to include(:user_age) + expect(invalid_params_validator.errors[:user_age]).to eq(I18n.t("#{local_error_prefix}.presence_error_msg", field: I18n.t("#{local_field_prefix}.user_age"))) + end + end + end + + describe "individual validations" do + context "user age validation" do + include_examples "presence validation", :user_age + end + + context "menstruation age validation" do + include_examples "presence validation", :menstruation_age + end + + context "menopause age validation" do + include_examples "presence validation", :menopause_age + end + + context "average menstruation cycle duration validation" do + include_examples "presence validation", :average_menstruation_cycle_duration + end + + context "pads per cycle validation" do + include_examples "presence validation", :pads_per_cycle + end + + context "pad category validation" do + include_examples "presence validation", :pad_category + end + end +end From e3ee22d0194f2b85a53a2eda21ed3a3561645a28 Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 14 Nov 2024 12:54:49 +0000 Subject: [PATCH 16/33] add branch --- .github/workflows/ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a13be3851..77129c821 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,16 @@ name: CI on: push: + pull_request: + branches: + - develop + - master + types: + - closed + + release: + types: [published] + jobs: rubocop: runs-on: ubuntu-latest @@ -50,14 +60,14 @@ jobs: with: ruby-version: 3.3.5 bundler-cache: true - + - name: Install system dependencies run: sudo apt-get install -y libvips42 libvips-dev imagemagick - uses: actions/setup-node@v1 with: - node-version: '14.x' - registry-url: 'https://registry.npmjs.org' + node-version: "14.x" + registry-url: "https://registry.npmjs.org" - uses: nanasess/setup-chromedriver@master From bb41c570eb352056725b1e0b9fb56102285ba002 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Tue, 19 Nov 2024 14:56:50 +0200 Subject: [PATCH 17/33] fix refresh newCategory page --- app/views/account/categories/new.html.erb | 18 +++--------------- .../account/categories/new.turbo_stream.erb | 4 ++++ .../categories/partials/new/_form.html.erb | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 app/views/account/categories/new.turbo_stream.erb create mode 100644 app/views/account/categories/partials/new/_form.html.erb diff --git a/app/views/account/categories/new.html.erb b/app/views/account/categories/new.html.erb index f9f6156d6..1bdd33494 100644 --- a/app/views/account/categories/new.html.erb +++ b/app/views/account/categories/new.html.erb @@ -1,15 +1,3 @@ -<%= simple_form_for @category, url: { action: "create" }, html: { novalidate: false } do |f| %> -
-
- <%= f.input :uk_name, class: "form-control col-sm-11" %> - <%= f.input :en_name, class: "form-control col-sm-11" %> - <%= f.input :priority, collection: Category::PRIORITY_RANGE, wrapper: :custom_vertical_select %> -
-
-
- <%= f.submit t(".form.create_category_button"), class: "btn btn-green me-2" %> - <%= link_to account_categories_path, class: "btn btn-danger d-flex align-items-center justify-content-center" do %> - <%= t("buttons.cancel") %> - <% end %> -
-<% end %> +
+ <%= render "account/categories/partials/new/form", category: @category %> +
diff --git a/app/views/account/categories/new.turbo_stream.erb b/app/views/account/categories/new.turbo_stream.erb new file mode 100644 index 000000000..0de8de8e1 --- /dev/null +++ b/app/views/account/categories/new.turbo_stream.erb @@ -0,0 +1,4 @@ +<%= turbo_stream.replace( + dom_id(@category, :form), + partial: "account/categories/partials/new/form", + locals: {category: @category}) %> diff --git a/app/views/account/categories/partials/new/_form.html.erb b/app/views/account/categories/partials/new/_form.html.erb new file mode 100644 index 000000000..f0ad59de7 --- /dev/null +++ b/app/views/account/categories/partials/new/_form.html.erb @@ -0,0 +1,15 @@ +<%= simple_form_for @category, url: { action: "create" }, html: { id: dom_id(category, :form) } do |f| %> +
+
+ <%= f.input :uk_name, class: "form-control col-sm-11" %> + <%= f.input :en_name, class: "form-control col-sm-11" %> + <%= f.input :priority, collection: Category::PRIORITY_RANGE, wrapper: :custom_vertical_select %> +
+
+
+ <%= f.submit t("account.categories.new.form.create_category_button"), class: "btn btn-green me-2" %> + <%= link_to account_categories_path, class: "btn btn-danger d-flex align-items-center justify-content-center" do %> + <%= t("buttons.cancel") %> + <% end %> +
+<% end %> From f00318645322bf2754ab9d347b5098f6070c948e Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 19 Nov 2024 14:04:11 +0000 Subject: [PATCH 18/33] add pipeline --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77129c821..315493d3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,3 +89,39 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} json-path: tmp/rspec_results.json if: always() + + deploy-to-develop: + needs: rspec + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + + - uses: miloserdow/capistrano-deploy@v3 + with: + target: development + deploy_key: ${{ secrets.DEV_DEPLOY_KEY }} + + deploy-to-production: + needs: rspec + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + + - uses: miloserdow/capistrano-deploy@v3 + with: + target: production + deploy_key: ${{ secrets.PROD_DEPLOY_KEY }} From 2eedb174740c20b1f021e3457bea25d44f9d68a0 Mon Sep 17 00:00:00 2001 From: Artem Stepanchenko Date: Tue, 19 Nov 2024 21:16:20 +0200 Subject: [PATCH 19/33] added calculator new specs; fixed controller; --- .../account/calculators_controller.rb | 9 +++- spec/factories/calculators.rb | 3 +- spec/factories/fields.rb | 2 +- spec/requests/account/calculators_spec.rb | 51 +++++++++++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index dec87775d..4a1cd4b6a 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class Account::CalculatorsController < Account::BaseController - before_action :resource, only: [:edit, :update, :destroy] load_and_authorize_resource def index @@ -23,6 +22,8 @@ def new end def edit + @calculator = resource + collect_fields_for_form end @@ -37,6 +38,8 @@ def create end def update + @calculator = resource + if updater redirect_to edit_account_calculator_path(slug: @calculator), notice: t("notifications.calculator_updated") else @@ -47,6 +50,8 @@ def update end def destroy + @calculator = resource + @calculator.destroy redirect_to account_calculators_path, notice: t("notifications.calculator_deleted"), status: :see_other @@ -59,7 +64,7 @@ def collection end def resource - Calculator.find(params[:slug]) + collection.friendly.find(params[:slug]) end def collect_fields_for_form diff --git a/spec/factories/calculators.rb b/spec/factories/calculators.rb index 76607bb4b..8f6db7dc2 100644 --- a/spec/factories/calculators.rb +++ b/spec/factories/calculators.rb @@ -18,7 +18,6 @@ FactoryBot.define do factory :calculator do en_name { "English Calculator" } - uk_name { "Український калькуялтор" } - slug { "calculator" } + uk_name { "Український калькулятор" } end end diff --git a/spec/factories/fields.rb b/spec/factories/fields.rb index 1f202204f..d8870a92c 100644 --- a/spec/factories/fields.rb +++ b/spec/factories/fields.rb @@ -19,7 +19,7 @@ # FactoryBot.define do factory :field do - kind { 0 } + kind { "number" } en_label { "Label" } uk_label { "Label" } var_name { "var" } diff --git a/spec/requests/account/calculators_spec.rb b/spec/requests/account/calculators_spec.rb index cb92c8b16..ad4123801 100644 --- a/spec/requests/account/calculators_spec.rb +++ b/spec/requests/account/calculators_spec.rb @@ -7,6 +7,10 @@ let!(:calculator) { create(:calculator) } + let(:user) { create(:user) } + let(:locale) { "en" } + let(:new_path) { new_account_calculator_path(locale: locale) } + describe "DELETE #destroy" do it "destroys the calculator and redirects" do expect do @@ -40,4 +44,51 @@ end end end + + describe "GET #new" do + subject { get new_path } + + context "when the user is authorized" do + it "initializes a new Calculator object with fields and formulas" do + subject + + expect(response).to have_http_status(:ok) + + calculator = assigns(:calculator) + expect(calculator).to be_a_new(Calculator) + + expect(calculator.fields.size).to eq(1) + expect(calculator.formulas.size).to eq(1) + + expect(calculator.fields.first).to be_a_new(Field) + expect(calculator.formulas.first).to be_a_new(Formula) + end + + it "renders the new template" do + subject + expect(response).to render_template(:new) + end + end + + context "when the locale is different" do + let(:locale) { "uk" } + + it "handles the locale correctly" do + subject + expect(I18n.locale).to eq(:uk) + expect(response).to have_http_status(:ok) + end + end + + context "when the user is not logged in" do + before do + sign_out(:user) + end + + it "redirects to the login page" do + subject + expect(response).to redirect_to(new_user_session_path) + end + end + end end From 123bc949c02a2df5100628d6bfc2042d3e603b7c Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 20 Nov 2024 09:30:59 +0000 Subject: [PATCH 20/33] add key for staging --- .github/workflows/ci.yml | 3 ++- config/credentials/staging_deploy_id_ed25519_enc | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 config/credentials/staging_deploy_id_ed25519_enc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 315493d3a..6b7191454 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: json-path: tmp/rspec_results.json if: always() - deploy-to-develop: + deploy-to-staging: needs: rspec runs-on: ubuntu-latest if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true @@ -107,6 +107,7 @@ jobs: with: target: development deploy_key: ${{ secrets.DEV_DEPLOY_KEY }} + enc_rsa_key_pth: config/credentials/deploy_id_ed25519_enc deploy-to-production: needs: rspec diff --git a/config/credentials/staging_deploy_id_ed25519_enc b/config/credentials/staging_deploy_id_ed25519_enc new file mode 100644 index 000000000..bd3eb4dc7 --- /dev/null +++ b/config/credentials/staging_deploy_id_ed25519_enc @@ -0,0 +1,10 @@ +U2FsdGVkX1+dAao58N25fwh/ICC4DEgTajI1FHPj36c7HRFb0WUo9mDljBWNEqA7 +R0+5nXn3pROcIFNjSu6wInKiCXB6wHTN+N29k+I6tG5HDkSElt7OZJffeluFfz/N +XKtGdPZuXjACLE343yCclrde9MJBZBsFVujONQfj4DMcrFkUmaPSGQyKnt+zahl7 +ML8Q2tnF8eFdFk9DyOqEha0F+Ux/+ZJtAjL0e8bYQQZ1Oz8vmqWgradu0V5WL37x +5mXo9BAEfb+oxOjOaN29eIFcTWGP6d0sXtfT3/815e6FKCphZ2v7A3eaKqb/s0Zi +LF+RKd+WMXGS2kB30ySZmJ6mX+uFbn2Qfq7lyy81qGwO1hfbAUvEqLe/YE5UaDDi +d8II5hh1SOitUbEU8pKjDPhuYdYZJggRa0WEC9P5rpC5JK750IPok4qFlc5UZp/B +pV+ey/roGY/HbbV9dZ0NIRoPZtWFjQvMOx+RhrCLmUvMyk4hv43IbLkMm3Z0sioZ +AktZWPns5yZfAYZYeVBFYbDvvuJHJiFlD35mzuDzOwh0p02nYi2pldn6P/1i8Rbf +tk0USJUvX/bDI5ooCEwyCw== \ No newline at end of file From 95ca3b156cf02dc0c54c0410d1be198f675b5195 Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 20 Nov 2024 09:49:27 +0000 Subject: [PATCH 21/33] add updating packages --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7191454..468aca764 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,9 @@ jobs: ruby-version: 3.3.5 bundler-cache: true + - name: Update packages + run: sudo apt-get update + - name: Install system dependencies run: sudo apt-get install -y libvips42 libvips-dev imagemagick From 033ff376f83ba3f18bc2d489564f2019b69573e1 Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 20 Nov 2024 13:41:03 +0000 Subject: [PATCH 22/33] fix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 468aca764..276c16bdc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,8 +109,8 @@ jobs: - uses: miloserdow/capistrano-deploy@v3 with: target: development - deploy_key: ${{ secrets.DEV_DEPLOY_KEY }} - enc_rsa_key_pth: config/credentials/deploy_id_ed25519_enc + deploy_key: ${{ secrets.STAGING_KEY_PASSWORD }} + enc_rsa_key_pth: config/credentials/staging_deploy_id_ed25519_enc deploy-to-production: needs: rspec From 0a64360fbadb581ad022c6aae11a98bb7dcc4066 Mon Sep 17 00:00:00 2001 From: Ivan Marynych <49816584+loqimean@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:14:19 +0200 Subject: [PATCH 23/33] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 276c16bdc..05b3114a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,7 +108,7 @@ jobs: - uses: miloserdow/capistrano-deploy@v3 with: - target: development + target: staging deploy_key: ${{ secrets.STAGING_KEY_PASSWORD }} enc_rsa_key_pth: config/credentials/staging_deploy_id_ed25519_enc From 3cb4be9caecafbd52465b23b9dccf3ad138a0bb0 Mon Sep 17 00:00:00 2001 From: Ivan Marynych <49816584+loqimean@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:33:55 +0200 Subject: [PATCH 24/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1bb70b38..0f6a65d4f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The latest version from the release branch 'master' is automatically deployed to - Bootstrap ## Clone - + $ `git clone https://github.com/ita-social-projects/ZeroWaste.git` ## Local setup From a6b220878a482514022cc5ba7fe2e72b1e5755e2 Mon Sep 17 00:00:00 2001 From: SleekMutt <84468904+SleekMutt@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:46:54 +0200 Subject: [PATCH 25/33] Added flipper, so admin could enable or disable mhc calculator (#969) * Added flipper, so admin could enable or disable mhc calculator --- app/controllers/calculators_controller.rb | 7 +++++++ app/views/account/shared/_navigation.html.erb | 5 +++++ config/initializers/flipper/features.rb | 3 +++ config/locales/en/en.yml | 3 +++ config/locales/uk/uk.yml | 3 +++ spec/requests/calculators_spec.rb | 21 ++++++++++++++----- spec/support/shared/context/feature_flags.rb | 14 +++++++++++++ 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/app/controllers/calculators_controller.rb b/app/controllers/calculators_controller.rb index e0b7a4460..6693a80ad 100644 --- a/app/controllers/calculators_controller.rb +++ b/app/controllers/calculators_controller.rb @@ -2,6 +2,7 @@ class CalculatorsController < ApplicationController before_action :authenticate_user!, only: :receive_recomendations + before_action :check_mhc_flipper, only: :mhc_calculator def index if Flipper[:show_calculators_list].enabled? @@ -52,4 +53,10 @@ def collection def resource collection.friendly.find(params[:slug]) end + + def check_mhc_flipper + return if Flipper[:mhc_calculator_status].enabled? + + raise ActionController::RoutingError, "Mhc calculator flipper is disabled" + end end diff --git a/app/views/account/shared/_navigation.html.erb b/app/views/account/shared/_navigation.html.erb index 1df545e99..264fd2e55 100644 --- a/app/views/account/shared/_navigation.html.erb +++ b/app/views/account/shared/_navigation.html.erb @@ -10,6 +10,11 @@ <%= link_to t("layouts.navigation.calculate"), calculator_path, class: "tab-main-page" %> <% end %> +
  • + <% if Flipper[:mhc_calculator_status].enabled? %> + <%= link_to t("layouts.navigation.mhc_calculator"), mhc_calculator_path, class: "tab-main-page" %> + <% end %> +
  • <%= link_to t("layouts.navigation.about_us"), about_path, class: "tab-main-page" %>
  • diff --git a/config/initializers/flipper/features.rb b/config/initializers/flipper/features.rb index 24f9571ad..93387a7eb 100644 --- a/config/initializers/flipper/features.rb +++ b/config/initializers/flipper/features.rb @@ -9,4 +9,7 @@ Flipper[:sandbox_mode].en_description = "This feature flag is responsible for enabling sandbox mode" Flipper[:sandbox_mode].uk_description = "Відкриває можливість використовувати режим пісочниці" + + Flipper[:mhc_calculator_status].en_description = "This feature flag is responsible for enabling mhc calculator" + Flipper[:mhc_calculator_status].uk_description = "Відкриває можливість використовувати калькулятор продуктів жіночої гігієни" end diff --git a/config/locales/en/en.yml b/config/locales/en/en.yml index 4a624b943..3bb164b80 100644 --- a/config/locales/en/en.yml +++ b/config/locales/en/en.yml @@ -126,6 +126,7 @@ en: about_us: "About us" admin: "Admin" calculate: "Diaper calculator" + mhc_calculator: "Pad calculator" log_out: "Log Out" sign_up: "Sign Up" log_in: "Log In" @@ -480,6 +481,8 @@ en: name: "Show calculators on the public side" sandbox_mode: name: "Enable sandbox mode" + mhc_calculator_status: + name: "Enable mhc calculator" sessions: new: log_in_header: "Log In" diff --git a/config/locales/uk/uk.yml b/config/locales/uk/uk.yml index 0b52f53aa..8ba07e394 100644 --- a/config/locales/uk/uk.yml +++ b/config/locales/uk/uk.yml @@ -109,6 +109,7 @@ uk: admin: "Адміністратор" calculate: "Калькулятор підгузків" log_out: "Вийти" + mhc_calculator: "Калькулятор прокладок" sign_up: "Зареєструватися" log_in: "Увійти" contact_us: "Зв'яжіться з нами" @@ -440,6 +441,8 @@ uk: name: "Показати калькулятори користувачам" sandbox_mode: name: "Увімкнути режим пісочниці" + mhc_calculator_status: + name: "Увімкнути калькулятор продуктів жіночої гігієни" sessions: new: log_in_header: "Увійти" diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index 2be0577e0..df316e5ba 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -111,12 +111,23 @@ end describe "GET /mhc_calculator" do - it "renders pad calculator" do - get mhc_calculator_path + context "mhc calculator is enabled" do + include_context :mhc_calculator_enabled - expect(response).to be_successful - expect(response).to render_template(:mhc_calculator) - expect(response.body).to include("results") + it "renders pad calculator" do + get mhc_calculator_path + + expect(response).to be_successful + expect(response).to render_template(:mhc_calculator) + end + end + + context "mhc calculator is disabled" do + include_context :mhc_calculator_disabled + + it "renders pad calculator" do + expect { get mhc_calculator_path }.to raise_error(ActionController::RoutingError) + end end end diff --git a/spec/support/shared/context/feature_flags.rb b/spec/support/shared/context/feature_flags.rb index a037cdaa9..cb62bed93 100644 --- a/spec/support/shared/context/feature_flags.rb +++ b/spec/support/shared/context/feature_flags.rb @@ -35,5 +35,19 @@ def sandbox_mode_context(mode) end end +RSpec.shared_context :mhc_calculator_enabled do + before do + FeatureFlag.find_or_create_by!(name: "show_calculators_list") + Flipper.enable(:mhc_calculator_status) + end +end + +RSpec.shared_context :mhc_calculator_disabled do + before do + FeatureFlag.find_or_create_by!(name: "show_calculators_list") + Flipper.disable(:mhc_calculator_status) + end +end + sandbox_mode_context(:enable) sandbox_mode_context(:disable) From 7a7f15c0ee294c6051b2923ab712d0b4fc06f292 Mon Sep 17 00:00:00 2001 From: Bohdan Date: Tue, 26 Nov 2024 17:11:23 +0200 Subject: [PATCH 26/33] Added feature flipper for calculators constructor --- .../account/calculators_controller.rb | 9 +++++++-- app/controllers/calculators_controller.rb | 7 +++++++ app/views/account/shared/_navigation.html.erb | 2 +- app/views/layouts/_account_navbar.html.erb | 16 +++++++++------- config/locales/en/en.yml | 2 ++ config/locales/uk/uk.yml | 2 ++ 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index 4a1cd4b6a..c4d6bb1a5 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -2,10 +2,9 @@ class Account::CalculatorsController < Account::BaseController load_and_authorize_resource + before_action :check_constructor_flipper def index - render "shared/under_construction" unless Rails.env.local? - @q = collection.ransack(params[:q]) @calculators = @q.result.page(params[:page]) end @@ -95,4 +94,10 @@ def updater @calculator.update(calculator_params) end end + + def check_constructor_flipper + return if Flipper[:constructor_status].enabled? + + raise ActionController::RoutingError, "Constructor flipper is disabled" + end end diff --git a/app/controllers/calculators_controller.rb b/app/controllers/calculators_controller.rb index 8e87d0e92..08227a1a8 100644 --- a/app/controllers/calculators_controller.rb +++ b/app/controllers/calculators_controller.rb @@ -2,6 +2,7 @@ class CalculatorsController < ApplicationController before_action :authenticate_user!, only: :receive_recomendations + before_action :check_constructor_flipper, only: [:index, :show, :calculate] def index if Flipper[:show_calculators_list].enabled? @@ -51,4 +52,10 @@ def collection def resource collection.friendly.find(params[:slug]) end + + def check_constructor_flipper + return if Flipper[:constructor_status].enabled? + + raise ActionController::RoutingError, "Constructor flipper is disabled" + end end diff --git a/app/views/account/shared/_navigation.html.erb b/app/views/account/shared/_navigation.html.erb index 1df545e99..51430c093 100644 --- a/app/views/account/shared/_navigation.html.erb +++ b/app/views/account/shared/_navigation.html.erb @@ -18,7 +18,7 @@ <% if user_signed_in? && current_user.admin? %>
  • - <%= link_to t("layouts.navigation.admin"), account_calculators_path, class: "tab-main-page" %> + <%= link_to t("layouts.navigation.admin"), edit_account_site_setting_path, class: "tab-main-page" %>
  • <% end %> <% if user_signed_in? %> diff --git a/app/views/layouts/_account_navbar.html.erb b/app/views/layouts/_account_navbar.html.erb index 35774f393..f3cac3796 100644 --- a/app/views/layouts/_account_navbar.html.erb +++ b/app/views/layouts/_account_navbar.html.erb @@ -8,13 +8,15 @@