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
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
25 deletions
+43
-25
app/controllers/applies_controller.rb
+13
-3
app/javascript/packs/validation.js
+15
-0
app/views/applies/_validate_form.html.slim
+0
-9
app/views/applies/confirm.html.slim
+3
-4
app/views/applies/new.html.slim
+4
-3
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
before_action
:load_job
,
only:
%i[new confirm create]
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
)
end
...
...
@@ -11,6 +14,12 @@ class AppliesController < ApplicationController
@apply
.
job
=
@job
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
else
render
'new'
...
...
@@ -20,7 +29,7 @@ class AppliesController < ApplicationController
def
create
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
.
job
=
@job
@apply
.
cv
.
attach
(
params
[
:apply_job
][
:cv
])
@apply
.
cv
=
ActiveStorage
::
Blob
.
find
(
session
[
:blob_id
])
if
@apply
.
save
UserMailer
.
apply_job
(
current_user
,
@job
,
@apply
).
deliver_now
...
...
@@ -28,6 +37,7 @@ class AppliesController < ApplicationController
else
render
'new'
end
session
[
:blob_id
]
=
nil
session
[
:apply_job
]
=
nil
end
...
...
@@ -41,7 +51,7 @@ class AppliesController < ApplicationController
end
def
apply_params
params
.
require
(
:apply_job
).
permit
(
:user_name
,
:email
,
:cv
)
params
.
require
(
:apply_job
).
permit
(
:user_name
,
:email
,
:cv
,
:job_id
)
end
def
current_user
...
...
app/javascript/packs/validation.js
View file @
36ab9ceb
...
...
@@ -96,3 +96,18 @@ Validator.isEmail = function (selector) {
}
}
}
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 @@
h1
.my-5.text-center
|
Confirmation
.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
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
=
f
.
hidden_field
:blob_id
,
value:
@blob
.
id
.col-2
=
f
.
label
:name
,
'Full name:'
,
class:
'form-label label'
.col-10
...
...
@@ -30,12 +31,10 @@
.col-2
=
f
.
label
:cv
,
'Cv: '
,
class:
'form-label label'
.col-10
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
span
.form-control
=
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'
=
render
'validate_form'
app/views/applies/new.html.slim
View file @
36ab9ceb
-
provide
(
:title
,
'Apply job'
)
.container
=
render
'ribbon'
.container
...
...
@@ -7,7 +8,7 @@
p
.fs-5.fw-bold.mb-4.text-center
=
@job
.
title
.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
.row.mb-5.form-group
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
...
...
@@ -28,12 +29,11 @@
.col-2
=
f
.
label
:cv
,
class:
'form-label label'
.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
br
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 my-4 btn-height'
,
data:
{
disable_with:
false
}
=
render
'validate_form'
javascript:
Validator
({
form
:
'#apply-form'
,
...
...
@@ -42,6 +42,7 @@ javascript:
Validator
.
isRequired
(
'#apply_job_user_name'
),
Validator
.
isRequired
(
'#apply_job_email'
),
Validator
.
isRequired
(
'#apply_job_cv'
),
Validator
.
fileTooLarge
(
'#apply_job_cv'
),
Validator
.
isEmail
(
'#apply_job_email'
)
]
})
app/views/jobs/show.html.slim
View file @
36ab9ceb
...
...
@@ -22,7 +22,7 @@ ruby:
.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
.
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
=
@job
.
company
.
name
.row.bg-light
...
...
@@ -84,5 +84,5 @@ ruby:
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
.
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'
app/views/user_mailer/apply_job.text.slim
View file @
36ab9ceb
...
...
@@ -4,7 +4,9 @@
=
"
\n
"
'
Thank you for applied with VenJOB. Your applied job's information is as follow:
=
"
\n
"
'
Job title:
#{
@job
.
title
}
'
Job title:
#{
show_location
(
@job
.
cities
)
}
=
"
\n
"
'
Location:
#{
@job
.
title
}
=
"
\n
"
'
Company:
#{
@job
.
company
.
name
}
=
"
\n
"
...
...
config/routes.rb
View file @
36ab9ceb
...
...
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
resources
:jobs
,
only:
%i[index show]
get
'/apply'
,
to:
'applies#new'
post
'/confirm'
,
to:
'applies#confirm'
post
'/done'
,
to:
'applies#create'
get
'/apply'
,
to:
'applies#new'
,
as: :apply_job
post
'/confirm'
,
to:
'applies#confirm'
,
as: :confirm_job
post
'/done'
,
to:
'applies#create'
,
as: :done_job
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