Skip to content

Commit

Permalink
Merge pull request #7740 from fjordllc/feature/corporate_training_for…
Browse files Browse the repository at this point in the history
…m_create

企業研修の申し込みフォームを作成(修正)
  • Loading branch information
komagata authored May 1, 2024
2 parents fd8aeed + 514815d commit 26d8699
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 140 deletions.
41 changes: 41 additions & 0 deletions app/controllers/corporate_training_inquiries_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

class CorporateTrainingInquiriesController < ApplicationController
include Recaptchable::V3
skip_before_action :require_active_user_login, raise: false

def new
@corporate_training_inquiry = CorporateTrainingInquiry.new
end

def create
@corporate_training_inquiry = CorporateTrainingInquiry.new(corporate_training_inquiry_params)

result = valid_recaptcha?('corporate_training_inquiry')
if result && @corporate_training_inquiry.save
CorporateTrainingInquiryMailer.incoming(@corporate_training_inquiry).deliver_later
redirect_to new_corporate_training_inquiry_url, notice: 'お問い合わせを送信しました。'
else
flash.now[:alert] = 'Bot対策のため送信を拒否しました。しばらくしてからもう一度送信してください。' unless result
render :new
end
end

private

def corporate_training_inquiry_params
params.require(:corporate_training_inquiry).permit(
:company_name,
:name,
:email,
:meeting_date1,
:meeting_date2,
:meeting_date3,
:participants_count,
:training_duration,
:how_did_you_hear,
:additional_information,
:privacy_policy
)
end
end
41 changes: 0 additions & 41 deletions app/controllers/corporate_trainings_controller.rb

This file was deleted.

8 changes: 8 additions & 0 deletions app/mailers/corporate_training_inquiry_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class CorporateTrainingInquiryMailer < ApplicationMailer
def incoming(corporate_training_inquiry)
@corporate_training_inquiry = corporate_training_inquiry
mail to: '[email protected]', reply_to: @corporate_training_inquiry.email, subject: '[FBC] 企業研修の申し込み'
end
end
8 changes: 0 additions & 8 deletions app/mailers/corporate_training_mailer.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class CorporateTraining < ApplicationRecord
class CorporateTrainingInquiry < ApplicationRecord
validates :company_name, presence: true
validates :name, presence: true
validates :email, presence: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= form_with model: corporate_training, url: corporate_training_path, method: :post, local: true do |f|
= render 'errors', object: corporate_training
= form_with model: corporate_training_inquiry, url: corporate_training_inquiry_path, method: :post, local: true do |f|
= render 'errors', object: corporate_training_inquiry
.form__items
.form-item
= f.label :name, class: 'a-form-label is-required'
Expand Down Expand Up @@ -49,4 +49,4 @@
li.form-actions__item.is-main
= f.submit '送信', class: 'a-button is-lg is-primary is-block'

