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
24d4089f
Commit
24d4089f
authored
Aug 12, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed review p3, add job not found
parent
41dfcb2e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
20 deletions
+39
-20
app/assets/stylesheets/applies.scss
+1
-2
app/controllers/applies_controller.rb
+15
-11
app/controllers/jobs_controller.rb
+2
-1
app/views/applies/confirm.html.slim
+3
-4
app/views/applies/new.html.slim
+1
-2
app/views/shared/_job_not_found.html.slim
+17
-0
No files found.
app/assets/stylesheets/applies.scss
View file @
24d4089f
...
@@ -81,4 +81,4 @@ $text-color-white: #fff;
...
@@ -81,4 +81,4 @@ $text-color-white: #fff;
.btn-height
{
.btn-height
{
height
:
50px
;
height
:
50px
;
}
}
\ No newline at end of file
app/controllers/applies_controller.rb
View file @
24d4089f
class
AppliesController
<
ApplicationController
class
AppliesController
<
ApplicationController
before_action
:load_job
,
only:
%i[confirm create]
before_action
:load_job
,
only:
%i[
new
confirm create]
def
new
def
new
@job
=
Job
.
find_by
(
id:
params
[
:job_id
])
@apply
=
current_user
.
apply_jobs
.
build
@apply
=
@job
.
apply_jobs
.
build
end
end
def
confirm
def
confirm
@user
=
User
.
find_by
(
id:
1
)
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
=
@job
.
apply_jobs
.
build
(
apply_params
)
@apply
.
job
=
@job
@apply
.
user_id
=
@user
.
id
render
'new'
if
@apply
.
invalid?
render
'new'
if
@apply
.
invalid?
end
end
def
create
def
create
@user
=
User
.
find_by
(
id:
1
)
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
=
@job
.
apply_jobs
.
build
(
apply_params
)
@apply
.
job
=
@job
@apply
.
user_id
=
@user
.
id
@apply
.
cv
.
attach
(
params
[
:apply_job
][
:cv
])
@apply
.
cv
.
attach
(
params
[
:apply_job
][
:cv
])
if
@apply
.
save
if
@apply
.
save
UserMailer
.
apply_job
(
@
user
,
@job
,
@apply
).
deliver_now
UserMailer
.
apply_job
(
current_
user
,
@job
,
@apply
).
deliver_now
flash
.
now
[
:info
]
=
'Job application information has been sent to your email'
flash
.
now
[
:info
]
=
'Job application information has been sent to your email'
else
else
render
'new'
render
'new'
...
@@ -31,10 +28,17 @@ class AppliesController < ApplicationController
...
@@ -31,10 +28,17 @@ class AppliesController < ApplicationController
private
private
def
load_job
def
load_job
@job
=
Job
.
find_by
(
id:
params
[
:apply_job
][
:job_id
])
job_id
=
params
[
:job_id
]
||
params
[
:apply_job
][
:job_id
]
@job
=
Job
.
find_by
(
id:
job_id
)
render
partial:
'shared/job_not_found'
if
@job
.
nil?
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
)
end
end
def
current_user
@current_user
||=
User
.
first
end
end
end
app/controllers/jobs_controller.rb
View file @
24d4089f
...
@@ -8,7 +8,8 @@ class JobsController < ApplicationController
...
@@ -8,7 +8,8 @@ class JobsController < ApplicationController
end
end
def
show
def
show
@job
=
Job
.
find
(
params
[
:id
])
@job
=
Job
.
find_by
(
id:
params
[
:id
])
render
partial:
'shared/job_not_found'
if
@job
.
nil?
end
end
private
private
...
...
app/views/applies/confirm.html.slim
View file @
24d4089f
...
@@ -10,13 +10,13 @@
...
@@ -10,13 +10,13 @@
=
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
|
.row.mb-5
.row.mb-5
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
,
class:
'form-control'
=
f
.
hidden_field
:job_id
,
value:
@job
.
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
span
.mx-2.label.form-control
span
.mx-2.label.form-control
=
@apply
.
user_name
=
@apply
.
user_name
=
f
.
hidden_field
:user_name
,
value:
@apply
.
user_name
,
class:
'form-control'
=
f
.
hidden_field
:user_name
,
value:
@apply
.
user_name
.row.mb-5
.row.mb-5
.col-2
.col-2
...
@@ -24,11 +24,10 @@
...
@@ -24,11 +24,10 @@
.col-10
.col-10
span
.mx-2.label.form-control
span
.mx-2.label.form-control
=
@apply
.
email
=
@apply
.
email
=
f
.
hidden_field
:email
,
value:
@apply
.
email
,
class:
'form-control'
=
f
.
hidden_field
:email
,
value:
@apply
.
email
.row.mb-5
.row.mb-5
.col-2
.col-2
/ = 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'
.col-10
.col-10
=
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'
...
...
app/views/applies/new.html.slim
View file @
24d4089f
...
@@ -5,13 +5,12 @@
...
@@ -5,13 +5,12 @@
h1
.my-5.text-center
h1
.my-5.text-center
|
Apply form
|
Apply form
p
.fs-5.fw-bold.mb-4.text-center
p
.fs-5.fw-bold.mb-4.text-center
|
Apply for
=
@job
.
title
=
@job
.
title
.col
.col
=
form_with
(
model:
@apply
,
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
.row.mb-5
.row.mb-5
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
,
class:
'form-control'
=
f
.
hidden_field
:job_id
,
value:
@job
.
id
.col-2
.col-2
=
f
.
label
:user_name
,
'Full name'
,
class:
'form-label label'
=
f
.
label
:user_name
,
'Full name'
,
class:
'form-label label'
.col-10
.col-10
...
...
app/views/shared/_job_not_found.html.slim
0 → 100644
View file @
24d4089f
link
crossorigin
=
"anonymous"
href
=
"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity
=
"sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
rel
=
"stylesheet"
/
.container
.row
.col-md-12
.error-template.text-center
h1
.my-4
|
Oops!
h2
.my-2
|
Job Not Found
.error-details.mb-5
|
Sorry, an error has occured, Requested page not found!
.error-actions
=
link_to
'Take Me Home'
,
root_path
,
class:
'btn btn-primary btn-lg mx-2'
=
link_to
'Contact Support'
,
'#'
,
class:
'btn btn-secondary mx-2 btn-lg'
\ No newline at end of file
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