Commit 4362da42 by Mai Hoang Thai Ha

fixed review part 1

parent 3926645e
......@@ -6,57 +6,56 @@
color: black;
}
.ribbon{
.ribbon {
font-weight: 400;
line-height: 1.5;
color: #212529;
display: flex;
.item {
display: inline-flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: center;
justify-content: center;
padding: 20px;
font-size: 1rem;
font-weight: 700;
line-height: 1.5;
color: #6c757d;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: none;
border-radius: .25rem;
.circle {
display: inline-flex;
-ms-flex-line-pack: center;
align-content: center;
-ms-flex-pack: center;
justify-content: center;
padding: 20px;
font-size: 1rem;
font-weight: 700;
line-height: 1.5;
color: #6c757d;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: none;
border-radius: .25rem;
.circle {
display: inline-flex;
-ms-flex-line-pack: center;
align-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 2em;
height: 2em;
padding: .5em 0;
margin: .25rem;
line-height: 1em;
color: #fff;
background-color: #6c757d;
border-radius: 50%
}
width: 2em;
height: 2em;
padding: .5em 0;
margin: .25rem;
line-height: 1em;
color: #fff;
background-color: #6c757d;
border-radius: 50%
}
}
.current-page {
color: #0d6efd;
.circle {
background: #0d6efd;
}
}
.line {
flex: 1 0 32px;
......@@ -65,4 +64,4 @@
margin: auto;
background-color: rgba(0,0,0,.12);
}
}
\ No newline at end of file
}
class AppliesController < ApplicationController
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
@job = Job.find_by(id: params[:job_id])
@apply = @job.apply_jobs.build
......@@ -25,11 +11,18 @@ class AppliesController < ApplicationController
@apply = @job.apply_jobs.build(apply_params)
@apply.user_id = @user.id
if @apply.valid?
@name = @apply.user_name
@email = @apply.email
@cv = @apply.cv
@job_id = @apply.job_id
render 'new' unless @apply.valid?
end
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
......
......@@ -8,9 +8,10 @@ class ApplyJob < ApplicationRecord
validates :user_name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX }
validates :cv, presence: true,
content_type: { in: %w[application/pdf application/msword application/zip application/xls application/xlsx],
message: 'must be a valid cv format' },
size: { less_than: 5.megabytes,
message: 'should be less than 5MB' }
validates :cv, presence: true, content_type:
{ in: %w[application/pdf application/msword application/zip application/xls application/xlsx],
message: 'must be a valid cv format' },
size:
{ less_than: 5.megabytes,
message: 'should be less than 5MB' }
end
......@@ -11,26 +11,29 @@
= form_with(model: @apply, scope: :apply_job, url: done_path, local: true) do |f|
.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'
span.mx-2.label
= @name
= f.hidden_field :user_name, value: @name, class: 'form-control'
= @apply.user_name
= f.hidden_field :user_name, value: @apply.user_name, class: 'form-control'
.mb-5
= f.label :email, 'Email:', class: 'form-label label'
span.mx-2.label
= @email
= f.hidden_field :email, value: @email, class: 'form-control'
= @apply.email
= f.hidden_field :email, value: @apply.email, class: 'form-control'
.mb-5
span
= f.hidden_field :cv, value: @apply.cv, class: 'form-control'
= f.label :cv, 'Cv: ', class: 'form-label label'
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
= url_for(@apply.cv)
.row.justify-content-between
.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
= f.submit 'Confirm', class: 'btn btn-primary w-100'
......
......@@ -3,10 +3,10 @@
=render 'ribbon'
.container
h1.my-5.text-center
| Apply for
| Apply form
= @job.title
.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
.mb-5
= f.hidden_field :job_id, value: @job.id, class: 'form-control'
......@@ -17,6 +17,8 @@
= f.label :email, class: 'form-label label'
= f.text_field :email, class: 'form-control'
.mb-5
/ - if @user.cv.attached?
/ = url_for(@user.cv)
span.label
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
= 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'
......@@ -6,4 +6,5 @@
ul.mb-3
- object.errors.full_messages.each do |msg|
li.text-danger
= msg
\ No newline at end of file
= msg
\ No newline at end of file
......@@ -6,8 +6,7 @@ p
| Job title: #{@job.title}
p
| Location:
- @job.cities.each do |city|
span= city.name
= show_location(@job.cities)
p
| Company: #{@job.company.name}
br/
......
......@@ -11,6 +11,9 @@ module VenJob
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
config.to_prepare do
ActionMailer::Base.helper "application"
end
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
......
......@@ -96,4 +96,8 @@ Rails.application.configure do
Bullet.rails_logger = true
Bullet.add_footer = true
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
......@@ -1609,11 +1609,6 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.16.6, browserslist@^4
escalade "^3.1.1"
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:
version "1.1.1"
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