= recaptcha_v3(action: 'corporate_training', callback: 'skipOnLoadReCaptcha') if recaptcha_enabled?
= recaptcha_v3(action: 'corporate_training_inquiry', callback: 'skipOnLoadReCaptcha') if recaptcha_enabled?
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ruby:
header.auth-form__header
h1.auth-form__title = title
.auth-form__body
= render 'form', corporate_training: @corporate_training
= render 'form', corporate_training_inquiry: @corporate_training_inquiry
footer.auth-form__footer
nav.auth-form-nav
ul.auth-form-nav__items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
<td style="word-wrap:break-word;font-size:0px;padding:16px 24px 16px 24px;" align="left">
<div style="cursor:auto;font-family:sans-serif; font-size:14px; line-height:1.8; text-align:left;">
<p><b>企業名:</b></p>
<p><%= @corporate_training.company_name %></p>
<p><%= @corporate_training_inquiry.company_name %></p>
<p><b>名前:</b></p>
<p><%= @corporate_training.name %></p>
<p><%= @corporate_training_inquiry.name %></p>
<p><b>Email:</b></p>
<p><%= @corporate_training.email %></p>
<p><%= @corporate_training_inquiry.email %></p>
<p><b>研修打ち合わせ希望日時:</b></p>
<p><b>第1希望</b></p>
<p><%= l @corporate_training.meeting_date1, format: :default %></p>
<p><%= l @corporate_training_inquiry.meeting_date1, format: :default %></p>
<p><b>第2希望</b></p>
<p><%= l @corporate_training.meeting_date2, format: :default %></p>
<p><%= l @corporate_training_inquiry.meeting_date2, format: :default %></p>
<p><b>第3希望</b></p>
<p><%= l @corporate_training.meeting_date3, format: :default%></p>
<p><%= l @corporate_training_inquiry.meeting_date3, format: :default%></p>
<p><b>研修を受ける方の人数:</b></p>
<p><%= @corporate_training.participants_count %></p>
<p><%= @corporate_training_inquiry.participants_count %></p>
<p><b>研修期間:</b></p>
<p><%= @corporate_training.training_duration %></p>
<p><%= @corporate_training_inquiry.training_duration %></p>
<p><b>どこでフィヨルドブートキャンプを知りましたか?:</b></p>
<p><%= @corporate_training.how_did_you_hear %></p>
<p><%= @corporate_training_inquiry.how_did_you_hear %></p>
<p><b>その他伝えておきたいこと:</b></p>
<p><%= @corporate_training.additional_information %></p>
<p><%= @corporate_training_inquiry.additional_information %></p>
</div>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ ja:
email: メールアドレス
body: 内容
privacy_policy: 個人情報の取り扱い
corporate_training:
corporate_training_inquiry:
name: 名前
company_name: 企業名
email: メールアドレス
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
resources :questions
resources :courses, only: :index
resource :inquiry, only: %i(new create)
resource :corporate_training, only: %i(new create)
resource :corporate_training_inquiry, only: %i(new create)
resources :articles
resources :survey_questions, except: %i(show destroy)
namespace :events do
Expand Down
73 changes: 34 additions & 39 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_03_14_023555) do
ActiveRecord::Schema.define(version: 2024_03_20_081440) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -125,8 +125,8 @@
end

create_table "categories", id: :serial, force: :cascade do |t|
t.string "name", limit: 255
t.string "slug", limit: 255
t.string "name"
t.string "slug"
t.datetime "created_at"
t.datetime "updated_at"
t.text "description"
Expand Down Expand Up @@ -180,31 +180,30 @@
t.datetime "updated_at"
t.string "commentable_type", default: "Report"
t.index ["commentable_id"], name: "index_comments_on_commentable_id"
t.index ["user_id"], name: "comment_user_id"
t.index ["user_id"], name: "index_comments_on_user_id"
end

create_table "companies", id: :serial, force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.text "description"
t.string "website", limit: 255
t.string "website"
t.datetime "created_at"
t.datetime "updated_at"
t.text "tos"
t.string "blog_url"
t.text "memo"
end

create_table "corporate_trainings", force: :cascade do |t|
t.string "company_name"
t.string "name"
t.string "email"
t.datetime "meeting_date1"
t.datetime "meeting_date2"
t.datetime "meeting_date3"
t.integer "participants_count"
t.string "training_duration"
t.string "how_did_you_hear"
create_table "corporate_training_inquiries", force: :cascade do |t|
t.string "company_name", null: false
t.string "name", null: false
t.string "email", null: false
t.datetime "meeting_date1", null: false
t.datetime "meeting_date2", null: false
t.datetime "meeting_date3", null: false
t.integer "participants_count", null: false
t.string "training_duration", null: false
t.string "how_did_you_hear", null: false
t.text "additional_information"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
Expand All @@ -227,9 +226,6 @@
t.index ["course_id", "category_id"], name: "index_courses_categories_on_course_id_and_category_id", unique: true
end

create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t|
end

create_table "discord_profiles", force: :cascade do |t|
t.bigint "user_id"
t.string "account_name"
Expand Down Expand Up @@ -557,8 +553,8 @@
t.integer "kind", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["reactionable_type", "reactionable_id"], name: "index_reactions_on_reactionable_type_and_reactionable_id"
t.index ["user_id", "reactionable_id", "reactionable_type", "kind"], name: "index_reactions_on_reactionable", unique: true
t.index ["reactionable_type", "reactionable_id"], name: "index_reactions_on_reactionable"
t.index ["user_id", "reactionable_id", "reactionable_type", "kind"], name: "index_reactions_on_reactionable_u_k", unique: true
t.index ["user_id"], name: "index_reactions_on_user_id"
end

