From 400c8a87f4100ab7edd4e94dff5f687aff9fe40a Mon Sep 17 00:00:00 2001 From: goruchan Date: Fri, 8 Dec 2023 15:25:17 +0900 Subject: [PATCH 01/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E4=BA=86=E3=82=BF=E3=83=96=E3=81=AB=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E5=80=8B=E6=95=B0?= =?UTF-8?q?=E3=82=92=E4=BC=91=E6=AD=A2=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=81=AE=E3=82=82=E3=81=AE=E3=82=92=E5=BC=95=E3=81=84=E3=81=9F?= =?UTF-8?q?=E5=80=8B=E6=95=B0=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/cache.rb | 2 +- app/models/product.rb | 4 ++++ db/fixtures/products.yml | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/cache.rb b/app/models/cache.rb index 47aeb48f6f1..1102d3e26a9 100644 --- a/app/models/cache.rb +++ b/app/models/cache.rb @@ -14,7 +14,7 @@ def delete_unchecked_report_count def unchecked_product_count Rails.cache.fetch 'unchecked_product_count' do - Product.unchecked.not_wip.count + Product.unchecked_not_wip_hibernated_user_products.count end end diff --git a/app/models/product.rb b/app/models/product.rb index bf99e783363..0e114e3ea2f 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -107,6 +107,10 @@ def self.unchecked_no_replied_products .order(published_at: :asc, id: :asc) end + def self.unchecked_not_wip_hibernated_user_products + Product.unchecked.not_wip.reject { |product| product.user.hibernated? } + end + def completed?(user) checks.where(user: user).present? end diff --git a/db/fixtures/products.yml b/db/fixtures/products.yml index 94cdb5ca2c9..e2c15775058 100644 --- a/db/fixtures/products.yml +++ b/db/fixtures/products.yml @@ -179,3 +179,10 @@ product5: body: 4時間後に5日経過に到達する提出物です。 published_at: <%= (now - 60 * 60 * 23 * 5).to_formatted_s(:db) %> created_at: <%= (now - 60 * 60 * 23 * 5).to_formatted_s(:db) %> + +product76: + practice: practice19 + user: kyuukai + body: 休会中ユーザの提出物です。 + published_at: <%= now.to_formatted_s(:db) %> + created_at: <%= now.to_formatted_s(:db) %> From 66ff2847cce52b39c4c34964dc2ca0d519ede3aa Mon Sep 17 00:00:00 2001 From: goruchan Date: Fri, 8 Dec 2023 21:48:41 +0900 Subject: [PATCH 02/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E5=8F=96=E5=BE=97=E6=96=B9=E6=B3=95=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=82=92=20scope=20=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E6=96=B9=E6=B3=95=E3=81=AB=E5=A4=89=E6=9B=B4=EF=BC=8B?= =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=83=80=E3=82=AF=E3=83=88=E3=82=92=E9=99=A4=E3=81=84=E3=81=9F?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E5=8F=96=E5=BE=97=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/products/unchecked_controller.rb | 5 +++-- app/models/cache.rb | 2 +- app/models/product.rb | 17 ++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/products/unchecked_controller.rb b/app/controllers/api/products/unchecked_controller.rb index 9efe79518a2..ed0ffb796bc 100644 --- a/app/controllers/api/products/unchecked_controller.rb +++ b/app/controllers/api/products/unchecked_controller.rb @@ -8,13 +8,14 @@ def index checker_id = params[:checker_id] @products = case @target when 'unchecked_all' - Product.unchecked + Product.unhibernated_user_products + .unchecked .not_wip .list .ascending_by_date_of_publishing_and_id .page(params[:page]) when 'unchecked_no_replied' - Product.unchecked_no_replied_products + Product.unhibernated_user_products_unchecked_no_replied_products .unchecked .not_wip .list diff --git a/app/models/cache.rb b/app/models/cache.rb index 1102d3e26a9..b9656ab5565 100644 --- a/app/models/cache.rb +++ b/app/models/cache.rb @@ -14,7 +14,7 @@ def delete_unchecked_report_count def unchecked_product_count Rails.cache.fetch 'unchecked_product_count' do - Product.unchecked_not_wip_hibernated_user_products.count + Product.unhibernated_user_products.unchecked.not_wip.count end end diff --git a/app/models/product.rb b/app/models/product.rb index 0e114e3ea2f..870e0489c07 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -52,6 +52,8 @@ class Product < ApplicationRecord scope :ascending_by_date_of_publishing_and_id, -> { order(published_at: :asc, id: :asc) } scope :order_for_self_assigned_list, -> { order('commented_at asc nulls first, published_at asc') } + scope :unhibernated_user_products, -> { Product.joins(:user).where(user: { hibernated_at: nil }) } + def self.add_latest_commented_at Product.all.includes(:comments).find_each do |product| next if product.comments.blank? @@ -97,18 +99,15 @@ def self.self_assigned_no_replied_products(user_id) .order(published_at: :asc, id: :asc) end - def self.unchecked_no_replied_products - self_last_commented_products = Product.where.not(commented_at: nil).filter do |product| + def self.unhibernated_user_products_unchecked_no_replied_products + unhibernated_user_products = Product.joins(:user).where(user: { hibernated_at: nil }) + self_last_commented_products = unhibernated_user_products.where.not(commented_at: nil).filter do |product| product.comments.last.user_id == product.user.id end - no_comments_products = Product.where(commented_at: nil) + no_comments_products = unhibernated_user_products.where(commented_at: nil) no_replied_products_ids = (self_last_commented_products + no_comments_products).map(&:id) - Product.where(id: no_replied_products_ids) - .order(published_at: :asc, id: :asc) - end - - def self.unchecked_not_wip_hibernated_user_products - Product.unchecked.not_wip.reject { |product| product.user.hibernated? } + unhibernated_user_products.where(id: no_replied_products_ids) + .order(published_at: :asc, id: :asc) end def completed?(user) From 56bc8c4d64f4a1f2a709da305a32d8324387d2a3 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 9 Dec 2023 22:05:38 +0900 Subject: [PATCH 03/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E4=BA=86=E3=82=BF=E3=83=96=E3=81=AB=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E6=8F=90=E5=87=BA=E7=89=A9?= =?UTF-8?q?=E6=95=B0=E3=81=AF=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 41a82be9b60..af05207a0c8 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -200,4 +200,9 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_selector '.card-list-item__assignee-name', text: 'komagata' assert_no_selector '.card-list-item__assignee-name', text: 'machida' end + + test 'page tab item count about unchecked product is exclude unhiberanated user products' do + visit_with_auth '/products/unchecked', 'komagata' + assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count})" + end end From 7dcc64e1eeafc1cafe2754dc5b81518520513a77 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 9 Dec 2023 23:23:01 +0900 Subject: [PATCH 04/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E4=BA=86=E4=B8=80=E8=A6=A7=E3=81=AB=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=8C?= =?UTF-8?q?=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6=E3=81=AE?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=A7=E3=81=82=E3=82=8B=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index af05207a0c8..1e49b8bf608 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -201,8 +201,25 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_no_selector '.card-list-item__assignee-name', text: 'machida' end - test 'page tab item count about unchecked product is exclude unhiberanated user products' do + test 'the number of products in the unchecked tab is excepted unhiberanated user' do visit_with_auth '/products/unchecked', 'komagata' assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count})" end + + test 'unchecked products is excepted unhiberanated user' do + user = users(:kyuukai) + product_unhiberanated_user_name = "#{user.login_name} (#{user.name_kana})" + + visit_with_auth '/products/unchecked', 'komagata' + # assert_no_text だとデータが読み込まれる前に実行され常に成立してしまうため、明示的に待機する has_text? を使用する + assert_not has_text?(product_unhiberanated_user_name) + first('.pagination__item-link', text: '2').click + assert_not has_text?(product_unhiberanated_user_name) + + visit_with_auth '/products/unchecked?target=unchecked_no_replied', 'komagata' + assert_not has_text?(product_unhiberanated_user_name) + first('.pagination__item-link', text: '2').click + assert_not has_text?(product_unhiberanated_user_name) + end end + From d6f5bee877bb6cc60cb23465033eb1e557edc6b8 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 9 Dec 2023 23:29:55 +0900 Subject: [PATCH 05/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=81=AE=E6=8A=BD=E5=87=BA=E3=82=92=E3=82=B9?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=97=E5=AE=9A=E7=BE=A9=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/product.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 870e0489c07..9ce53443351 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -100,7 +100,7 @@ def self.self_assigned_no_replied_products(user_id) end def self.unhibernated_user_products_unchecked_no_replied_products - unhibernated_user_products = Product.joins(:user).where(user: { hibernated_at: nil }) + unhibernated_user_products = Product.unhibernated_user_products self_last_commented_products = unhibernated_user_products.where.not(commented_at: nil).filter do |product| product.comments.last.user_id == product.user.id end From a65a4a5491378810bfb64ca5c2a4854050f943f2 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 9 Dec 2023 23:48:49 +0900 Subject: [PATCH 06/79] =?UTF-8?q?lint=20=E5=AF=BE=E5=BF=9C=E3=80=82?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E7=A9=BA=E8=A1=8C=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 1e49b8bf608..2d485d8c23d 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -222,4 +222,3 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_not has_text?(product_unhiberanated_user_name) end end - From b41acc6678587c55e4fbcd206002c7b359b55949 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sun, 10 Dec 2023 16:17:14 +0900 Subject: [PATCH 07/79] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E7=A9=BA?= =?UTF-8?q?=E8=A1=8C=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/product.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 9ce53443351..995247dde4e 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -51,7 +51,6 @@ class Product < ApplicationRecord scope :order_for_all_list, -> { order(published_at: :desc, id: :asc) } scope :ascending_by_date_of_publishing_and_id, -> { order(published_at: :asc, id: :asc) } scope :order_for_self_assigned_list, -> { order('commented_at asc nulls first, published_at asc') } - scope :unhibernated_user_products, -> { Product.joins(:user).where(user: { hibernated_at: nil }) } def self.add_latest_commented_at From 425aa3e60c20fd7e82de9139eb27e550648ae7f1 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sun, 10 Dec 2023 20:43:22 +0900 Subject: [PATCH 08/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E5=90=8D=E3=81=8C=E4=BC=91=E4=BC=9A=E4=B8=AD?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=92=E7=A4=BA=E3=81=99=E3=81=B9?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=AE=E3=81=AB=E3=80=81=E9=9D=9E=E4=BC=91?= =?UTF-8?q?=E4=BC=9A=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6=E3=81=A8=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 2d485d8c23d..c29a839331c 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -201,12 +201,12 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_no_selector '.card-list-item__assignee-name', text: 'machida' end - test 'the number of products in the unchecked tab is excepted unhiberanated user' do + test 'the number of products in the unchecked tab is excepted hiberanated user' do visit_with_auth '/products/unchecked', 'komagata' assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count})" end - test 'unchecked products is excepted unhiberanated user' do + test 'unchecked products is excepted hiberanated user' do user = users(:kyuukai) product_unhiberanated_user_name = "#{user.login_name} (#{user.name_kana})" From b9f7e67ae18e668653ac4ac8ff4a2802b527dbc8 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sun, 10 Dec 2023 20:45:23 +0900 Subject: [PATCH 09/79] =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=81=8C?= =?UTF-8?q?=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6=E3=81=AE?= =?UTF-8?q?=E3=81=A4=E3=82=82=E3=82=8A=E3=81=8C=E9=9D=9E=E4=BC=91=E4=BC=9A?= =?UTF-8?q?=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=9F=E3=81=AE=E3=81=A7=E3=81=93=E3=81=93=E3=82=82?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index c29a839331c..cd1cb347ed9 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -208,17 +208,17 @@ class Product::UncheckedTest < ApplicationSystemTestCase test 'unchecked products is excepted hiberanated user' do user = users(:kyuukai) - product_unhiberanated_user_name = "#{user.login_name} (#{user.name_kana})" + product_hiberanated_user_name = "#{user.login_name} (#{user.name_kana})" visit_with_auth '/products/unchecked', 'komagata' # assert_no_text だとデータが読み込まれる前に実行され常に成立してしまうため、明示的に待機する has_text? を使用する - assert_not has_text?(product_unhiberanated_user_name) + assert_not has_text?(product_hiberanated_user_name) first('.pagination__item-link', text: '2').click - assert_not has_text?(product_unhiberanated_user_name) + assert_not has_text?(product_hiberanated_user_name) visit_with_auth '/products/unchecked?target=unchecked_no_replied', 'komagata' - assert_not has_text?(product_unhiberanated_user_name) + assert_not has_text?(product_hiberanated_user_name) first('.pagination__item-link', text: '2').click - assert_not has_text?(product_unhiberanated_user_name) + assert_not has_text?(product_hiberanated_user_name) end end From f79f649fb2d939a16446a1a82fc9a9b64b77e955 Mon Sep 17 00:00:00 2001 From: niikz <60736158+niikz@users.noreply.github.com> Date: Mon, 11 Dec 2023 22:42:01 +0900 Subject: [PATCH 10/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=8C0?= =?UTF-8?q?=E3=81=AE=E3=81=A8=E3=81=8D=E3=82=82=E3=80=81[=E6=9C=AA?= =?UTF-8?q?=E8=BF=94=E4=BF=A1/=E5=85=A8=E3=81=A6]=E3=81=AE=E3=83=8A?= =?UTF-8?q?=E3=83=93=E3=82=B2=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Products.jsx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/javascript/components/Products.jsx b/app/javascript/components/Products.jsx index 91a67212c25..06da11cc389 100644 --- a/app/javascript/components/Products.jsx +++ b/app/javascript/components/Products.jsx @@ -79,12 +79,22 @@ export default function Products({ ) } else if (data.products.length === 0) { return ( -
-
- + <> + {selectedTab === 'unchecked' || selectedTab === 'self_assigned' ? ( + + ) : null} + +
+
+ +
+

{title}はありません

-

{title}はありません

-
+ ) } else if (isDashboard() && isNotProduct5daysElapsed()) { return ( From 4067bc46272c1df2f9e8de48f6659dd27f0c6a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CsasacoJM=E2=80=9D?= <78665068+Sasaco-JM@users.noreply.github.com> Date: Sat, 2 Dec 2023 18:29:15 +0900 Subject: [PATCH 11/79] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88?= =?UTF-8?q?=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mailers/activity_mailer.rb | 2 +- app/models/concerns/mentioner.rb | 2 +- app/models/concerns/watchable.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/mailers/activity_mailer.rb b/app/mailers/activity_mailer.rb index 31bd1eb446e..a5738c36fc3 100644 --- a/app/mailers/activity_mailer.rb +++ b/app/mailers/activity_mailer.rb @@ -251,7 +251,7 @@ def watching_notification(args = {}) kind: Notification.kinds[:watched] ) @action = @watchable.instance_of?(Question) ? '回答' : 'コメント' - subject = "[FBC] #{@watchable.user.login_name}さんの【 #{@watchable.notification_title} 】に#{@sender.login_name}さんが#{@action}しました。" + subject = "[FBC] #{@watchable.user.login_name}さんの#{@watchable.notification_title}で#{@sender.login_name}さんが#{@action}しました。" message = mail to: @user.email, subject: subject message.perform_deliveries = @user.mail_notification? && !@user.retired? diff --git a/app/models/concerns/mentioner.rb b/app/models/concerns/mentioner.rb index e669f87b9f6..e046bdd4b5f 100644 --- a/app/models/concerns/mentioner.rb +++ b/app/models/concerns/mentioner.rb @@ -14,7 +14,7 @@ def new_mention_users def where_mention case self when Product - "#{user.login_name}さんの「#{practice[:title]}」の提出物" + "#{user.login_name}さんの提出物「#{practice[:title]}」" when Report "#{user.login_name}さんの日報「#{self[:title]}」" when Comment diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index fa98f66bd54..0a20368ecff 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -16,19 +16,19 @@ def watched? def notification_title case self when Product - "「#{practice[:title]}」の提出物" + "提出物「#{practice[:title]}」" when Report - "「#{self[:title]}」の日報" + "日報「#{self[:title]}」" when Question - "「#{self[:title]}」のQ&A" + "Q&A「#{self[:title]}」" when Event - "「#{self[:title]}」の特別イベント" + "特別イベント「#{self[:title]}」" when RegularEvent - "「#{self[:title]}」の定期イベント" + "定期イベント「#{self[:title]}」" when Page - "「#{self[:title]}」のDocs" + "Docs「#{self[:title]}」" when Announcement - " [#{self[:title]}]のお知らせ" + " お知らせ[#{self[:title]}]" end end From b2f3f664f5a388ba6b1aa5a05cbb73ce3040d63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CsasacoJM=E2=80=9D?= <78665068+Sasaco-JM@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:11:58 +0900 Subject: [PATCH 12/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/concerns/watchable.rb | 2 +- app/notifiers/activity_notifier.rb | 2 +- test/mailers/activity_mailer_test.rb | 2 +- test/models/comment_test.rb | 2 +- test/system/followings_test.rb | 4 ++-- test/system/notification/watches_test.rb | 8 ++++---- test/system/notifications_test.rb | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index 0a20368ecff..7d539b8232a 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -28,7 +28,7 @@ def notification_title when Page "Docs「#{self[:title]}」" when Announcement - " お知らせ[#{self[:title]}]" + "お知らせ「#{self[:title]}」" end end diff --git a/app/notifiers/activity_notifier.rb b/app/notifiers/activity_notifier.rb index 294854de66d..87322f741ee 100644 --- a/app/notifiers/activity_notifier.rb +++ b/app/notifiers/activity_notifier.rb @@ -299,7 +299,7 @@ def watching_notification(params = {}) action = watchable.instance_of?(Question) ? '回答' : 'コメント' notification( - body: "#{watchable.user.login_name}さんの【 #{watchable.notification_title} 】に#{sender.login_name}さんが#{action}しました。", + body: "#{watchable.user.login_name}さんの#{watchable.notification_title}で#{sender.login_name}さんが#{action}しました。", kind: :watching, receiver: receiver, sender: sender, diff --git a/test/mailers/activity_mailer_test.rb b/test/mailers/activity_mailer_test.rb index ef6bcc81e97..483b0d08d22 100644 --- a/test/mailers/activity_mailer_test.rb +++ b/test/mailers/activity_mailer_test.rb @@ -622,7 +622,7 @@ class ActivityMailerTest < ActionMailer::TestCase email = ActionMailer::Base.deliveries.last assert_equal ['noreply@bootcamp.fjord.jp'], email.from assert_equal ['kimura@fjord.jp'], email.to - assert_equal '[FBC] komagataさんの【 「作業週1日目」の日報 】にmachidaさんがコメントしました。', email.subject + assert_equal '[FBC] komagataさんの日報「作業週1日目」でmachidaさんがコメントしました。', email.subject assert_match(/コメント/, email.body.to_s) end diff --git a/test/models/comment_test.rb b/test/models/comment_test.rb index b3012d4745e..1193f8819f3 100644 --- a/test/models/comment_test.rb +++ b/test/models/comment_test.rb @@ -58,7 +58,7 @@ class CommentTest < ActiveSupport::TestCase assert users(:kimura).notifications.exists?( kind: 'watching', sender: users(:mentormentaro), - message: 'kimuraさんの【 「PC性能の見方を知る」の提出物 】にmentormentaroさんがコメントしました。' + message: 'kimuraさんの提出物「PC性能の見方を知る」でmentormentaroさんがコメントしました。' ) end assert_not users(:mentormentaro).notifications.exists?( diff --git a/test/system/followings_test.rb b/test/system/followings_test.rb index cacda086c10..315194960a3 100644 --- a/test/system/followings_test.rb +++ b/test/system/followings_test.rb @@ -120,9 +120,9 @@ class FollowingsTest < ApplicationSystemTestCase assert_text comment visit_with_auth '/notifications', 'kimura' - assert_text 'hatsunoさんの【 「test title」の日報 】にhatsunoさんがコメントしました。' + assert_text 'hatsunoさんの日報「test title」でhatsunoさんがコメントしました。' visit_with_auth '/notifications', 'mentormentaro' - assert_no_text 'hatsunoさんの【 「test title」の日報 】にhatsunoさんがコメントしました。' + assert_no_text 'hatsunoさんの日報「test title」でhatsunoさんがコメントしました。' end end diff --git a/test/system/notification/watches_test.rb b/test/system/notification/watches_test.rb index 17239e51b5c..7bdc6b1ef46 100644 --- a/test/system/notification/watches_test.rb +++ b/test/system/notification/watches_test.rb @@ -32,13 +32,13 @@ class Notification::WatchesTest < ApplicationSystemTestCase visit_with_auth '/notifications', 'kimura' within first('.card-list-item.is-unread') do - assert_text "komagataさんの【 「#{reports(:report1).title}」の日報 】にkomagataさんがコメントしました。" + assert_text "komagataさんの日報「#{reports(:report1).title}」でkomagataさんがコメントしました。" end visit_with_auth '/notifications', 'machida' within first('.card-list-item.is-unread') do - assert_text "komagataさんの【 「#{reports(:report1).title}」の日報 】にkomagataさんがコメントしました。" + assert_text "komagataさんの日報「#{reports(:report1).title}」でkomagataさんがコメントしました。" end end @@ -62,13 +62,13 @@ class Notification::WatchesTest < ApplicationSystemTestCase visit_with_auth '/notifications', 'kimura' within first('.card-list-item.is-unread') do - assert_text "machidaさんの【 「#{questions(:question1).title}」のQ&A 】にmachidaさんが回答しました。" + assert_text "machidaさんのQ&A「#{questions(:question1).title}」でmachidaさんが回答しました。" end visit_with_auth '/notifications', 'komagata' within first('.card-list-item.is-unread') do - assert_text "machidaさんの【 「#{questions(:question1).title}」のQ&A 】にmachidaさんが回答しました。" + assert_text "machidaさんのQ&A「#{questions(:question1).title}」でmachidaさんが回答しました。" end end end diff --git a/test/system/notifications_test.rb b/test/system/notifications_test.rb index 8c61d851c6e..52302e392a1 100644 --- a/test/system/notifications_test.rb +++ b/test/system/notifications_test.rb @@ -266,7 +266,7 @@ class NotificationsTest < ApplicationSystemTestCase visit_with_auth "/reports/#{report}", 'hatsuno' assert_text 'コメントと確認した' find('.header-links__link.test-show-notifications').click - assert_text 'hatsunoさんの【 「コメントと」の日報 】にkomagataさんがコメントしました。' + assert_text 'hatsunoさんの日報「コメントと」でkomagataさんがコメントしました。' end end From f80f69f694fffb2c64a810a893b9a62d67e0569e Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Mon, 4 Dec 2023 21:40:49 +0900 Subject: [PATCH 13/79] =?UTF-8?q?=E6=9C=AA=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=81=A7=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E5=80=8B?= =?UTF-8?q?=E5=88=A5=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=BB=E3=82=B9=E3=81=97=E3=81=9F=E6=99=82=E3=81=AE=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 +++++++- app/views/users/unauthorized_show.slim | 17 +++++++++++++++++ test/system/require_login/users_test.rb | 4 ---- test/system/user/not_logged_in_test.rb | 13 +++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 app/views/users/unauthorized_show.slim create mode 100644 test/system/user/not_logged_in_test.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dfda69738df..9b3baa12ab3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class UsersController < ApplicationController - skip_before_action :require_active_user_login, raise: false, only: %i[new create] + skip_before_action :require_active_user_login, raise: false, only: %i[new create show] before_action :require_token, only: %i[new] if Rails.env.production? before_action :set_user, only: %w[show] @@ -40,6 +40,12 @@ def show .includes(:practice) .where(status: 3) .order(updated_at: :desc) + + if logged_in? + render :show + else + render :unauthorized_show, layout: 'not_logged_in' + end end def new diff --git a/app/views/users/unauthorized_show.slim b/app/views/users/unauthorized_show.slim new file mode 100644 index 00000000000..09a04dbaf04 --- /dev/null +++ b/app/views/users/unauthorized_show.slim @@ -0,0 +1,17 @@ +- title @user.login_name +- description "オンラインプログラミングスクール「フィヨルドブートキャンプ」の#{@user.login_name}さんのプロフィールページ" +- content_for :extra_body_classes + +.page-body + article.unauthorized + = render '/unauthorized/unauthorized_header', label: 'プロフィールページ', title: "#{title}" + .unauthorized__body + .container.is-md + .unauthorized__contents + .unauthorized__content + = render '/unauthorized/must_be_enrolled' + hr.unauthorized__content-separalor + .unauthorized__content + = render '/unauthorized/about_fbc' + .unauthorized__content + = render '/unauthorized/join_us' diff --git a/test/system/require_login/users_test.rb b/test/system/require_login/users_test.rb index 5a4316bec35..2c7c8026e0d 100644 --- a/test/system/require_login/users_test.rb +++ b/test/system/require_login/users_test.rb @@ -9,10 +9,6 @@ class UsersLoginTest < ApplicationSystemTestCase assert_login_required('/users') end - test 'cannot access user detail without login' do - assert_login_required("/users/#{users(:hatsuno).id}") - end - test 'can access user create screen without login' do assert_no_login_required('/users/new', 'フィヨルドブートキャンプ参加登録') end diff --git a/test/system/user/not_logged_in_test.rb b/test/system/user/not_logged_in_test.rb new file mode 100644 index 00000000000..9105e1adfb2 --- /dev/null +++ b/test/system/user/not_logged_in_test.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class User::NotLoggedInTest < ApplicationSystemTestCase + test 'appropriate meta description is displayed when accessed by non-logged-in user' do + target_user = users(:kimura) + visit user_path(target_user) + assert_selector 'head', visible: false do + assert_selector "meta[name='description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」の#{target_user.login_name}さんのプロフィールページ']", visible: false + end + end +end From c0291f67ac0ce0c72823379e3b94198bc8257134 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Wed, 6 Dec 2023 09:05:08 +0900 Subject: [PATCH 14/79] =?UTF-8?q?Slim=20Lint=E3=81=AE=E6=8C=87=E6=91=98?= =?UTF-8?q?=E4=BA=8B=E9=A0=85=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/unauthorized_show.slim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/users/unauthorized_show.slim b/app/views/users/unauthorized_show.slim index 09a04dbaf04..8b568cce21d 100644 --- a/app/views/users/unauthorized_show.slim +++ b/app/views/users/unauthorized_show.slim @@ -4,7 +4,8 @@ .page-body article.unauthorized - = render '/unauthorized/unauthorized_header', label: 'プロフィールページ', title: "#{title}" + = render '/unauthorized/unauthorized_header', + label: 'プロフィールページ', title: title.to_s .unauthorized__body .container.is-md .unauthorized__contents From 93ab7e2a6815bae16f52703612c9f8848d396dce Mon Sep 17 00:00:00 2001 From: machida Date: Fri, 15 Dec 2023 14:44:41 +0900 Subject: [PATCH 15/79] =?UTF-8?q?=E6=9C=AA=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=87=E3=82=B6?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=81=AE=E5=BE=AE=E8=AA=BF=E6=95=B4=E3=80=81?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E6=96=87=E8=A8=80=E5=BE=AE=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/unauthorized/_unauthorized_header.html.slim | 6 +++++- app/views/users/unauthorized_show.slim | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/unauthorized/_unauthorized_header.html.slim b/app/views/unauthorized/_unauthorized_header.html.slim index 163300680ca..bba4d8c7e8a 100644 --- a/app/views/unauthorized/_unauthorized_header.html.slim +++ b/app/views/unauthorized/_unauthorized_header.html.slim @@ -4,4 +4,8 @@ header.unauthorized-header h1.unauthorized-header__title span.unauthorized-header__title-label = label - | 「#{title}」 + span.font-thin + | 「 + = title + span.font-thin + | 」 diff --git a/app/views/users/unauthorized_show.slim b/app/views/users/unauthorized_show.slim index 8b568cce21d..cb3d5e01a99 100644 --- a/app/views/users/unauthorized_show.slim +++ b/app/views/users/unauthorized_show.slim @@ -1,11 +1,11 @@ -- title @user.login_name -- description "オンラインプログラミングスクール「フィヨルドブートキャンプ」の#{@user.login_name}さんのプロフィールページ" +- title '@' + @user.login_name +- description "オンラインプログラミングスクール「フィヨルドブートキャンプ」の@#{@user.login_name}さんのプロフィールページ" - content_for :extra_body_classes .page-body article.unauthorized = render '/unauthorized/unauthorized_header', - label: 'プロフィールページ', title: title.to_s + label: 'ユーザープロフィールページ', title: title.to_s .unauthorized__body .container.is-md .unauthorized__contents From 702219342a760ec8fab57fcba638714427baadfb Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sat, 16 Dec 2023 10:04:50 +0900 Subject: [PATCH 16/79] =?UTF-8?q?slim-lint=E3=81=AE=E6=8C=87=E6=91=98?= =?UTF-8?q?=E4=BA=8B=E9=A0=85=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/unauthorized_show.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/unauthorized_show.slim b/app/views/users/unauthorized_show.slim index cb3d5e01a99..c30751ed6ba 100644 --- a/app/views/users/unauthorized_show.slim +++ b/app/views/users/unauthorized_show.slim @@ -1,4 +1,4 @@ -- title '@' + @user.login_name +- title "@#{@user.login_name}" - description "オンラインプログラミングスクール「フィヨルドブートキャンプ」の@#{@user.login_name}さんのプロフィールページ" - content_for :extra_body_classes From 0c4b954a50368838987f9c4fa0d7ed35171e12b8 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sat, 16 Dec 2023 10:25:54 +0900 Subject: [PATCH 17/79] =?UTF-8?q?=E5=A4=89=E6=9B=B4=E7=AE=87=E6=89=80?= =?UTF-8?q?=E3=81=AB=E6=B2=BF=E3=81=A3=E3=81=A6=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/user/not_logged_in_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/user/not_logged_in_test.rb b/test/system/user/not_logged_in_test.rb index 9105e1adfb2..5014c3924d3 100644 --- a/test/system/user/not_logged_in_test.rb +++ b/test/system/user/not_logged_in_test.rb @@ -7,7 +7,7 @@ class User::NotLoggedInTest < ApplicationSystemTestCase target_user = users(:kimura) visit user_path(target_user) assert_selector 'head', visible: false do - assert_selector "meta[name='description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」の#{target_user.login_name}さんのプロフィールページ']", visible: false + assert_selector "meta[name='description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」の@#{target_user.login_name}さんのプロフィールページ']", visible: false end end end From 8c409e422bb48d59ae0c7005a96fdc8dc6ab228a Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 12:18:21 +0900 Subject: [PATCH 18/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E8=80=85=E7=B5=9E?= =?UTF-8?q?=E3=82=8A=E8=BE=BC=E3=81=BF=E3=81=A8=E3=80=81=E6=9C=AA=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=83=BB=E6=9C=AA=E8=BF=94=E4=BF=A1=E3=81=AE=E7=B5=9E?= =?UTF-8?q?=E3=82=8A=E8=BE=BC=E3=81=BF=E3=82=92=E5=88=A5=E3=81=AB=E5=88=86?= =?UTF-8?q?=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/products/unchecked_controller.rb | 4 ++-- app/models/product.rb | 22 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controllers/api/products/unchecked_controller.rb b/app/controllers/api/products/unchecked_controller.rb index ed0ffb796bc..676f3da1e1d 100644 --- a/app/controllers/api/products/unchecked_controller.rb +++ b/app/controllers/api/products/unchecked_controller.rb @@ -15,8 +15,8 @@ def index .ascending_by_date_of_publishing_and_id .page(params[:page]) when 'unchecked_no_replied' - Product.unhibernated_user_products_unchecked_no_replied_products - .unchecked + Product.unhibernated_user_products + .unchecked_no_replied_products .not_wip .list .page(params[:page]) diff --git a/app/models/product.rb b/app/models/product.rb index 995247dde4e..f6c67834819 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -51,7 +51,16 @@ class Product < ApplicationRecord scope :order_for_all_list, -> { order(published_at: :desc, id: :asc) } scope :ascending_by_date_of_publishing_and_id, -> { order(published_at: :asc, id: :asc) } scope :order_for_self_assigned_list, -> { order('commented_at asc nulls first, published_at asc') } - scope :unhibernated_user_products, -> { Product.joins(:user).where(user: { hibernated_at: nil }) } + scope :unchecked_no_replied_products, lambda { + self_last_commented_products = where.not(commented_at: nil).select do |product| + product.comments.last.user_id == product.user.id + end + no_comments_products = where(commented_at: nil) + no_replied_products_ids = (self_last_commented_products + no_comments_products).map(&:id) + where(id: no_replied_products_ids) + .order(published_at: :asc, id: :asc) + } + scope :unhibernated_user_products, -> { joins(:user).where(user: { hibernated_at: nil }) } def self.add_latest_commented_at Product.all.includes(:comments).find_each do |product| @@ -98,17 +107,6 @@ def self.self_assigned_no_replied_products(user_id) .order(published_at: :asc, id: :asc) end - def self.unhibernated_user_products_unchecked_no_replied_products - unhibernated_user_products = Product.unhibernated_user_products - self_last_commented_products = unhibernated_user_products.where.not(commented_at: nil).filter do |product| - product.comments.last.user_id == product.user.id - end - no_comments_products = unhibernated_user_products.where(commented_at: nil) - no_replied_products_ids = (self_last_commented_products + no_comments_products).map(&:id) - unhibernated_user_products.where(id: no_replied_products_ids) - .order(published_at: :asc, id: :asc) - end - def completed?(user) checks.where(user: user).present? end From 53fa40763b8ad16dd8505b4400c22b5de672cf7f Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 14:19:41 +0900 Subject: [PATCH 19/79] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=BC=8F=E3=82=92?= =?UTF-8?q?=E6=97=A2=E5=AD=98=E3=82=B3=E3=83=BC=E3=83=89=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/product.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/product.rb b/app/models/product.rb index f6c67834819..f4e2c178640 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -52,13 +52,12 @@ class Product < ApplicationRecord scope :ascending_by_date_of_publishing_and_id, -> { order(published_at: :asc, id: :asc) } scope :order_for_self_assigned_list, -> { order('commented_at asc nulls first, published_at asc') } scope :unchecked_no_replied_products, lambda { - self_last_commented_products = where.not(commented_at: nil).select do |product| + self_last_commented_products = where.not(commented_at: nil).filter do |product| product.comments.last.user_id == product.user.id end no_comments_products = where(commented_at: nil) no_replied_products_ids = (self_last_commented_products + no_comments_products).map(&:id) - where(id: no_replied_products_ids) - .order(published_at: :asc, id: :asc) + where(id: no_replied_products_ids).order(published_at: :asc, id: :asc) } scope :unhibernated_user_products, -> { joins(:user).where(user: { hibernated_at: nil }) } From 882a477aabbd7bb2babf3ea6312971f8733e10fe Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 14:33:31 +0900 Subject: [PATCH 20/79] =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E4=BA=86=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E6=9C=9F=E5=BE=85=E5=80=A4=E3=82=92=E8=AA=AC=E6=98=8E?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=AB=E5=85=A5=E3=82=8C=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index cd1cb347ed9..09344904047 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -203,7 +203,8 @@ class Product::UncheckedTest < ApplicationSystemTestCase test 'the number of products in the unchecked tab is excepted hiberanated user' do visit_with_auth '/products/unchecked', 'komagata' - assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count})" + expected_count = Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count + assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{expected_count})" end test 'unchecked products is excepted hiberanated user' do From 8ed9a323fae598eda9df0e1592eec3e3fa6e589d Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 14:39:51 +0900 Subject: [PATCH 21/79] =?UTF-8?q?=E3=80=8C=E5=85=A8=E3=81=A6=E3=80=8D?= =?UTF-8?q?=E3=80=8C=E6=9C=AA=E5=AE=8C=E4=BA=86/=E6=9C=AA=E8=BF=94?= =?UTF-8?q?=E4=BF=A1=E3=80=8D=E3=82=BF=E3=83=96=E3=81=AB=E5=AF=BE=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=83=86=E3=82=B9=E3=83=88=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=82=8F=E3=81=8B=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 09344904047..5dabef228be 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -208,17 +208,21 @@ class Product::UncheckedTest < ApplicationSystemTestCase end test 'unchecked products is excepted hiberanated user' do - user = users(:kyuukai) - product_hiberanated_user_name = "#{user.login_name} (#{user.name_kana})" + hiberanated_user = users(:kyuukai) + product_hiberanated_user_name = "#{hiberanated_user.login_name} (#{hiberanated_user.name_kana})" + # 「全て」タブの確認 :1ページ目 visit_with_auth '/products/unchecked', 'komagata' # assert_no_text だとデータが読み込まれる前に実行され常に成立してしまうため、明示的に待機する has_text? を使用する assert_not has_text?(product_hiberanated_user_name) + # 「全て」タブの確認 :2ページ目 first('.pagination__item-link', text: '2').click assert_not has_text?(product_hiberanated_user_name) + # 「未返信」タブの確認 :1ページ目 visit_with_auth '/products/unchecked?target=unchecked_no_replied', 'komagata' assert_not has_text?(product_hiberanated_user_name) + # 「未返信」タブの確認 :2ページ目 first('.pagination__item-link', text: '2').click assert_not has_text?(product_hiberanated_user_name) end From 3980ff34260d3e7a53e306dc26d220ae128a6251 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 22:37:47 +0900 Subject: [PATCH 22/79] =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AF=E3=83=A2=E3=83=87=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=81=B8=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/product_test.rb | 5 +++++ test/system/product/unchecked_test.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 71094272f7e..2982d2333dc 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -199,4 +199,9 @@ class ProductTest < ActiveSupport::TestCase wip_product.update!(body: 'product is updated.', wip: false, published_at: Time.current) assert_not wip_product.updated_after_submission? end + + test '#unhibernated_user_products' do + expected_count = Product.joins(:user).where(user: { hibernated_at: nil }).count + assert_equal expected_count, Product.unhibernated_user_products.count + end end diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 5dabef228be..32beaf45c68 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -203,7 +203,7 @@ class Product::UncheckedTest < ApplicationSystemTestCase test 'the number of products in the unchecked tab is excepted hiberanated user' do visit_with_auth '/products/unchecked', 'komagata' - expected_count = Product.joins(:user).where(user: { hibernated_at: nil }).unchecked.not_wip.count + expected_count = Product.unhibernated_user_products.unchecked.not_wip.count assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{expected_count})" end From a7b53a8cf638fd3907c95014f0e52075e3a3a776 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 23:00:01 +0900 Subject: [PATCH 23/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=81=AE=E6=8F=90=E5=87=BA=E7=89=A9=E3=82=92?= =?UTF-8?q?=E6=98=8E=E7=A4=BA=E7=9A=84=E3=81=AB=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 休会中ユーザの提出物を明示的に作成することでそもそも休会中ユーザの提出物がないという状況をなくし、正常に動作しているかの確認を行わせる。 --- test/system/product/unchecked_test.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index 32beaf45c68..a6bb8988f8e 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -207,22 +207,27 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{expected_count})" end - test 'unchecked products is excepted hiberanated user' do + test 'unchecked products is excepted unhiberanated user' do hiberanated_user = users(:kyuukai) + practice = practices(:practice47) + + Product.create!( + body: 'hiberanated user product.', + user: hiberanated_user, + practice: practice, + checker_id: nil + ) + product_hiberanated_user_name = "#{hiberanated_user.login_name} (#{hiberanated_user.name_kana})" - # 「全て」タブの確認 :1ページ目 visit_with_auth '/products/unchecked', 'komagata' # assert_no_text だとデータが読み込まれる前に実行され常に成立してしまうため、明示的に待機する has_text? を使用する assert_not has_text?(product_hiberanated_user_name) - # 「全て」タブの確認 :2ページ目 first('.pagination__item-link', text: '2').click assert_not has_text?(product_hiberanated_user_name) - # 「未返信」タブの確認 :1ページ目 visit_with_auth '/products/unchecked?target=unchecked_no_replied', 'komagata' assert_not has_text?(product_hiberanated_user_name) - # 「未返信」タブの確認 :2ページ目 first('.pagination__item-link', text: '2').click assert_not has_text?(product_hiberanated_user_name) end From ddb5aad4a494b6251742e1980783175dddb045f3 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 23:15:05 +0900 Subject: [PATCH 24/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/product_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 2982d2333dc..c167c48523a 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -200,7 +200,7 @@ class ProductTest < ActiveSupport::TestCase assert_not wip_product.updated_after_submission? end - test '#unhibernated_user_products' do + test 'unhibernated user products' do expected_count = Product.joins(:user).where(user: { hibernated_at: nil }).count assert_equal expected_count, Product.unhibernated_user_products.count end From f897920b46cc49148f933a7bbaa4e6309758f623 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sat, 16 Dec 2023 23:16:41 +0900 Subject: [PATCH 25/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E5=90=8D=E3=81=AB=E8=AA=A4=E3=82=8A=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index a6bb8988f8e..b8cfdf2d05e 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -201,7 +201,7 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_no_selector '.card-list-item__assignee-name', text: 'machida' end - test 'the number of products in the unchecked tab is excepted hiberanated user' do + test 'the number of products in the unchecked tab is excepted unhiberanated user' do visit_with_auth '/products/unchecked', 'komagata' expected_count = Product.unhibernated_user_products.unchecked.not_wip.count assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{expected_count})" From 65ee1918810faab7cb763440c43b8e91dd8fd38a Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Tue, 5 Dec 2023 21:21:57 +0900 Subject: [PATCH 26/79] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6=E4=BC=91?= =?UTF-8?q?=E4=BC=9A=E4=B8=AD=E3=81=AE=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E4=BC=91=E4=BC=9A=E7=B5=8C=E9=81=8E=E6=97=A5=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 15 +++++++++------ app/models/user.rb | 4 ++++ app/views/api/users/_list_user.json.jbuilder | 5 +++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index 2e41b00ec5f..e1c7ac7fe82 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -6,6 +6,9 @@ v-if='currentUser.mentor && user.student_or_trainee && !user.active') | 1ヶ月以上ログインがありません header.users-item__header + div( + v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') + | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__header-inner .users-item__header-start .users-item__icon @@ -16,12 +19,12 @@ :alt='user.icon_title', :src='user.avatar_url') .users-item__header-end - .card-list-item__rows - .card-list-item__row - .card-list-item-title - a.card-list-item-title__title.is-lg.a-text-link( - :href='user.url') - | {{ loginName }} + .card-list-item__rows + .card-list-item__row + .card-list-item-title + a.card-list-item-title__title.is-lg.a-text-link( + :href='user.url') + | {{ loginName }} a( v-if='user.company && user.company.logo_url', :href='user.company.url') diff --git a/app/models/user.rb b/app/models/user.rb index 87b327f8cd7..b604d7028c3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -712,6 +712,10 @@ def last_hibernation hibernations.order(:created_at).last end + def hibernation_elapsed_days + (Time.zone.today - hibernated_at.to_date).to_i + end + def update_last_returned_at! hibernation = last_hibernation hibernation.returned_at = Date.current diff --git a/app/views/api/users/_list_user.json.jbuilder b/app/views/api/users/_list_user.json.jbuilder index 78fc3bd8f14..88d5ba5e72d 100644 --- a/app/views/api/users/_list_user.json.jbuilder +++ b/app/views/api/users/_list_user.json.jbuilder @@ -39,3 +39,8 @@ json.company do json.url company_url(user.company) end end + +if user.hibernated? + json.hibernated_at l(user.hibernated_at, format: :year_and_date) + json.hibernation_elapsed_days user.hibernation_elapsed_days +end From 74a94d1644dae031d96f64c9e05c6ad4d05b7ebd Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Thu, 7 Dec 2023 09:02:24 +0900 Subject: [PATCH 27/79] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=A8=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index e1c7ac7fe82..aadd7cafef7 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -6,7 +6,7 @@ v-if='currentUser.mentor && user.student_or_trainee && !user.active') | 1ヶ月以上ログインがありません header.users-item__header - div( + .is-only-mentor( v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__header-inner @@ -19,12 +19,12 @@ :alt='user.icon_title', :src='user.avatar_url') .users-item__header-end - .card-list-item__rows - .card-list-item__row - .card-list-item-title - a.card-list-item-title__title.is-lg.a-text-link( - :href='user.url') - | {{ loginName }} + .card-list-item__rows + .card-list-item__row + .card-list-item-title + a.card-list-item-title__title.is-lg.a-text-link( + :href='user.url') + | {{ loginName }} a( v-if='user.company && user.company.logo_url', :href='user.company.url') From 19aca7090ad36c6b830c62d7fe99225c5ba34fe0 Mon Sep 17 00:00:00 2001 From: machida Date: Sat, 16 Dec 2023 18:02:17 +0900 Subject: [PATCH 28/79] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=86=E5=B2=90?= =?UTF-8?q?=E3=81=A8=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3=E3=82=92=E5=BE=AE?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 13 +++++++------ .../application/blocks/user/_users-item.sass | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index aadd7cafef7..07da6c56ff4 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,13 +2,14 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message.is-only-mentor( - v-if='currentUser.mentor && user.student_or_trainee && !user.active') - | 1ヶ月以上ログインがありません - header.users-item__header - .is-only-mentor( - v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') + .users-item__inactive-message-container(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message.is-only-mentor(v-if='user.roles.includes("retired")') + | 退会しました + .users-item__inactive-message.is-only-mentor(v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) + .users-item__inactive-message.is-only-mentor(v-else-if='!user.active') + | 1ヶ月以上ログインがありません + header.users-item__header .users-item__header-inner .users-item__header-start .users-item__icon diff --git a/app/javascript/stylesheets/application/blocks/user/_users-item.sass b/app/javascript/stylesheets/application/blocks/user/_users-item.sass index 19daf3998d2..08600e85124 100644 --- a/app/javascript/stylesheets/application/blocks/user/_users-item.sass +++ b/app/javascript/stylesheets/application/blocks/user/_users-item.sass @@ -2,11 +2,11 @@ height: 100% .users-item__inactive-message - background-color: var(--background) + background-color: var(--disabled) +text-block(.625rem 1.4, center) padding: .25rem +border-radius(top, .1875rem) - margin-bottom: -.25rem + margin: -1px -1px -.25rem .users-item__inner +media-breakpoint-up(md) From 57699f0d624a3dd0c5122d87e996bf8ab642763f Mon Sep 17 00:00:00 2001 From: machida Date: Sat, 16 Dec 2023 18:05:26 +0900 Subject: [PATCH 29/79] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E3=81=AB=E3=81=AF=E9=9A=A0=E3=81=99=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E3=81=AB=E4=BD=BF=E3=81=86=E3=82=AF?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E4=BB=98=E3=81=AE=E4=BD=8D=E7=BD=AE=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=81=E4=BD=99=E7=99=BD=E5=BE=AE=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 8 ++++---- .../stylesheets/application/blocks/user/_users-item.sass | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index 07da6c56ff4..c1dfa90a3ff 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,12 +2,12 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message-container(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') - .users-item__inactive-message.is-only-mentor(v-if='user.roles.includes("retired")') + .users-item__inactive-message-container.is-only-mentor(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message(v-if='user.roles.includes("retired")') | 退会しました - .users-item__inactive-message.is-only-mentor(v-else-if='user.roles.includes("hibernationed")') + .users-item__inactive-message(v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) - .users-item__inactive-message.is-only-mentor(v-else-if='!user.active') + .users-item__inactive-message(v-else-if='!user.active') | 1ヶ月以上ログインがありません header.users-item__header .users-item__header-inner diff --git a/app/javascript/stylesheets/application/blocks/user/_users-item.sass b/app/javascript/stylesheets/application/blocks/user/_users-item.sass index 08600e85124..32ac6317bb2 100644 --- a/app/javascript/stylesheets/application/blocks/user/_users-item.sass +++ b/app/javascript/stylesheets/application/blocks/user/_users-item.sass @@ -16,7 +16,7 @@ .users-item__header +position(relative) - padding: 1rem + padding: .75rem 1rem border-bottom: solid 1px var(--border-tint) .users-item__header-inner From 9d9e56658bce42718eadc616f09082598f3f078b Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sun, 17 Dec 2023 14:44:48 +0900 Subject: [PATCH 30/79] =?UTF-8?q?vue=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index c1dfa90a3ff..ef8e49fa2c8 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,10 +2,12 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message-container.is-only-mentor(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message-container.is-only-mentor( + v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') .users-item__inactive-message(v-if='user.roles.includes("retired")') | 退会しました - .users-item__inactive-message(v-else-if='user.roles.includes("hibernationed")') + .users-item__inactive-message( + v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__inactive-message(v-else-if='!user.active') | 1ヶ月以上ログインがありません From 3f9e802055a9eb1c2ce7e77522bb41c6fcaabe5d Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sun, 17 Dec 2023 21:25:13 +0900 Subject: [PATCH 31/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/user_test.rb | 10 ++++++++++ test/system/users_test.rb | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 10fd634aa2a..0c3de7535f7 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -623,6 +623,16 @@ class UserTest < ActiveSupport::TestCase assert target.sent_student_followup_message end + test '#hibernation_elapsed_days' do + user = users(:kyuukai) + + travel_to Time.zone.local(2020, 1, 10) do + elapsed_days = user.hibernation_elapsed_days + + assert assert_equal 9, elapsed_days + end + end + test '#country_name' do assert_equal '日本', users(:kimura).country_name assert_equal '米国', users(:tom).country_name diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 589349354a3..5cd191b74a8 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -629,4 +629,18 @@ class UsersTest < ApplicationSystemTestCase visit_with_auth user_path(user), 'komagata' assert_no_text '休会中 / 休会から' end + + test 'show retirement message on users page' do + visit_with_auth users_path, 'komagata' + click_link('退会') + assert_selector '.users-item__inactive-message-container.is-only-mentor .users-item__inactive-message', text: '退会しました' + end + + test 'show hibernation elasped days message on users page' do + travel_to Time.zone.local(2020, 1, 11, 0, 0, 0) do + visit_with_auth users_path, 'komagata' + click_link('休会') + assert_selector '.users-item__inactive-message-container.is-only-mentor .users-item__inactive-message', text: '休会中: 2020年01月01日〜(10日経過)' + end + end end From 3f12f33090cb5a71dc4837f47e26c80e6f0e5320 Mon Sep 17 00:00:00 2001 From: goruchan Date: Sun, 17 Dec 2023 21:56:10 +0900 Subject: [PATCH 32/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E5=90=8D=E3=81=AE=E5=86=85=E5=AE=B9=E3=81=8C?= =?UTF-8?q?=E5=AE=9F=E6=85=8B=E3=81=A8=E7=95=B0=E3=81=AA=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/product/unchecked_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/system/product/unchecked_test.rb b/test/system/product/unchecked_test.rb index b8cfdf2d05e..201ab567701 100644 --- a/test/system/product/unchecked_test.rb +++ b/test/system/product/unchecked_test.rb @@ -201,13 +201,13 @@ class Product::UncheckedTest < ApplicationSystemTestCase assert_no_selector '.card-list-item__assignee-name', text: 'machida' end - test 'the number of products in the unchecked tab is excepted unhiberanated user' do + test 'the number of products in the unchecked tab is excepted hiberanated user' do visit_with_auth '/products/unchecked', 'komagata' expected_count = Product.unhibernated_user_products.unchecked.not_wip.count assert_selector '.page-tabs__item-link.is-active', text: "未完了 (#{expected_count})" end - test 'unchecked products is excepted unhiberanated user' do + test 'unchecked products is excepted hiberanated user' do hiberanated_user = users(:kyuukai) practice = practices(:practice47) From ee56b0bc56270a07e42edfa7fe18009e657878bc Mon Sep 17 00:00:00 2001 From: goruchan Date: Sun, 17 Dec 2023 21:57:19 +0900 Subject: [PATCH 33/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E4=B8=AD=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E6=8A=BD=E5=87=BA=E3=82=B9=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=97=E3=81=8C=E6=AD=A3=E3=81=97=E3=81=8F=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E3=81=8B=E3=82=92=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=81=99=E3=82=8B=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/product_test.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/models/product_test.rb b/test/models/product_test.rb index c167c48523a..0947d894a5d 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -201,7 +201,16 @@ class ProductTest < ActiveSupport::TestCase end test 'unhibernated user products' do - expected_count = Product.joins(:user).where(user: { hibernated_at: nil }).count - assert_equal expected_count, Product.unhibernated_user_products.count + hiberanated_user = users(:kyuukai) + + hibernated_user_product = Product.create!( + body: "hibernated user's product.", + user: hiberanated_user, + practice: practices(:practice7), + checker_id: nil + ) + + assert_includes Product.all, hibernated_user_product + assert_not_includes Product.unhibernated_user_products, hibernated_user_product end end From beb332c52b5ce6c241a5c6c3617aabac204e069a Mon Sep 17 00:00:00 2001 From: naokinaokiboo Date: Tue, 19 Dec 2023 18:06:44 +0900 Subject: [PATCH 34/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E4=BA=86=E3=82=BF=E3=83=96=E3=81=AE=E7=B5=9E?= =?UTF-8?q?=E3=82=8A=E8=BE=BC=E3=81=BF=E3=81=AE=E9=A0=86=E7=95=AA=E3=82=92?= =?UTF-8?q?=E9=80=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/components/Products.jsx b/app/javascript/components/Products.jsx index 91a67212c25..7b3654858c3 100644 --- a/app/javascript/components/Products.jsx +++ b/app/javascript/components/Products.jsx @@ -234,7 +234,7 @@ const FilterButtons = ({ selectedTab }) => { if (selectedTab === 'self_assigned') { targets = ['self_assigned_no_replied', 'self_assigned_all'] } else { - targets = ['unchecked_no_replied', 'unchecked_all'] + targets = ['unchecked_all', 'unchecked_no_replied'] } const filterButtonUrl = ({ selectedTab, target }) => { From 9d43560b0ac21b9ea236e464e3bb76ca0df5b676 Mon Sep 17 00:00:00 2001 From: naokinaokiboo Date: Tue, 19 Dec 2023 22:33:43 +0900 Subject: [PATCH 35/79] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=88=86=E3=81=AE=E6=8B=85=E5=BD=93=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=81=AE=E7=B5=9E=E3=82=8A=E8=BE=BC=E3=81=BF=E3=81=AE=E9=A0=86?= =?UTF-8?q?=E7=95=AA=E3=82=92=E9=80=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/components/Products.jsx b/app/javascript/components/Products.jsx index 91a67212c25..b4013bf4e4b 100644 --- a/app/javascript/components/Products.jsx +++ b/app/javascript/components/Products.jsx @@ -232,7 +232,7 @@ function ProductHeader({ const FilterButtons = ({ selectedTab }) => { let targets if (selectedTab === 'self_assigned') { - targets = ['self_assigned_no_replied', 'self_assigned_all'] + targets = ['self_assigned_all', 'self_assigned_no_replied'] } else { targets = ['unchecked_no_replied', 'unchecked_all'] } From e6b480c8a350c3350eea8b6ea5e42a4545401c23 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sat, 4 Nov 2023 10:39:53 +0900 Subject: [PATCH 36/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=89=E5=AE=9A=E6=9C=9F=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=E4=B8=BB=E5=82=AC=E8=80=85=E3=81=8Ckomagata=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 1 + app/controllers/regular_events_controller.rb | 9 +++++++++ app/models/regular_event.rb | 8 ++++++++ app/models/user.rb | 9 +++++++++ 4 files changed, 27 insertions(+) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index ca32de380cd..c2e43900cb2 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,6 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins + current_user.delete_organizer logout redirect_to hibernation_path else diff --git a/app/controllers/regular_events_controller.rb b/app/controllers/regular_events_controller.rb index d1fd907d0a5..edad6a51618 100644 --- a/app/controllers/regular_events_controller.rb +++ b/app/controllers/regular_events_controller.rb @@ -120,4 +120,13 @@ def set_all_user_participants_and_watchers RegularEvent::ParticipantsCreator.call(regular_event: @regular_event, target: students_trainees_mentors_and_admins) RegularEvent::ParticipantsWatcher.call(regular_event: @regular_event, target: students_trainees_mentors_and_admins) end + + def assign_admin_as_organizer_if_none + return if @regular_event.organizers.exists? + + # 管理者(komagata)をデータベースから検索 + admin_user = User.active.find_by(login_name: 'komagata') + # 管理者を主催者として割り当てる + @regular_event.organizers.create(user: admin_user) if admin_user + end end diff --git a/app/models/regular_event.rb b/app/models/regular_event.rb index 046132d17aa..02196813c7a 100644 --- a/app/models/regular_event.rb +++ b/app/models/regular_event.rb @@ -185,6 +185,14 @@ def remove_event(events_arr, id) end end + def assign_admin_as_organizer_if_none + return if organizers.exists? + # DBから管理者(komagata)を取得 + admin_user = User.find_by(login_name: 'komagata') + # 管理者が存在する場合にのみ主催者として追加 + Organizer.new(user: admin_user, regular_event: self).save if admin_user + end + private def end_at_be_greater_than_start_at diff --git a/app/models/user.rb b/app/models/user.rb index 87b327f8cd7..fb2a7a97b8d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -755,6 +755,15 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end + def delete_organizer + organizers = self.organizers + organizers.each do |organizer| + event = organizer.regular_event + organizer.delete + event.assign_admin_as_organizer_if_none + end + end + private def password_required? From 53f813fa8628029f8c36af763e42c5906a85add7 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sat, 4 Nov 2023 12:02:58 +0900 Subject: [PATCH 37/79] =?UTF-8?q?=E9=80=80=E4=BC=9A=E3=81=97=E3=81=9F?= =?UTF-8?q?=E6=99=82=E3=81=AE=E5=AE=9A=E6=9C=9F=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E4=B8=BB=E5=82=AC=E8=80=85=E3=81=AE=E5=89=B2=E3=82=8A?= =?UTF-8?q?=E5=BD=93=E3=81=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/regular_events_controller.rb | 9 ------ app/controllers/retirement_controller.rb | 1 + app/models/regular_event.rb | 3 +- test/fixtures/regular_events.yml | 11 +++++++ test/models/regular_event_test.rb | 9 ++++++ test/models/user_test.rb | 8 +++++ test/system/hibernation_test.rb | 34 ++++++++++++++++++++ 7 files changed, 64 insertions(+), 11 deletions(-) diff --git a/app/controllers/regular_events_controller.rb b/app/controllers/regular_events_controller.rb index edad6a51618..d1fd907d0a5 100644 --- a/app/controllers/regular_events_controller.rb +++ b/app/controllers/regular_events_controller.rb @@ -120,13 +120,4 @@ def set_all_user_participants_and_watchers RegularEvent::ParticipantsCreator.call(regular_event: @regular_event, target: students_trainees_mentors_and_admins) RegularEvent::ParticipantsWatcher.call(regular_event: @regular_event, target: students_trainees_mentors_and_admins) end - - def assign_admin_as_organizer_if_none - return if @regular_event.organizers.exists? - - # 管理者(komagata)をデータベースから検索 - admin_user = User.active.find_by(login_name: 'komagata') - # 管理者を主催者として割り当てる - @regular_event.organizers.create(user: admin_user) if admin_user - end end diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index b633f862de0..5f115c58de7 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,6 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user + current_user.delete_organizer Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now diff --git a/app/models/regular_event.rb b/app/models/regular_event.rb index 02196813c7a..48e62aebd52 100644 --- a/app/models/regular_event.rb +++ b/app/models/regular_event.rb @@ -187,9 +187,8 @@ def remove_event(events_arr, id) def assign_admin_as_organizer_if_none return if organizers.exists? - # DBから管理者(komagata)を取得 + admin_user = User.find_by(login_name: 'komagata') - # 管理者が存在する場合にのみ主催者として追加 Organizer.new(user: admin_user, regular_event: self).save if admin_user end diff --git a/test/fixtures/regular_events.yml b/test/fixtures/regular_events.yml index 3c15d904384..3673ecd50da 100644 --- a/test/fixtures/regular_events.yml +++ b/test/fixtures/regular_events.yml @@ -155,3 +155,14 @@ regular_event32: user: komagata category: 0 published_at: "2023-08-01 00:00:00" + +regular_event33: + title: 主催者のいないイベント + description: 主催者のいないイベント + finished: false + hold_national_holiday: false + start_at: <%= Time.zone.local(2020, 1, 1, 21, 0, 0) %> + end_at: <%= Time.zone.local(2020, 1, 1, 22, 0, 0) %> + user: kimura + category: 0 + published_at: "2023-08-01 00:00:00" diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index b80627c5768..90709c92746 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -155,4 +155,13 @@ class RegularEventTest < ActiveSupport::TestCase assert regular_events1.include?(regular_event2) assert regular_events2.include?(regular_event3) end + + test '#assign_admin_as_organizer_if_none' do + + regular_event = regular_events(:regular_event33) + regular_event.assign_admin_as_organizer_if_none + assert User.find_by(login_name: 'komagata'), regular_event.organizers[0] + end + + end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 10fd634aa2a..e1102226eb8 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -678,4 +678,12 @@ class UserTest < ActiveSupport::TestCase assert_equal User.students_and_trainees, User.users_role(not_scope_name, allowed_targets: allowed_targets, default_target: 'student_and_trainee') assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) end + + test '#delete_organizer' do + user = users(:hajime) + user.delete_organizer + + event = regular_events(:regular_event4) + assert !event.organizers.include?(user) + end end diff --git a/test/system/hibernation_test.rb b/test/system/hibernation_test.rb index c19a7300e89..8bcef514834 100644 --- a/test/system/hibernation_test.rb +++ b/test/system/hibernation_test.rb @@ -37,4 +37,38 @@ class HibernationTest < ApplicationSystemTestCase page.driver.browser.switch_to.alert.accept assert_text '復帰予定日を入力してください' end + + test 'hibernate with event organizer' do + visit_with_auth new_hibernation_path, 'hajime' + within('form[name=hibernation]') do + fill_in( + 'hibernation[scheduled_return_on]', + with: (Date.current + 30) + ) + fill_in('hibernation[reason]', with: 'test') + end + click_on '休会する' + page.driver.browser.switch_to.alert.accept + assert_text '休会処理が完了しました' + + regular_event = regular_event(regular_event4) + visit_with_auth "regular_events/#{regular_event.id}", 'kimura' + assert_no_selector 'is-hajime' + + visit_with_auth new_hibernation_path, 'kimura' + within('form[name=hibernation]') do + fill_in( + 'hibernation[scheduled_return_on]', + with: (Date.current + 30) + ) + fill_in('hibernation[reason]', with: 'test') + end + click_on '休会する' + page.driver.browser.switch_to.alert.accept + assert_text '休会処理が完了しました' + + visit_with_auth "regular_events/#{regular_event.id}", 'komagata' + assert_no_selector 'is-kimura' + assert_selector 'is-komagata' + end end From ef80d89f7ef960c9d452024555152bbc4189f907 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sun, 5 Nov 2023 12:32:06 +0900 Subject: [PATCH 38/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E8=BF=BD=E5=8A=A0=E3=81=A8=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/regular_event_test.rb | 3 --- test/models/user_test.rb | 2 +- test/system/hibernation_test.rb | 10 ++++++---- test/system/retirement_test.rb | 22 ++++++++++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index 90709c92746..491b4a54cab 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -157,11 +157,8 @@ class RegularEventTest < ActiveSupport::TestCase end test '#assign_admin_as_organizer_if_none' do - regular_event = regular_events(:regular_event33) regular_event.assign_admin_as_organizer_if_none assert User.find_by(login_name: 'komagata'), regular_event.organizers[0] end - - end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index e1102226eb8..6c11ce92350 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -684,6 +684,6 @@ class UserTest < ActiveSupport::TestCase user.delete_organizer event = regular_events(:regular_event4) - assert !event.organizers.include?(user) + assert_not event.organizers.include?(user) end end diff --git a/test/system/hibernation_test.rb b/test/system/hibernation_test.rb index 8bcef514834..0aa033b42bd 100644 --- a/test/system/hibernation_test.rb +++ b/test/system/hibernation_test.rb @@ -47,13 +47,14 @@ class HibernationTest < ApplicationSystemTestCase ) fill_in('hibernation[reason]', with: 'test') end + find('.check-box-to-read').click click_on '休会する' page.driver.browser.switch_to.alert.accept assert_text '休会処理が完了しました' - regular_event = regular_event(regular_event4) + regular_event = regular_events(:regular_event4) visit_with_auth "regular_events/#{regular_event.id}", 'kimura' - assert_no_selector 'is-hajime' + assert_no_selector '.is-hajime' visit_with_auth new_hibernation_path, 'kimura' within('form[name=hibernation]') do @@ -63,12 +64,13 @@ class HibernationTest < ApplicationSystemTestCase ) fill_in('hibernation[reason]', with: 'test') end + find('.check-box-to-read').click click_on '休会する' page.driver.browser.switch_to.alert.accept assert_text '休会処理が完了しました' visit_with_auth "regular_events/#{regular_event.id}", 'komagata' - assert_no_selector 'is-kimura' - assert_selector 'is-komagata' + assert_no_selector '.is-kimura' + assert_selector '.is-komagata' end end diff --git a/test/system/retirement_test.rb b/test/system/retirement_test.rb index e8b2376cd3b..a35521a25e8 100644 --- a/test/system/retirement_test.rb +++ b/test/system/retirement_test.rb @@ -185,4 +185,26 @@ class RetirementTest < ApplicationSystemTestCase visit '/retirement' assert_equal 'FJORD BOOT CAMP(フィヨルドブートキャンプ)', title end + + test 'retirement with event organizer' do + visit_with_auth new_retirement_path, 'hajime' + find('label', text: 'とても良い').click + click_on '退会する' + page.driver.browser.switch_to.alert.accept + assert_text '退会処理が完了しました' + + regular_event = regular_events(:regular_event4) + visit_with_auth "regular_events/#{regular_event.id}", 'kimura' + assert_no_selector '.is-hajime' + + visit_with_auth new_retirement_path, 'kimura' + find('label', text: 'とても良い').click + click_on '退会する' + page.driver.browser.switch_to.alert.accept + assert_text '退会処理が完了しました' + + visit_with_auth "regular_events/#{regular_event.id}", 'komagata' + assert_no_selector '.is-kimura' + assert_selector '.is-komagata' + end end From 4e9b976abd02a9303238a63301af551356930971 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:55:25 +0900 Subject: [PATCH 39/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=80=81=E9=80=80?= =?UTF-8?q?=E4=BC=9A=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=81=AB=E8=87=AA?= =?UTF-8?q?=E5=88=86=E3=81=8C=E4=B8=BB=E5=82=AC=E3=81=AE=E5=AE=9A=E6=9C=9F?= =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=81=8C=E3=81=82=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81=E4=BB=BB=E6=84=8F=E3=81=A7=E5=88=A5?= =?UTF-8?q?=E3=81=AE=E5=8F=82=E5=8A=A0=E8=80=85=E3=81=AB=E4=B8=BB=E5=82=AC?= =?UTF-8?q?=E8=80=85=E5=BC=95=E3=81=8D=E7=B6=99=E3=81=8E=E3=82=92=E6=8E=A8?= =?UTF-8?q?=E5=A5=A8=E3=81=99=E3=82=8B=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=82=92=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/hibernation/new.html.slim | 14 ++++++++++++++ app/views/retirement/new.html.slim | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/views/hibernation/new.html.slim b/app/views/hibernation/new.html.slim index fb04de60331..9b6ee13b2ad 100644 --- a/app/views/hibernation/new.html.slim +++ b/app/views/hibernation/new.html.slim @@ -69,6 +69,20 @@ hr.a-border | こちら | のページの「分報 URL」欄に分報チャンネルの URL を登録してください。 + - if current_user.regular_events.any? + .form-item + label.a-form-label + | 定期イベント + .important-message + .important-message__body + .a-short-text.is-sm + p + |ご自身が主催者である定期イベントがあります。 + | 休会をお考えの場合、イベントの進行に影響がないよう、任意で他の参加者に主催を引き継ぐことを推奨します。 + | 休会手続きを完了する前に、 + = link_to 'こちら', regular_events_path + | からイベント管理を行なってください。 + .form-item label.a-form-label.is-required | 休会についての注意を読みましたか? diff --git a/app/views/retirement/new.html.slim b/app/views/retirement/new.html.slim index 15df2ab1f23..436712c742e 100644 --- a/app/views/retirement/new.html.slim +++ b/app/views/retirement/new.html.slim @@ -15,6 +15,17 @@ hr.a-border = render 'errors', object: current_user = form_with model: current_user, local: true, url: retirement_path, method: :post, class: 'form' do |f| .form__items + - if current_user.regular_events.any? + .form-item + .important-message + .important-message__body + .a-short-text.is-sm + p + |ご自身が主催者である定期イベントがあります。 + | 退会をお考えの場合、イベントの進行に影響がないよう、任意で他の参加者に主催を引き継ぐことを推奨します。 + | 退会手続きを完了する前に、 + = link_to 'こちら', regular_events_path + | からイベント管理を行ってください。 .form-item = f.label :retire_reasons, '退会の理由を教えてください(複数選択可)', class: 'a-form-label' .checkboxes From 94c2bc0465f0f5e2297f9408fb79d947e75bda46 Mon Sep 17 00:00:00 2001 From: machida Date: Tue, 21 Nov 2023 02:27:01 +0900 Subject: [PATCH 40/79] =?UTF-8?q?=E9=80=80=E4=BC=9A=E3=80=81=E4=BC=91?= =?UTF-8?q?=E4=BC=9A=E6=99=82=E3=81=AE=E5=AE=9A=E6=9C=9F=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E7=AE=A1=E7=90=86=E8=80=85=E3=81=B8=E3=81=AE?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E5=BE=AE?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/hibernation/new.html.slim | 10 +++++++--- app/views/retirement/new.html.slim | 10 ++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/views/hibernation/new.html.slim b/app/views/hibernation/new.html.slim index 9b6ee13b2ad..2fa508b6b4f 100644 --- a/app/views/hibernation/new.html.slim +++ b/app/views/hibernation/new.html.slim @@ -78,10 +78,14 @@ hr.a-border .a-short-text.is-sm p |ご自身が主催者である定期イベントがあります。 + br | 休会をお考えの場合、イベントの進行に影響がないよう、任意で他の参加者に主催を引き継ぐことを推奨します。 - | 休会手続きを完了する前に、 - = link_to 'こちら', regular_events_path - | からイベント管理を行なってください。 + | 休会手続きを完了する前に、以下のリンク先でイベント設定変更を行なってください。 + ul + - current_user.regular_events.each do |event| + li + = link_to edit_regular_event_path(event), target: '_blank', rel: 'noopener' do + | 定期イベント「#{event.title}」の設定変更 .form-item label.a-form-label.is-required diff --git a/app/views/retirement/new.html.slim b/app/views/retirement/new.html.slim index 436712c742e..93124aab0c0 100644 --- a/app/views/retirement/new.html.slim +++ b/app/views/retirement/new.html.slim @@ -22,10 +22,16 @@ hr.a-border .a-short-text.is-sm p |ご自身が主催者である定期イベントがあります。 + br | 退会をお考えの場合、イベントの進行に影響がないよう、任意で他の参加者に主催を引き継ぐことを推奨します。 | 退会手続きを完了する前に、 - = link_to 'こちら', regular_events_path - | からイベント管理を行ってください。 + | 以下のリンク先でイベント設定変更を行なってください。 + ul + - current_user.regular_events.each do |event| + li + = link_to edit_regular_event_path(event), target: '_blank', rel: 'noopener' do + | 定期イベント「#{event.title}」の設定変更 + .form-item = f.label :retire_reasons, '退会の理由を教えてください(複数選択可)', class: 'a-form-label' .checkboxes From 746373904d3208345001d3975be020968c6996ee Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Tue, 21 Nov 2023 17:51:50 +0900 Subject: [PATCH 41/79] =?UTF-8?q?.card-list-item=E3=81=AE=E8=A6=81?= =?UTF-8?q?=E7=B4=A0=E6=95=B0=E3=82=928=E5=80=8B=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/regular_events_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/regular_events_test.rb b/test/system/regular_events_test.rb index 8acb4239798..b79fdd9c8ec 100644 --- a/test/system/regular_events_test.rb +++ b/test/system/regular_events_test.rb @@ -180,7 +180,7 @@ class RegularEventsTest < ApplicationSystemTestCase visit_with_auth regular_events_path, 'kimura' assert_selector '.card-list-item', count: 25 visit regular_events_path(page: 2) - assert_selector '.card-list-item', count: 7 + assert_selector '.card-list-item', count: 8 end test 'create a regular event for all students and trainees' do From ae2efb4a87f6af916f2ec565f04de03f7cfd4a1c Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:13:10 +0900 Subject: [PATCH 42/79] =?UTF-8?q?.card-list-item=E3=81=AE=E8=A6=81?= =?UTF-8?q?=E7=B4=A0=E6=95=B0=E3=82=9215=E5=80=8B=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/regular_events_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/regular_events_test.rb b/test/system/regular_events_test.rb index b79fdd9c8ec..670e79910e1 100644 --- a/test/system/regular_events_test.rb +++ b/test/system/regular_events_test.rb @@ -173,7 +173,7 @@ class RegularEventsTest < ApplicationSystemTestCase test 'show listing not finished regular events' do visit_with_auth regular_events_path(target: 'not_finished'), 'kimura' - assert_selector '.card-list-item', count: 14 + assert_selector '.card-list-item', count: 15 end test 'show listing all regular events' do From 47beb79da4ee1f57a0f1720864a484f5e599d1a0 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:03:32 +0900 Subject: [PATCH 43/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/regular_event_test.rb | 2 +- test/models/user_test.rb | 7 ++++--- test/system/retirement_test.rb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index 491b4a54cab..50ca8db2deb 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -159,6 +159,6 @@ class RegularEventTest < ActiveSupport::TestCase test '#assign_admin_as_organizer_if_none' do regular_event = regular_events(:regular_event33) regular_event.assign_admin_as_organizer_if_none - assert User.find_by(login_name: 'komagata'), regular_event.organizers[0] + assert_equal User.find_by(login_name: 'komagata'), regular_event.organizers[0] end end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 6c11ce92350..0bca8cca749 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -681,9 +681,10 @@ class UserTest < ActiveSupport::TestCase test '#delete_organizer' do user = users(:hajime) - user.delete_organizer - event = regular_events(:regular_event4) - assert_not event.organizers.include?(user) + + assert_changes -> { event.organizers.include?(user) }, from: true, to: false do + user.delete_organizer + end end end diff --git a/test/system/retirement_test.rb b/test/system/retirement_test.rb index a35521a25e8..de8b20262cc 100644 --- a/test/system/retirement_test.rb +++ b/test/system/retirement_test.rb @@ -186,7 +186,7 @@ class RetirementTest < ApplicationSystemTestCase assert_equal 'FJORD BOOT CAMP(フィヨルドブートキャンプ)', title end - test 'retirement with event organizer' do + test 'retire with event organizer' do visit_with_auth new_retirement_path, 'hajime' find('label', text: 'とても良い').click click_on '退会する' From 537bdf6e4dd28d2bc9f7db82f1b62a6035bd1925 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:41:22 +0900 Subject: [PATCH 44/79] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E9=80=80=E4=BC=9A=E6=99=82=E3=81=AE=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E4=B8=BB=E5=82=AC=E8=80=85=E5=89=B2=E3=82=8A=E5=BD=93?= =?UTF-8?q?=E3=81=A6=E5=87=A6=E7=90=86=E3=82=92Organizer=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 2 +- app/controllers/retirement_controller.rb | 2 +- app/models/organizer.rb | 6 ++++++ app/models/user.rb | 9 ++------- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index c2e43900cb2..50bee6e37b1 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,7 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins - current_user.delete_organizer + current_user.delete_all_organizer logout redirect_to hibernation_path else diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index 5f115c58de7..c51aa7b1aef 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,7 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user - current_user.delete_organizer + current_user.delete_all_organizer Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now diff --git a/app/models/organizer.rb b/app/models/organizer.rb index 8392e284141..bf6c0ae6149 100644 --- a/app/models/organizer.rb +++ b/app/models/organizer.rb @@ -5,4 +5,10 @@ class Organizer < ApplicationRecord belongs_to :regular_event validates :user_id, uniqueness: { scope: :regular_event_id } + + def delete_and_assign_new + event = regular_event + delete + event.assign_admin_as_organizer_if_none + end end diff --git a/app/models/user.rb b/app/models/user.rb index fb2a7a97b8d..02eb9a23a73 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -755,13 +755,8 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end - def delete_organizer - organizers = self.organizers - organizers.each do |organizer| - event = organizer.regular_event - organizer.delete - event.assign_admin_as_organizer_if_none - end + def delete_all_organizer + organizers.each(&:delete_and_assign_new) end private From 92ec8f12fb58a3ab6d32a19b315e4347bcc62120 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:59:09 +0900 Subject: [PATCH 45/79] =?UTF-8?q?=E8=A4=87=E6=95=B0=E5=BD=A2=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 2 +- app/controllers/retirement_controller.rb | 2 +- app/models/user.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index 50bee6e37b1..374c0881ed1 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,7 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins - current_user.delete_all_organizer + current_user.delete_all_organizers logout redirect_to hibernation_path else diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index c51aa7b1aef..c9267a279e9 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,7 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user - current_user.delete_all_organizer + current_user.delete_all_organizers Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now diff --git a/app/models/user.rb b/app/models/user.rb index 02eb9a23a73..1c2175923d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -755,7 +755,7 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end - def delete_all_organizer + def delete_all_organizers organizers.each(&:delete_and_assign_new) end From c5e4817a8fa43282a48b1a44f4a8dcbe49af2ace Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:00:16 +0900 Subject: [PATCH 46/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/organizer_test.rb | 16 ++++++++++++++++ test/models/user_test.rb | 7 +++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 test/models/organizer_test.rb diff --git a/test/models/organizer_test.rb b/test/models/organizer_test.rb new file mode 100644 index 00000000000..6dde4da1b3a --- /dev/null +++ b/test/models/organizer_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'test_helper' + +class OrganizerTest < ActiveSupport::TestCase + test '#delete_and_assign_new' do + organizer = organizers(:organizer12) + event = organizer.regular_event + + assert_changes -> { Organizer.where(regular_event: event, user: organizer.user).exists? }, from: true, to: false do + organizer.delete_and_assign_new + end + + assert Organizer.where(regular_event: event).exists? + end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 0bca8cca749..65f7ae9ae94 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -679,12 +679,11 @@ class UserTest < ActiveSupport::TestCase assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) end - test '#delete_organizer' do + test '#delete_all_organizers' do user = users(:hajime) - event = regular_events(:regular_event4) - assert_changes -> { event.organizers.include?(user) }, from: true, to: false do - user.delete_organizer + assert_changes -> { Organizer.where(user: user).exists? }, from: true, to: false do + user.delete_all_organizers end end end From bae6ee6f0b3616ba6b9c71bd8f6094429dab3448 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:16:50 +0900 Subject: [PATCH 47/79] =?UTF-8?q?komagata=E3=82=92=E5=AE=9A=E6=95=B0?= =?UTF-8?q?=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/regular_event.rb | 2 +- app/models/user.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/regular_event.rb b/app/models/regular_event.rb index 48e62aebd52..449a2449b19 100644 --- a/app/models/regular_event.rb +++ b/app/models/regular_event.rb @@ -188,7 +188,7 @@ def remove_event(events_arr, id) def assign_admin_as_organizer_if_none return if organizers.exists? - admin_user = User.find_by(login_name: 'komagata') + admin_user = User.find_by(login_name: User::DEFAULT_ADMIN_LOGIN_NAME) Organizer.new(user: admin_user, regular_event: self).save if admin_user end diff --git a/app/models/user.rb b/app/models/user.rb index 1c2175923d1..5404c1a4ac4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,6 +19,7 @@ class User < ApplicationRecord 'adviser' => :advisers, 'trainee' => :trainees }.freeze + DEFAULT_ADMIN_LOGIN_NAME = 'komagata' enum job: { student: 0, From a53b5a7a7e7575f9794776df39b094cbe651e557 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Fri, 15 Dec 2023 13:15:03 +0900 Subject: [PATCH 48/79] =?UTF-8?q?RegularEvent=E3=83=A2=E3=83=87=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fixtures/regular_events.yml | 11 ----------- test/models/regular_event_test.rb | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/fixtures/regular_events.yml b/test/fixtures/regular_events.yml index 3673ecd50da..3c15d904384 100644 --- a/test/fixtures/regular_events.yml +++ b/test/fixtures/regular_events.yml @@ -155,14 +155,3 @@ regular_event32: user: komagata category: 0 published_at: "2023-08-01 00:00:00" - -regular_event33: - title: 主催者のいないイベント - description: 主催者のいないイベント - finished: false - hold_national_holiday: false - start_at: <%= Time.zone.local(2020, 1, 1, 21, 0, 0) %> - end_at: <%= Time.zone.local(2020, 1, 1, 22, 0, 0) %> - user: kimura - category: 0 - published_at: "2023-08-01 00:00:00" diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index 50ca8db2deb..b5fcc531812 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -157,8 +157,19 @@ class RegularEventTest < ActiveSupport::TestCase end test '#assign_admin_as_organizer_if_none' do - regular_event = regular_events(:regular_event33) + regular_event = RegularEvent.new( + title: '主催者のいないイベント', + description: '主催者のいないイベント', + finished: false, + hold_national_holiday: false, + start_at: Time.zone.local(2020, 1, 1, 21, 0, 0), + end_at: Time.zone.local(2020, 1, 1, 22, 0, 0), + user: users(:kimura), + category: 0, + published_at: '2023-08-01 00:00:00' + ) + regular_event.save(validate: false) regular_event.assign_admin_as_organizer_if_none - assert_equal User.find_by(login_name: 'komagata'), regular_event.organizers[0] + assert_equal User.find_by(login_name: User::DEFAULT_ADMIN_LOGIN_NAME), regular_event.organizers.first end end From 7c9f7b4c72c48242faca6b57cb1fc6e8e145f23e Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Fri, 15 Dec 2023 15:00:40 +0900 Subject: [PATCH 49/79] =?UTF-8?q?count=E3=81=AE=E6=95=B0=E3=82=92=E5=90=88?= =?UTF-8?q?=E3=82=8F=E3=81=9B=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/regular_events_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/regular_events_test.rb b/test/system/regular_events_test.rb index 670e79910e1..b79fdd9c8ec 100644 --- a/test/system/regular_events_test.rb +++ b/test/system/regular_events_test.rb @@ -173,7 +173,7 @@ class RegularEventsTest < ApplicationSystemTestCase test 'show listing not finished regular events' do visit_with_auth regular_events_path(target: 'not_finished'), 'kimura' - assert_selector '.card-list-item', count: 15 + assert_selector '.card-list-item', count: 14 end test 'show listing all regular events' do From 54c6f5c06c6a8fff5b00d8b3e62d6c518c2bd73c Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sat, 16 Dec 2023 11:09:49 +0900 Subject: [PATCH 50/79] =?UTF-8?q?=E5=AE=9A=E6=95=B0=E5=90=8D=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/regular_event.rb | 2 +- app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/regular_event.rb b/app/models/regular_event.rb index 449a2449b19..7b89d5b9fbf 100644 --- a/app/models/regular_event.rb +++ b/app/models/regular_event.rb @@ -188,7 +188,7 @@ def remove_event(events_arr, id) def assign_admin_as_organizer_if_none return if organizers.exists? - admin_user = User.find_by(login_name: User::DEFAULT_ADMIN_LOGIN_NAME) + admin_user = User.find_by(login_name: User::DEFAULT_REGULAR_EVENT_ORGANIZER) Organizer.new(user: admin_user, regular_event: self).save if admin_user end diff --git a/app/models/user.rb b/app/models/user.rb index 5404c1a4ac4..b768145a024 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,7 @@ class User < ApplicationRecord 'adviser' => :advisers, 'trainee' => :trainees }.freeze - DEFAULT_ADMIN_LOGIN_NAME = 'komagata' + DEFAULT_REGULAR_EVENT_ORGANIZER = 'komagata' enum job: { student: 0, From 1d64dd5df81b8a42eeedbd5bcf660e8ba389ffa0 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sat, 16 Dec 2023 11:27:33 +0900 Subject: [PATCH 51/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AB?= =?UTF-8?q?=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B=E5=AE=9A=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/regular_event_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/regular_event_test.rb b/test/models/regular_event_test.rb index b5fcc531812..f99016d7162 100644 --- a/test/models/regular_event_test.rb +++ b/test/models/regular_event_test.rb @@ -170,6 +170,6 @@ class RegularEventTest < ActiveSupport::TestCase ) regular_event.save(validate: false) regular_event.assign_admin_as_organizer_if_none - assert_equal User.find_by(login_name: User::DEFAULT_ADMIN_LOGIN_NAME), regular_event.organizers.first + assert_equal User.find_by(login_name: User::DEFAULT_REGULAR_EVENT_ORGANIZER), regular_event.organizers.first end end From 72dd86d59a7e7504128f0aa0024c66bd520d6819 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:14:00 +0900 Subject: [PATCH 52/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=81=BE=E3=81=9F?= =?UTF-8?q?=E3=81=AF=E9=80=80=E4=BC=9A=E3=81=97=E3=81=9F=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E3=81=AE=E5=AE=9A=E6=9C=9F=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E4=B8=BB=E5=82=AC=E8=80=85=E3=82=92?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=80=85=E3=81=AB=E8=87=AA=E5=8B=95=E3=81=A7?= =?UTF-8?q?=E5=89=B2=E3=82=8A=E5=BD=93=E3=81=A6=E3=82=8B=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 7 ++++++- app/controllers/retirement_controller.rb | 7 ++++++- app/models/organizer.rb | 6 ------ app/models/user.rb | 4 ---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index 374c0881ed1..87486d7dfd3 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,7 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins - current_user.delete_all_organizers + assign_admin_as_organizer logout redirect_to hibernation_path else @@ -52,4 +52,9 @@ def notify_to_mentors_and_admins def notify_to_chat DiscordNotifier.with(sender: current_user).hibernated.notify_now end + + def assign_admin_as_organizer + current_user.organizers.destroy_all + current_user.regular_events.each(&:assign_admin_as_organizer_if_none) + end end diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index c9267a279e9..77c19ab3726 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,7 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user - current_user.delete_all_organizers + assign_admin_as_organizer Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now @@ -52,4 +52,9 @@ def notify_to_mentors ActivityDelivery.with(sender: current_user, receiver: mentor_user).notify(:retired) end end + + def assign_admin_as_organizer + current_user.organizers.destroy_all + current_user.regular_events.each(&:assign_admin_as_organizer_if_none) + end end diff --git a/app/models/organizer.rb b/app/models/organizer.rb index bf6c0ae6149..8392e284141 100644 --- a/app/models/organizer.rb +++ b/app/models/organizer.rb @@ -5,10 +5,4 @@ class Organizer < ApplicationRecord belongs_to :regular_event validates :user_id, uniqueness: { scope: :regular_event_id } - - def delete_and_assign_new - event = regular_event - delete - event.assign_admin_as_organizer_if_none - end end diff --git a/app/models/user.rb b/app/models/user.rb index b768145a024..45edcef0a6e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -756,10 +756,6 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end - def delete_all_organizers - organizers.each(&:delete_and_assign_new) - end - private def password_required? From 0fc35c1281494cf8b30e2420e58d270349debfd9 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sun, 17 Dec 2023 11:13:56 +0900 Subject: [PATCH 53/79] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/organizer_test.rb | 16 ---------------- test/models/user_test.rb | 8 -------- 2 files changed, 24 deletions(-) delete mode 100644 test/models/organizer_test.rb diff --git a/test/models/organizer_test.rb b/test/models/organizer_test.rb deleted file mode 100644 index 6dde4da1b3a..00000000000 --- a/test/models/organizer_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -class OrganizerTest < ActiveSupport::TestCase - test '#delete_and_assign_new' do - organizer = organizers(:organizer12) - event = organizer.regular_event - - assert_changes -> { Organizer.where(regular_event: event, user: organizer.user).exists? }, from: true, to: false do - organizer.delete_and_assign_new - end - - assert Organizer.where(regular_event: event).exists? - end -end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 65f7ae9ae94..10fd634aa2a 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -678,12 +678,4 @@ class UserTest < ActiveSupport::TestCase assert_equal User.students_and_trainees, User.users_role(not_scope_name, allowed_targets: allowed_targets, default_target: 'student_and_trainee') assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) end - - test '#delete_all_organizers' do - user = users(:hajime) - - assert_changes -> { Organizer.where(user: user).exists? }, from: true, to: false do - user.delete_all_organizers - end - end end From 11f9b95d91f057f6d0eff66e25128c1fe26cc23e Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sun, 17 Dec 2023 19:07:10 +0900 Subject: [PATCH 54/79] =?UTF-8?q?=E4=BC=91=E4=BC=9A=E3=81=BE=E3=81=9F?= =?UTF-8?q?=E3=81=AF=E9=80=80=E4=BC=9A=E3=81=97=E3=81=9F=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E3=81=AE=E5=AE=9A=E6=9C=9F=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E4=B8=BB=E5=82=AC=E8=80=85=E3=82=92?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=80=85=E3=81=AB=E8=87=AA=E5=8B=95=E3=81=A7?= =?UTF-8?q?=E5=89=B2=E3=82=8A=E5=BD=93=E3=81=A6=E3=82=8B=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E6=88=BB=E3=81=97=E3=80=81=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 7 +------ app/controllers/retirement_controller.rb | 7 +------ app/models/organizer.rb | 6 ++++++ app/models/user.rb | 4 ++++ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index 87486d7dfd3..42b4533efcb 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,7 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins - assign_admin_as_organizer + current_user.organizers_delete_and_assign_new logout redirect_to hibernation_path else @@ -52,9 +52,4 @@ def notify_to_mentors_and_admins def notify_to_chat DiscordNotifier.with(sender: current_user).hibernated.notify_now end - - def assign_admin_as_organizer - current_user.organizers.destroy_all - current_user.regular_events.each(&:assign_admin_as_organizer_if_none) - end end diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index 77c19ab3726..7638ea2d747 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,7 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user - assign_admin_as_organizer + current_user.organizers_delete_and_assign_new Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now @@ -52,9 +52,4 @@ def notify_to_mentors ActivityDelivery.with(sender: current_user, receiver: mentor_user).notify(:retired) end end - - def assign_admin_as_organizer - current_user.organizers.destroy_all - current_user.regular_events.each(&:assign_admin_as_organizer_if_none) - end end diff --git a/app/models/organizer.rb b/app/models/organizer.rb index 8392e284141..bf6c0ae6149 100644 --- a/app/models/organizer.rb +++ b/app/models/organizer.rb @@ -5,4 +5,10 @@ class Organizer < ApplicationRecord belongs_to :regular_event validates :user_id, uniqueness: { scope: :regular_event_id } + + def delete_and_assign_new + event = regular_event + delete + event.assign_admin_as_organizer_if_none + end end diff --git a/app/models/user.rb b/app/models/user.rb index 45edcef0a6e..d18982235b4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -756,6 +756,10 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end + def organizers_delete_and_assign_new + organizers.each(&:delete_and_assign_new) + end + private def password_required? From e10c4a716b7d1e62431cb62540f6d93aae455ae7 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Sun, 17 Dec 2023 19:20:05 +0900 Subject: [PATCH 55/79] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E6=88=BB?= =?UTF-8?q?=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/organizer_test.rb | 16 ++++++++++++++++ test/models/user_test.rb | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/models/organizer_test.rb diff --git a/test/models/organizer_test.rb b/test/models/organizer_test.rb new file mode 100644 index 00000000000..6dde4da1b3a --- /dev/null +++ b/test/models/organizer_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'test_helper' + +class OrganizerTest < ActiveSupport::TestCase + test '#delete_and_assign_new' do + organizer = organizers(:organizer12) + event = organizer.regular_event + + assert_changes -> { Organizer.where(regular_event: event, user: organizer.user).exists? }, from: true, to: false do + organizer.delete_and_assign_new + end + + assert Organizer.where(regular_event: event).exists? + end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 10fd634aa2a..a1484f43081 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -678,4 +678,12 @@ class UserTest < ActiveSupport::TestCase assert_equal User.students_and_trainees, User.users_role(not_scope_name, allowed_targets: allowed_targets, default_target: 'student_and_trainee') assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) end + + test '#organizers_delete_and_assign_new' do + user = users(:hajime) + + assert_changes -> { Organizer.where(user: user).exists? }, from: true, to: false do + user.organizers_delete_and_assign_new + end + end end From a62971b873825c2ae9ce8efe243542aa2eb14b10 Mon Sep 17 00:00:00 2001 From: natsuto6 <79001972+natsuto6@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:02:04 +0900 Subject: [PATCH 56/79] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hibernation_controller.rb | 2 +- app/controllers/retirement_controller.rb | 2 +- app/models/user.rb | 2 +- test/models/user_test.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/hibernation_controller.rb b/app/controllers/hibernation_controller.rb index 42b4533efcb..cdea0cabdcf 100644 --- a/app/controllers/hibernation_controller.rb +++ b/app/controllers/hibernation_controller.rb @@ -18,7 +18,7 @@ def create destroy_subscription! notify_to_chat notify_to_mentors_and_admins - current_user.organizers_delete_and_assign_new + current_user.delete_and_assign_new_organizer logout redirect_to hibernation_path else diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index 7638ea2d747..9c45bc1e968 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -12,7 +12,7 @@ def create current_user.retired_on = Date.current if current_user.save(context: :retirement) user = current_user - current_user.organizers_delete_and_assign_new + current_user.delete_and_assign_new_organizer Newspaper.publish(:retirement_create, user) begin UserMailer.retire(user).deliver_now diff --git a/app/models/user.rb b/app/models/user.rb index d18982235b4..def7dd8db00 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -756,7 +756,7 @@ def become_watcher!(watchable) watches.find_or_create_by!(watchable:) end - def organizers_delete_and_assign_new + def delete_and_assign_new_organizer organizers.each(&:delete_and_assign_new) end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index a1484f43081..5dc836a211d 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -679,11 +679,11 @@ class UserTest < ActiveSupport::TestCase assert_empty User.users_role(not_scope_name, allowed_targets: allowed_targets) end - test '#organizers_delete_and_assign_new' do + test '#delete_and_assign_new_organizer' do user = users(:hajime) assert_changes -> { Organizer.where(user: user).exists? }, from: true, to: false do - user.organizers_delete_and_assign_new + user.delete_and_assign_new_organizer end end end From cd497c9e3271ee952256a18880db1b76201d2d78 Mon Sep 17 00:00:00 2001 From: goruchan Date: Wed, 20 Dec 2023 23:17:24 +0900 Subject: [PATCH 57/79] =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=90=8D=E3=82=92=E4=BB=96=E3=81=AE?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E6=96=B9=E6=B3=95=E3=81=A8=E6=8F=83=E3=81=88?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scopeはクラスメソッドの別の書き方なのでクラスメソッドとして対応 --- test/models/product_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 0947d894a5d..a528a59324e 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -200,7 +200,7 @@ class ProductTest < ActiveSupport::TestCase assert_not wip_product.updated_after_submission? end - test 'unhibernated user products' do + test '.unhibernated_user_products' do hiberanated_user = users(:kyuukai) hibernated_user_product = Product.create!( From c5202a2b6894be8c17a925d2a0e08332c425ca0b Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Fri, 8 Dec 2023 21:50:00 +0900 Subject: [PATCH 58/79] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=82=B9=E3=81=94?= =?UTF-8?q?=E3=81=A8=E3=81=AE=E5=8F=82=E8=80=83=E6=9B=B8=E7=B1=8D=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=83=9A=E3=83=BC=E3=82=B8=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses/books_controller.rb | 7 + app/javascript/components/course-books.vue | 148 ++++++++++++++++++++ app/javascript/packs/application.js | 2 + app/views/courses/_tabs.html.slim | 9 ++ app/views/courses/books/index.html.slim | 27 ++++ app/views/courses/practices/index.html.slim | 1 + config/routes.rb | 1 + db/fixtures/books.yml | 6 + db/fixtures/practices_books.yml | 5 + test/fixtures/books.yml | 6 + test/fixtures/practices_books.yml | 5 + test/system/course/books_test.rb | 28 ++++ 12 files changed, 245 insertions(+) create mode 100644 app/controllers/courses/books_controller.rb create mode 100644 app/javascript/components/course-books.vue create mode 100644 app/views/courses/_tabs.html.slim create mode 100644 app/views/courses/books/index.html.slim create mode 100644 test/system/course/books_test.rb diff --git a/app/controllers/courses/books_controller.rb b/app/controllers/courses/books_controller.rb new file mode 100644 index 00000000000..6dc9ef76e0a --- /dev/null +++ b/app/controllers/courses/books_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class Courses::BooksController < ApplicationController + def index + @course = Course.find(params[:course_id]) + end +end diff --git a/app/javascript/components/course-books.vue b/app/javascript/components/course-books.vue new file mode 100644 index 00000000000..64a97f6bdc5 --- /dev/null +++ b/app/javascript/components/course-books.vue @@ -0,0 +1,148 @@ + + diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 4296b1f3019..fc3be89ada9 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -81,6 +81,7 @@ import SadReports from '../components/sad_reports.vue' import UserProducts from '../components/user-products.vue' import MentorPractices from '../components/mentor-practices.vue' import ActionCompletedButton from '../components/action-completed-button.vue' +import CourseBooks from '../components/course-books.vue' import '../stylesheets/application' @@ -106,6 +107,7 @@ mounter.addComponent(SadReports) mounter.addComponent(UserProducts) mounter.addComponent(MentorPractices) mounter.addComponent(ActionCompletedButton) +mounter.addComponent(CourseBooks) mounter.mount() // Support component names relative to this directory: diff --git a/app/views/courses/_tabs.html.slim b/app/views/courses/_tabs.html.slim new file mode 100644 index 00000000000..385f4a71d18 --- /dev/null +++ b/app/views/courses/_tabs.html.slim @@ -0,0 +1,9 @@ +.page-tabs + .container + ul.page-tabs__items + li.page-tabs__item + = link_to course_practices_path, class: "page-tabs__item-link #{current_link(/^courses-practices-index/)}" do + | プラクティス + li.page-tabs__item + = link_to course_books_path, class: "page-tabs__item-link #{current_link(/^courses-books-index/)} is-sm" do + | 書籍 diff --git a/app/views/courses/books/index.html.slim b/app/views/courses/books/index.html.slim new file mode 100644 index 00000000000..f7277ca4498 --- /dev/null +++ b/app/views/courses/books/index.html.slim @@ -0,0 +1,27 @@ +- title "#{@course.title}コースの参考書籍" +- set_meta_tags description: "#{@course.title}コースの参考書籍一覧ページです。" + +header.page-header + .container + .page-header__inner + h2.page-header__title + = title + .page-header-actions + ul.page-header-actions__items + - if current_user.admin_or_mentor? + li.page-header-actions__item + = link_to new_book_path, class: 'a-button is-md is-secondary is-block' do + i.fas.fa-plus + | 参考書籍登録 += render 'courses/tabs' +hr.a-border + .page-body + .container.is-md + nav.pill-nav + .container + ul.pill-nav__items + li.pill-nav__item + = link_to '全て', course_books_path, class: "pill-nav__item-link #{params[:status] == 'mustread' ? '' : 'is-active'}" + li.pill-nav__item + = link_to '必読', course_books_path(status: 'mustread'), class: "pill-nav__item-link #{params[:status] == 'mustread' ? 'is-active' : ''}" +div(data-vue="CourseBooks" data-vue-is-admin:boolean="#{current_user.admin?}" data-vue-is-mentor:boolean="#{current_user.mentor?}" data-vue-course:json="#{@course.to_json}") diff --git a/app/views/courses/practices/index.html.slim b/app/views/courses/practices/index.html.slim index 2ab8c647fe5..3637b10fc76 100644 --- a/app/views/courses/practices/index.html.slim +++ b/app/views/courses/practices/index.html.slim @@ -34,6 +34,7 @@ header.page-header li.page-header-actions__item = link_to courses_path, class: 'a-button is-md is-secondary is-block is-back' do | コース一覧 += render 'courses/tabs' hr.a-border .page-body.js-users-visibility .container.is-xl diff --git a/config/routes.rb b/config/routes.rb index 5eff2d07728..d0adc8f5b7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ resources :password_resets, only: %i(create edit update) resources :courses, only: %i(index) do resources :practices, only: %i(index), controller: "courses/practices" + resources :books, only: %i(index), controller: "courses/books" end resources :practices, only: %i(show) do resources :reports, only: %i(index), controller: "practices/reports" diff --git a/db/fixtures/books.yml b/db/fixtures/books.yml index c5459ed81fb..43d17c78c4a 100644 --- a/db/fixtures/books.yml +++ b/db/fixtures/books.yml @@ -9,3 +9,9 @@ book2: price: 2640 page_url: https://www.amazon.co.jp/dp/4822282511 description: ソフトウェアテストの必修技法を満載した初心者にもわかりやすい解説書です。 + +book3: + title: パーフェクト Ruby on Rails + price: 3637 + page_url: https://www.amazon.co.jp/dp/B08D3DW7LP + description: 通称パRails diff --git a/db/fixtures/practices_books.yml b/db/fixtures/practices_books.yml index 0d5bc357cd1..a7fde4b5e18 100644 --- a/db/fixtures/practices_books.yml +++ b/db/fixtures/practices_books.yml @@ -2,3 +2,8 @@ practices_book1: practice: practice1 book: book1 must_read: true + +practices_book2: + practice: practice1 + book: book3 + must_read: false diff --git a/test/fixtures/books.yml b/test/fixtures/books.yml index c5459ed81fb..43d17c78c4a 100644 --- a/test/fixtures/books.yml +++ b/test/fixtures/books.yml @@ -9,3 +9,9 @@ book2: price: 2640 page_url: https://www.amazon.co.jp/dp/4822282511 description: ソフトウェアテストの必修技法を満載した初心者にもわかりやすい解説書です。 + +book3: + title: パーフェクト Ruby on Rails + price: 3637 + page_url: https://www.amazon.co.jp/dp/B08D3DW7LP + description: 通称パRails diff --git a/test/fixtures/practices_books.yml b/test/fixtures/practices_books.yml index 0d5bc357cd1..a7fde4b5e18 100644 --- a/test/fixtures/practices_books.yml +++ b/test/fixtures/practices_books.yml @@ -2,3 +2,8 @@ practices_book1: practice: practice1 book: book1 must_read: true + +practices_book2: + practice: practice1 + book: book3 + must_read: false diff --git a/test/system/course/books_test.rb b/test/system/course/books_test.rb new file mode 100644 index 00000000000..2aea65207c7 --- /dev/null +++ b/test/system/course/books_test.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class Course::PracticesTest < ApplicationSystemTestCase + test 'show the course book list page' do + visit_with_auth "/courses/#{courses(:course1).id}/books", 'kimura' + assert_equal 'Railsプログラマーコースの参考書籍 | FBC', title + end + + test 'disply in the list is books associated with practices of that course' do + practice_title = 'OS X Mountain Lionをクリーンインストールする' + visit_with_auth "/courses/#{courses(:course1).id}/books", 'kimura' + assert_selector '.tag-links__item-link', text: practice_title + + click_link 'プラクティス', class: 'page-tabs__item-link', exact: true + assert_text practice_title + end + + test 'show only must-read books' do + visit_with_auth "/courses/#{courses(:course1).id}/books", 'kimura' + must_read_books_count = page.all('.books__items .card-books-item.a-card .a-badge.is-danger.is-sm', text: '必読').count + + click_link '必読', class: 'pill-nav__item-link', exact: true + displayed_must_read_books_count = page.all('.books__items .card-books-item.a-card').count + assert_equal must_read_books_count, displayed_must_read_books_count + end +end From 25da6c7957abc6ddb856064012339ca73272e6ac Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sun, 17 Dec 2023 11:14:11 +0900 Subject: [PATCH 59/79] =?UTF-8?q?fixtures=E5=A4=89=E6=9B=B4=E3=81=AB?= =?UTF-8?q?=E4=BC=B4=E3=81=84=E3=80=81=E9=96=A2=E9=80=A3=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/practices_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/practices_test.rb b/test/system/practices_test.rb index 332ae9ce284..919f770a535 100644 --- a/test/system/practices_test.rb +++ b/test/system/practices_test.rb @@ -123,7 +123,7 @@ class PracticesTest < ApplicationSystemTestCase practice = practices(:practice1) visit_with_auth "/mentor/practices/#{practice.id}/edit", 'komagata' within '#reference_books' do - find('.choices__list').click + first('.choices__list').click find('#choices--practice_practices_books_attributes_0_book_id-item-choice-2', text: 'はじめて学ぶソフトウェアのテスト技法').click end click_button '更新する' From 20522aa2c11ef9f816460bbb6277538138561c86 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Thu, 21 Dec 2023 09:14:11 +0900 Subject: [PATCH 60/79] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=AF=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=82=B9=E3=81=A7=E7=B5=9E=E3=82=8A=E8=BE=BC=E3=82=80?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/course-books.vue | 53 ++++------------------ 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/app/javascript/components/course-books.vue b/app/javascript/components/course-books.vue index 64a97f6bdc5..2d72f920125 100644 --- a/app/javascript/components/course-books.vue +++ b/app/javascript/components/course-books.vue @@ -1,11 +1,5 @@