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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
45fb6219
Commit
45fb6219
authored
Aug 17, 2021
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'store-file-cv' into 'master'
store-file-cv See merge request
!8
parents
8ca02714
bc2c5d35
Pipeline
#1396
failed with stages
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
22 deletions
+63
-22
app/assets/stylesheets/custom.scss
+8
-1
app/controllers/apply_jobs_controller.rb
+34
-14
app/helpers/application_helper.rb
+10
-0
app/models/industry.rb
+2
-2
app/views/apply_jobs/confirm.html.slim
+5
-3
app/views/apply_jobs/new.html.slim
+4
-2
No files found.
app/assets/stylesheets/custom.scss
View file @
45fb6219
...
@@ -7,9 +7,16 @@
...
@@ -7,9 +7,16 @@
padding-top
:
10px
;
padding-top
:
10px
;
padding-bottom
:
10px
;
padding-bottom
:
10px
;
}
}
body
{
position
:
relative
;
padding-bottom
:
228px
;
min-height
:
100vh
;
}
footer
{
footer
{
min-height
:
227px
;
position
:absolute
;
bottom
:
0
;
width
:
100%
;
}
}
.navbar
ul
li
a
{
.navbar
ul
li
a
{
...
...
app/controllers/apply_jobs_controller.rb
View file @
45fb6219
class
ApplyJobsController
<
ApplicationController
class
ApplyJobsController
<
ApplicationController
include
ApplicationHelper
def
new
def
new
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
or
not_found
return
root_path
unless
job
@apply_job
=
if
session
[
:apply_job
].
present?
if
session
[
:apply_job
].
present?
ApplyJob
.
new
(
session
[
:apply_job
])
@apply_job
=
ApplyJob
.
new
(
session
[
:apply_job
])
else
if
session
[
:blob_id
].
present?
ApplyJob
.
new
@blob
=
ActiveStorage
::
Blob
.
find
(
session
[
:blob_id
])
end
@apply_job
.
assign_attributes
(
cv:
@blob
)
@apply_job
.
job_id
=
job
.
id
end
else
@apply_job
=
ApplyJob
.
new
end
@apply_job
.
job
=
job
end
end
def
confirm
def
confirm
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@apply_job
.
validate
if
@apply_job
.
cv
.
attached?
&&
@apply_job
.
errors
[
:cv
].
empty?
@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
elsif
@apply_job
.
cv
.
attached?
&&
!
@apply_job
.
errors
[
:cv
].
empty?
&&
session
[
:blob_id
]
ActiveStorage
::
Blob
.
find_by
(
id:
session
[
:blob_id
]).
try
(
:destroy
)
elsif
!
@apply_job
.
cv
.
attached?
&&
session
[
:blob_id
]
@blob
=
ActiveStorage
::
Blob
.
find_by
(
id:
session
[
:blob_id
])
@apply_job
.
assign_attributes
(
cv:
@blob
)
end
if
@apply_job
.
valid?
if
@apply_job
.
valid?
session
[
:apply_job
]
=
@apply_job
session
[
:apply_job
]
=
@apply_job
render
:confirm
return
render
:confirm
else
render
:new
end
end
render
:new
end
end
def
done
def
done
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
=
ApplyJob
.
new
(
apply_params
)
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@apply_job
.
user_id
=
User
.
find_by
(
id:
1
).
id
@job
=
Job
.
latest_jobs
.
find
(
apply_params
[
:job_id
])
@job
=
Job
.
latest_jobs
.
find
(
apply_params
[
:job_id
])
@apply_job
.
cv
=
ActiveStorage
::
Blob
.
find
(
session
[
:blob_id
])
if
@apply_job
.
save
if
@apply_job
.
save
ApplyJobMailer
.
with
(
apply_job:
@apply_job
,
job:
@job
).
create_apply
.
deliver_now
ApplyJobMailer
.
with
(
apply_job:
@apply_job
,
job:
@job
).
create_apply
.
deliver_now
flash
.
now
[
:success
]
=
'You have applied successfully'
flash
.
now
[
:success
]
=
'You have applied successfully'
else
else
flash
.
now
[
:danger
]
=
'
Please apply again'
flash
[
:danger
]
=
'Have something wrong.
Please apply again'
redirect_to
root_url
redirect_to
root_url
end
end
session
[
:apply_job
]
=
nil
session
[
:apply_job
]
=
nil
session
[
:blob_id
]
=
nil
end
end
private
private
def
apply_params
def
apply_params
params
.
require
(
:apply_job
).
permit
(
:name
,
:email
,
:cv
,
:job_id
)
params
.
require
(
:apply_job
).
permit
(
:name
,
:email
,
:cv
,
:job_id
,
:id
)
end
end
end
end
\ No newline at end of file
app/helpers/application_helper.rb
View file @
45fb6219
...
@@ -14,4 +14,14 @@ module ApplicationHelper
...
@@ -14,4 +14,14 @@ module ApplicationHelper
def
current_page?
(
*
paths
)
def
current_page?
(
*
paths
)
paths
.
include?
(
request
.
path
)
paths
.
include?
(
request
.
path
)
end
end
def
not_found
raise
ActionController
::
RoutingError
.
new
(
'Not Found'
)
rescue
render_404
end
def
render_404
render
file:
"
#{
Rails
.
root
}
/public/404.html"
,
status: :not_found
end
end
end
app/models/industry.rb
View file @
45fb6219
...
@@ -4,8 +4,8 @@ class Industry < ApplicationRecord
...
@@ -4,8 +4,8 @@ class Industry < ApplicationRecord
has_and_belongs_to_many
:jobs
has_and_belongs_to_many
:jobs
LATEST_INDUSTRY_NUMBER
=
9
LATEST_INDUSTRY_NUMBER
=
9
scope
:top_industries
,
->
{
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:top_industries
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:industry_list
,
->
{
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
scope
:industry_list
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
def
normalize_friendly_id
(
string
)
def
normalize_friendly_id
(
string
)
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
...
...
app/views/apply_jobs/confirm.html.slim
View file @
45fb6219
...
@@ -15,9 +15,10 @@ h2.text-center
...
@@ -15,9 +15,10 @@ h2.text-center
placeholder:
"Type email..."
,
class:
'form-control'
placeholder:
"Type email..."
,
class:
'form-control'
=
f
.
hidden_field
:email
=
f
.
hidden_field
:email
p
.my-1
p
.my-1
=
f
.
label
:cv
,
"CV"
=
f
.
label
:cv
,
"Your CV"
p
br
=
f
.
file_field
:cv
,
required:
true
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
hidden_field
:id
,
value:
@blob
.
id
=
@apply_job
.
cv
.
filename
.span.p-3.text-center
.span.p-3.text-center
=
link_to
"Back"
,
apply_path
(
job_id:
@apply_job
.
job_id
),
class:
"btn btn-primary btn-space"
=
link_to
"Back"
,
apply_path
(
job_id:
@apply_job
.
job_id
),
class:
"btn btn-primary btn-space"
=
f
.
submit
"Done"
,
class:
"btn btn-primary btn-space"
=
f
.
submit
"Done"
,
class:
"btn btn-primary btn-space"
\ No newline at end of file
app/views/apply_jobs/new.html.slim
View file @
45fb6219
...
@@ -12,7 +12,8 @@ h2.text-center.form-title
...
@@ -12,7 +12,8 @@ h2.text-center.form-title
=
f
.
text_field
:email
,
required:
true
,
length:
{
maximum:
255
},
format:
{
with:
ApplyJob
::
VALID_EMAIL_REGEX
},
placeholder:
"Type email..."
,
class:
'form-control'
=
f
.
text_field
:email
,
required:
true
,
length:
{
maximum:
255
},
format:
{
with:
ApplyJob
::
VALID_EMAIL_REGEX
},
placeholder:
"Type email..."
,
class:
'form-control'
p
.my-1
p
.my-1
=
f
.
label
:cv
,
"CV"
=
f
.
label
:cv
,
"CV"
p
=
@apply_job
.
cv
.
filename
=
f
.
file_field
:cv
,
required:
true
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
br
=
f
.
file_field
:cv
,
accept:
"application/pdf"
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
.span.p-3.text-center
.span.p-3.text-center
=
f
.
submit
"Confirm"
,
class:
"btn btn-primary"
=
f
.
submit
"Confirm"
,
class:
"btn btn-primary"
\ 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