Expand Down Expand Up @@ -589,9 +585,9 @@
t.boolean "hold_national_holiday", null: false
t.time "start_at", null: false
t.time "end_at", null: false
t.boolean "wip", default: false, null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.boolean "wip", default: false, null: false
t.integer "category", default: 0, null: false
t.boolean "all", default: false, null: false
t.datetime "published_at"
Expand Down Expand Up @@ -619,7 +615,6 @@
t.index ["created_at"], name: "index_reports_on_created_at"
t.index ["user_id", "reported_on"], name: "index_reports_on_user_id_and_reported_on", unique: true
t.index ["user_id", "title"], name: "index_reports_on_user_id_and_title", unique: true
t.index ["user_id"], name: "reports_user_id"
end

create_table "survey_question_listings", force: :cascade do |t|
Expand Down Expand Up @@ -688,21 +683,21 @@
end

create_table "users", id: :serial, force: :cascade do |t|
t.string "login_name", limit: 255, null: false
t.string "email", limit: 255
t.string "crypted_password", limit: 255
t.string "salt", limit: 255
t.string "login_name", null: false
t.string "email"
t.string "crypted_password"
t.string "salt"
t.datetime "created_at"
t.datetime "updated_at"
t.string "remember_me_token", limit: 255
t.string "remember_me_token"
t.datetime "remember_me_token_expires_at"
t.string "twitter_account", limit: 255
t.string "facebook_url", limit: 255
t.string "blog_url", limit: 255
t.string "twitter_account"
t.string "facebook_url"
t.string "blog_url"
t.integer "company_id"
t.text "description"
t.datetime "accessed_at"
t.string "github_account", limit: 255
t.string "github_account"
t.boolean "adviser", default: false, null: false
t.boolean "nda", default: true, null: false
t.string "reset_password_token"
Expand All @@ -717,21 +712,21 @@
t.string "organization"
t.integer "os"
t.integer "experience"
t.boolean "free", default: false, null: false
t.boolean "trainee", default: false, null: false
t.text "retire_reason"
t.boolean "job_seeking", default: false, null: false
t.boolean "trainee", default: false, null: false
t.boolean "free", default: false, null: false
t.string "customer_id"
t.boolean "job_seeking", default: false, null: false
t.string "subscription_id"
t.boolean "mail_notification", default: true, null: false
t.boolean "job_seeker", default: false, null: false
t.boolean "github_collaborator", default: false, null: false
t.string "github_id"
t.boolean "github_collaborator", default: false, null: false
t.string "name", default: "", null: false
t.string "name_kana", default: "", null: false
t.integer "satisfaction"
t.text "opinion"
t.bigint "retire_reasons", default: 0, null: false
t.string "name", default: "", null: false
t.string "name_kana", default: "", null: false
t.string "unsubscribe_email_token"
t.text "mentor_memo"
t.text "after_graduation_hope"
Expand Down Expand Up @@ -767,7 +762,7 @@
t.datetime "updated_at", null: false
t.integer "user_id", null: false
t.index ["watchable_type", "watchable_id", "user_id"], name: "index_watches_on_watchable_type_and_watchable_id_and_user_id", unique: true
t.index ["watchable_type", "watchable_id"], name: "index_watches_on_watchable_type_and_watchable_id"
t.index ["watchable_type", "watchable_id"], name: "index_watches_on_watchable"
end

create_table "works", force: :cascade do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
corporate_training1:
corporate_training_inquiry1:
company_name: '株式会社カンパニー'
name: '研修 する世'
email: 'corporate_training@example.com'
email: 'corporate_training_inquiry@example.com'
meeting_date1: Time.zone.parse('2030-01-01-08:00')
meeting_date2: Time.zone.parse('2030-01-02-10:00')
meeting_date3: Time.zone.parse('2023-01-03-12:00')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require 'test_helper'

class CorporateTrainingMailerTest < ActionMailer::TestCase
class CorporateTrainingInquiryMailerTest < ActionMailer::TestCase
test 'incoming' do
corporate_training = CorporateTraining.new(
corporate_training_inquiry = CorporateTrainingInquiry.new(
company_name: '株式会社ロッカ',
name: '駒形真幸',
email: '[email protected]',
Expand All @@ -16,7 +16,7 @@ class CorporateTrainingMailerTest < ActionMailer::TestCase
how_did_you_hear: 'インターネットで知った',
additional_information: 'よろしくお願いします。'
)
mail = CorporateTrainingMailer.incoming(corporate_training)
mail = CorporateTrainingInquiryMailer.incoming(corporate_training_inquiry)
assert_equal '[FBC] 企業研修の申し込み', mail.subject
assert_equal ['[email protected]'], mail.to
assert_equal ['[email protected]'], mail.from
Expand Down
Loading

0 comments on commit 26d8699

Please sign in to comment.