Commit 4362da42 by Mai Hoang Thai Ha

fixed review part 1

parent 3926645e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
color: black; color: black;
} }
.ribbon{ .ribbon {
font-weight: 400; font-weight: 400;
line-height: 1.5; line-height: 1.5;
color: #212529; color: #212529;
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
.circle { .circle {
background: #0d6efd; background: #0d6efd;
} }
} }
.line { .line {
flex: 1 0 32px; flex: 1 0 32px;
......
class AppliesController < ApplicationController class AppliesController < ApplicationController
before_action :load_job, only: %i[confirm create] before_action :load_job, only: %i[confirm create]
def create
@user = User.find_by(id: 1)
@apply = @job.apply_jobs.build(apply_params)
@apply.user_id = @user.id
@apply.cv.attach(params[:apply_job][:cv])
if @apply.save
UserMailer.apply_job(@user, @job, @apply).deliver_now
flash.now[:info] = 'Job application information has been sent to your email'
else
render 'new'
end
end
def new def new
@job = Job.find_by(id: params[:job_id]) @job = Job.find_by(id: params[:job_id])
@apply = @job.apply_jobs.build @apply = @job.apply_jobs.build
...@@ -25,11 +11,18 @@ class AppliesController < ApplicationController ...@@ -25,11 +11,18 @@ class AppliesController < ApplicationController
@apply = @job.apply_jobs.build(apply_params) @apply = @job.apply_jobs.build(apply_params)
@apply.user_id = @user.id @apply.user_id = @user.id
if @apply.valid? render 'new' unless @apply.valid?
@name = @apply.user_name end
@email = @apply.email
@cv = @apply.cv def create
@job_id = @apply.job_id @user = User.find_by(id: 1)
@apply = @job.apply_jobs.build(apply_params)
@apply.user_id = @user.id
@apply.cv.attach(params[:apply_job][:cv])
if @apply.save
UserMailer.apply_job(@user, @job, @apply).deliver_now
flash.now[:info] = 'Job application information has been sent to your email'
else else
render 'new' render 'new'
end end
......
...@@ -8,9 +8,10 @@ class ApplyJob < ApplicationRecord ...@@ -8,9 +8,10 @@ class ApplyJob < ApplicationRecord
validates :user_name, presence: true, length: { maximum: 50 } validates :user_name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 }, validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX } format: { with: VALID_EMAIL_REGEX }
validates :cv, presence: true, validates :cv, presence: true, content_type:
content_type: { in: %w[application/pdf application/msword application/zip application/xls application/xlsx], { in: %w[application/pdf application/msword application/zip application/xls application/xlsx],
message: 'must be a valid cv format' }, message: 'must be a valid cv format' },
size: { less_than: 5.megabytes, size:
{ less_than: 5.megabytes,
message: 'should be less than 5MB' } message: 'should be less than 5MB' }
end end
...@@ -11,26 +11,29 @@ ...@@ -11,26 +11,29 @@
= form_with(model: @apply, scope: :apply_job, url: done_path, local: true) do |f| = form_with(model: @apply, scope: :apply_job, url: done_path, local: true) do |f|
.mb-5 .mb-5
= f.hidden_field :job_id, value: @job_id, class: 'form-control' = f.hidden_field :job_id, value: @job.id, class: 'form-control'
= f.label :name, 'Full name:', class: 'form-label label' = f.label :name, 'Full name:', class: 'form-label label'
span.mx-2.label span.mx-2.label
= @name = @apply.user_name
= f.hidden_field :user_name, value: @name, class: 'form-control' = f.hidden_field :user_name, value: @apply.user_name, class: 'form-control'
.mb-5 .mb-5
= f.label :email, 'Email:', class: 'form-label label' = f.label :email, 'Email:', class: 'form-label label'
span.mx-2.label span.mx-2.label
= @email = @apply.email
= f.hidden_field :email, value: @email, class: 'form-control' = f.hidden_field :email, value: @apply.email, class: 'form-control'
.mb-5 .mb-5
span span
= f.hidden_field :cv, value: @apply.cv, class: 'form-control'
= f.label :cv, 'Cv: ', class: 'form-label label' = f.label :cv, 'Cv: ', class: 'form-label label'
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx' = f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
= url_for(@apply.cv)
.row.justify-content-between .row.justify-content-between
.col-6 .col-6
= link_to 'Edit', apply_path(job_id: @job_id), class: 'btn btn-secondary py-2 px-4 w-100' = link_to 'Edit', apply_path(job_id: @job.id), class: 'btn btn-secondary py-2 px-4 w-100'
.col-6 .col-6
= f.submit 'Confirm', class: 'btn btn-primary w-100' = f.submit 'Confirm', class: 'btn btn-primary w-100'
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
=render 'ribbon' =render 'ribbon'
.container .container
h1.my-5.text-center h1.my-5.text-center
| Apply for | Apply form
= @job.title = @job.title
.col .col
= form_with(model: @apply, scope: :apply_job, url: confirm_path, local: true) do |f| = form_with(model: @apply, url: confirm_path, local: true) do |f|
= render 'shared/error_messages', object: f.object = render 'shared/error_messages', object: f.object
.mb-5 .mb-5
= f.hidden_field :job_id, value: @job.id, class: 'form-control' = f.hidden_field :job_id, value: @job.id, class: 'form-control'
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
= f.label :email, class: 'form-label label' = f.label :email, class: 'form-label label'
= f.text_field :email, class: 'form-control' = f.text_field :email, class: 'form-control'
.mb-5 .mb-5
/ - if @user.cv.attached?
/ = url_for(@user.cv)
span.label span.label
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx' = f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
= f.submit 'Confirm', class: 'btn btn-primary w-100' = f.submit 'Confirm', class: 'btn btn-primary w-100'
.job-detail.my5
.job-apply.d-flex.align-items-center.justify-content-between
h2.align-items-start
= @job.title
= link_to 'Apply for this job', apply_path(job_id: Job.find_by(title: @job.title).id), class: 'btn btn-primary'
p.text-secondary
= @job.company.name
.row.bg-light
.col-4
ul.list-unstyled
li
strong
| Location
- @job.cities.each do |city|
p
= city.name
li
strong
| Salary
p.text-success
= @job.salary
.col-4
ul.list-unstyled
li
strong
| Type
p
= @job.job_type
li
strong
| Position
p
= @job.position
.col-4
ul.list-unstyled
li
strong
| Experience
p
= @job.experience
li
strong
| Expiration date
p
= @job.expiration_date
.job-benefits.my-4
h3
| Benefits
.row
- @job.benefit.split('---').each do |benefit|
li.list-unstyled.col-4.text-secondary
= benefit
.job-desc.my-4
h3
| Description
= @job.description.html_safe()
.job-req.my-4
h3
| Requirement
= @job.requirement.html_safe()
.job-info.my-4
h3
| Other info
- @job.other_info.split('---').each do |info|
li.text-secondary
= info
.job-apply.d-flex.align-items-center.justify-content-between
= link_to 'Apply for this job', apply_path(job_id: Job.find_by(title: @job.title).id), class: 'btn btn-primary'
= link_to 'Favorite', '#', class: 'btn btn-primary'
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
- object.errors.full_messages.each do |msg| - object.errors.full_messages.each do |msg|
li.text-danger li.text-danger
= msg = msg
\ No newline at end of file
...@@ -6,8 +6,7 @@ p ...@@ -6,8 +6,7 @@ p
| Job title: #{@job.title} | Job title: #{@job.title}
p p
| Location: | Location:
- @job.cities.each do |city| = show_location(@job.cities)
span= city.name
p p
| Company: #{@job.company.name} | Company: #{@job.company.name}
br/ br/
......
...@@ -11,6 +11,9 @@ module VenJob ...@@ -11,6 +11,9 @@ module VenJob
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1 config.load_defaults 6.1
config.to_prepare do
ActionMailer::Base.helper "application"
end
# Configuration for the application, engines, and railties goes here. # Configuration for the application, engines, and railties goes here.
# #
# These settings can be overridden in specific environments using the files # These settings can be overridden in specific environments using the files
......
...@@ -96,4 +96,8 @@ Rails.application.configure do ...@@ -96,4 +96,8 @@ Rails.application.configure do
Bullet.rails_logger = true Bullet.rails_logger = true
Bullet.add_footer = true Bullet.add_footer = true
end end
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => '127.0.0.1', :port => 1025 }
config.action_mailer.raise_delivery_errors = false
end end
...@@ -1609,11 +1609,6 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.16.6, browserslist@^4 ...@@ -1609,11 +1609,6 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.16.6, browserslist@^4
escalade "^3.1.1" escalade "^3.1.1"
node-releases "^1.1.71" node-releases "^1.1.71"
bs-stepper@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/bs-stepper/-/bs-stepper-1.7.0.tgz#bfa4cc51c4e67957caae57f5bdcba1977186bac1"
integrity sha512-+DX7UKKgw2GI6ucsSCRd19VHYrxf/8znRCLs1lQVVLxz+h7EqgIOxoHcJ0/QTaaNoR9Cwg78ydo6hXIasyd3LA==
buffer-from@^1.0.0: buffer-from@^1.0.0:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment