Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mai Hoang Thai Ha
VenJob
Commits
36ab9ceb
Commit
36ab9ceb
authored
Aug 17, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep cv from apply to confirm
parent
5c77f39a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
36 deletions
+53
-36
app/controllers/applies_controller.rb
+13
-3
app/javascript/packs/validation.js
+16
-2
app/views/applies/_validate_form.html.slim
+0
-9
app/views/applies/confirm.html.slim
+4
-5
app/views/applies/new.html.slim
+12
-11
app/views/jobs/show.html.slim
+2
-2
app/views/user_mailer/apply_job.text.slim
+3
-1
config/routes.rb
+3
-3
No files found.
app/controllers/applies_controller.rb
View file @
36ab9ceb
...
@@ -2,7 +2,10 @@ class AppliesController < ApplicationController
...
@@ -2,7 +2,10 @@ class AppliesController < ApplicationController
before_action
:load_job
,
only:
%i[new confirm create]
before_action
:load_job
,
only:
%i[new confirm create]
def
new
def
new
build_params
=
session
[
:apply_job
]
if
use_apply_job_session?
if
use_apply_job_session?
build_params
=
session
[
:apply_job
]
@blob
=
ActiveStorage
::
Blob
.
find
(
session
[
:blob_id
])
end
@apply
=
current_user
.
apply_jobs
.
build
(
build_params
)
@apply
=
current_user
.
apply_jobs
.
build
(
build_params
)
end
end
...
@@ -11,6 +14,12 @@ class AppliesController < ApplicationController
...
@@ -11,6 +14,12 @@ class AppliesController < ApplicationController
@apply
.
job
=
@job
@apply
.
job
=
@job
if
@apply
.
valid?
if
@apply
.
valid?
@blob
=
ActiveStorage
::
Blob
.
create_and_upload!
(
io:
apply_params
[
:cv
],
filename:
apply_params
[
:cv
].
original_filename
,
content_type:
apply_params
[
:cv
].
content_type
)
session
[
:blob_id
]
=
@blob
.
id
session
[
:apply_job
]
=
@apply
session
[
:apply_job
]
=
@apply
else
else
render
'new'
render
'new'
...
@@ -20,7 +29,7 @@ class AppliesController < ApplicationController
...
@@ -20,7 +29,7 @@ class AppliesController < ApplicationController
def
create
def
create
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
.
job
=
@job
@apply
.
job
=
@job
@apply
.
cv
.
attach
(
params
[
:apply_job
][
:cv
])
@apply
.
cv
=
ActiveStorage
::
Blob
.
find
(
session
[
:blob_id
])
if
@apply
.
save
if
@apply
.
save
UserMailer
.
apply_job
(
current_user
,
@job
,
@apply
).
deliver_now
UserMailer
.
apply_job
(
current_user
,
@job
,
@apply
).
deliver_now
...
@@ -28,6 +37,7 @@ class AppliesController < ApplicationController
...
@@ -28,6 +37,7 @@ class AppliesController < ApplicationController
else
else
render
'new'
render
'new'
end
end
session
[
:blob_id
]
=
nil
session
[
:apply_job
]
=
nil
session
[
:apply_job
]
=
nil
end
end
...
@@ -41,7 +51,7 @@ class AppliesController < ApplicationController
...
@@ -41,7 +51,7 @@ class AppliesController < ApplicationController
end
end
def
apply_params
def
apply_params
params
.
require
(
:apply_job
).
permit
(
:user_name
,
:email
,
:cv
)
params
.
require
(
:apply_job
).
permit
(
:user_name
,
:email
,
:cv
,
:job_id
)
end
end
def
current_user
def
current_user
...
...
app/javascript/packs/validation.js
View file @
36ab9ceb
...
@@ -95,4 +95,19 @@ Validator.isEmail = function (selector) {
...
@@ -95,4 +95,19 @@ Validator.isEmail = function (selector) {
return
regex
.
test
(
value
)
?
undefined
:
'Email invalid'
;
return
regex
.
test
(
value
)
?
undefined
:
'Email invalid'
;
}
}
}
}
}
}
\ No newline at end of file
Validator
.
fileTooLarge
=
function
(
selector
)
{
return
{
selector
:
selector
,
test
:
function
(
value
)
{
$
(
selector
).
on
(
'change'
,
function
()
{
const
size
=
(
this
.
files
[
0
].
size
/
1024
/
1024
).
toFixed
(
2
);
if
(
size
>
5
)
{
alert
(
'Maximum file size is 5MB. Please choose a smaller file.'
)
$
(
selector
).
val
(
''
);
}
})
}
}
}
app/views/applies/_validate_form.html.slim
deleted
100644 → 0
View file @
5c77f39a
javascript:
$
(
"#apply_job_cv"
).
bind
(
"change"
,
function
()
{
const
size_in_megabytes
=
this
.
files
[
0
].
size
/
1024
/
1024
;
if
(
size_in_megabytes
>
5
)
{
alert
(
"Maximum file size is 5MB. Please choose a smaller file."
);
$
(
"#apply_job_cv"
).
val
(
""
);
}
});
\ No newline at end of file
app/views/applies/confirm.html.slim
View file @
36ab9ceb
...
@@ -7,10 +7,11 @@
...
@@ -7,10 +7,11 @@
h1
.my-5.text-center
h1
.my-5.text-center
|
Confirmation
|
Confirmation
.col
.col
=
form_with
(
model:
@apply
,
scope: :apply_job
,
url:
done_path
,
local:
true
)
do
|
f
|
=
form_with
(
model:
@apply
,
scope: :apply_job
,
url:
done_
job_
path
,
local:
true
)
do
|
f
|
.row.mb-5
.row.mb-5
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
=
f
.
hidden_field
:blob_id
,
value:
@blob
.
id
.col-2
.col-2
=
f
.
label
:name
,
'Full name:'
,
class:
'form-label label'
=
f
.
label
:name
,
'Full name:'
,
class:
'form-label label'
.col-10
.col-10
...
@@ -30,12 +31,10 @@
...
@@ -30,12 +31,10 @@
.col-2
.col-2
=
f
.
label
:cv
,
'Cv: '
,
class:
'form-label label'
=
f
.
label
:cv
,
'Cv: '
,
class:
'form-label label'
.col-10
.col-10
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
span
.form-control
span
.form-control
=
url_for
(
@apply
.
cv
)
=
url_for
(
@apply
.
cv
)
=
link_to
'Edit'
,
:back
,
class:
'btn btn-secondary w-25 btn-height mr-5 my-5'
=
link_to
'Edit'
,
apply_job_path
(
job_id:
@job
.
id
)
,
class:
'btn btn-secondary w-25 btn-height mr-5 my-5'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 btn-height mx-5 my-5'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 btn-height mx-5 my-5'
=
render
'validate_form'
app/views/applies/new.html.slim
View file @
36ab9ceb
-
provide
(
:title
,
'Apply job'
)
-
provide
(
:title
,
'Apply job'
)
.container
.container
=
render
'ribbon'
=
render
'ribbon'
.container
.container
...
@@ -7,7 +8,7 @@
...
@@ -7,7 +8,7 @@
p
.fs-5.fw-bold.mb-4.text-center
p
.fs-5.fw-bold.mb-4.text-center
=
@job
.
title
=
@job
.
title
.col
.col
=
form_with
(
model:
@apply
,
url:
confirm_path
,
local:
true
,
id:
'apply-form'
)
do
|
f
|
=
form_with
(
model:
@apply
,
url:
confirm_
job_
path
,
local:
true
,
id:
'apply-form'
)
do
|
f
|
=
render
'shared/error_messages'
,
object:
f
.
object
=
render
'shared/error_messages'
,
object:
f
.
object
.row.mb-5.form-group
.row.mb-5.form-group
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
...
@@ -28,20 +29,20 @@
...
@@ -28,20 +29,20 @@
.col-2
.col-2
=
f
.
label
:cv
,
class:
'form-label label'
=
f
.
label
:cv
,
class:
'form-label label'
.col-10
.col-10
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
=
f
.
file_field
:cv
,
files:
@blob
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
span
.form-msg
span
.form-msg
br
br
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 my-4 btn-height'
,
data:
{
disable_with:
false
}
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 my-4 btn-height'
,
data:
{
disable_with:
false
}
=
render
'validate_form'
javascript:
javascript:
Validator
({
Validator
({
form
:
'#apply-form'
,
form
:
'#apply-form'
,
errorSelector
:
'.form-msg'
,
errorSelector
:
'.form-msg'
,
rules
:
[
rules
:
[
Validator
.
isRequired
(
'#apply_job_user_name'
),
Validator
.
isRequired
(
'#apply_job_user_name'
),
Validator
.
isRequired
(
'#apply_job_email'
),
Validator
.
isRequired
(
'#apply_job_email'
),
Validator
.
isRequired
(
'#apply_job_cv'
),
Validator
.
isRequired
(
'#apply_job_cv'
),
Validator
.
isEmail
(
'#apply_job_email'
)
Validator
.
fileTooLarge
(
'#apply_job_cv'
),
]
Validator
.
isEmail
(
'#apply_job_email'
)
]
})
})
app/views/jobs/show.html.slim
View file @
36ab9ceb
...
@@ -22,7 +22,7 @@ ruby:
...
@@ -22,7 +22,7 @@ ruby:
.job-apply.d-flex.align-items-center.justify-content-between
.job-apply.d-flex.align-items-center.justify-content-between
h2
.align-items-start
h2
.align-items-start
=
@job
.
title
=
@job
.
title
=
link_to
'Apply for this job'
,
apply_path
(
job_id:
@job
.
id
),
class:
'btn btn-primary'
=
link_to
'Apply for this job'
,
apply_
job_
path
(
job_id:
@job
.
id
),
class:
'btn btn-primary'
p
.text-secondary
p
.text-secondary
=
@job
.
company
.
name
=
@job
.
company
.
name
.row.bg-light
.row.bg-light
...
@@ -84,5 +84,5 @@ ruby:
...
@@ -84,5 +84,5 @@ ruby:
li
.text-secondary
li
.text-secondary
=
info
=
info
.job-apply.d-flex.align-items-center.justify-content-between
.job-apply.d-flex.align-items-center.justify-content-between
=
link_to
'Apply for this job'
,
apply_path
(
job_id:
@job
.
id
),
class:
'btn btn-primary'
=
link_to
'Apply for this job'
,
apply_
job_
path
(
job_id:
@job
.
id
),
class:
'btn btn-primary'
=
link_to
'Favorite'
,
'#'
,
class:
'btn btn-primary'
=
link_to
'Favorite'
,
'#'
,
class:
'btn btn-primary'
app/views/user_mailer/apply_job.text.slim
View file @
36ab9ceb
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
=
"
\n
"
=
"
\n
"
'
Thank you for applied with VenJOB. Your applied job's information is as follow:
'
Thank you for applied with VenJOB. Your applied job's information is as follow:
=
"
\n
"
=
"
\n
"
'
Job title:
#{
@job
.
title
}
'
Job title:
#{
show_location
(
@job
.
cities
)
}
=
"
\n
"
'
Location:
#{
@job
.
title
}
=
"
\n
"
=
"
\n
"
'
Company:
#{
@job
.
company
.
name
}
'
Company:
#{
@job
.
company
.
name
}
=
"
\n
"
=
"
\n
"
...
...
config/routes.rb
View file @
36ab9ceb
...
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
...
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
resources
:jobs
,
only:
%i[index show]
resources
:jobs
,
only:
%i[index show]
get
'/apply'
,
to:
'applies#new'
get
'/apply'
,
to:
'applies#new'
,
as: :apply_job
post
'/confirm'
,
to:
'applies#confirm'
post
'/confirm'
,
to:
'applies#confirm'
,
as: :confirm_job
post
'/done'
,
to:
'applies#create'
post
'/done'
,
to:
'applies#create'
,
as: :done_job
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment