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
bddaf152
Commit
bddaf152
authored
Sep 09, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix reviews
parent
294232a1
Pipeline
#1421
canceled with stages
in 0 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
17 deletions
+23
-17
app/controllers/favorite_jobs_controller.rb
+7
-3
app/controllers/jobs_controller.rb
+1
-1
app/helpers/application_helper.rb
+1
-1
app/models/history_job.rb
+1
-0
app/views/favorite_jobs/index.html.slim
+7
-7
app/views/history_jobs/index.html.slim
+3
-3
app/views/jobs/index.html.slim
+3
-2
No files found.
app/controllers/favorite_jobs_controller.rb
View file @
bddaf152
class
FavoriteJobsController
<
ApplicationController
class
FavoriteJobsController
<
ApplicationController
include
ApplicationHelper
include
ApplicationHelper
before_action
:check_params_job
,
only:
%i[update destroy]
def
index
def
index
@favorites
=
favorite_query
.
order_favorite
(
current_user
).
page
(
params
[
:page
])
@favorites
=
favorite_query
.
order_favorite
(
current_user
).
page
(
params
[
:page
])
end
end
def
update
def
update
job
=
Job
.
find_by
(
id:
params
[
:job_id
])
or
not_found
favorite
=
favorite_query
.
find_favorite
(
job_params
,
current_user
)
favorite
=
favorite_query
.
find_favorite
(
job_params
,
current_user
)
if
favorite
.
nil?
if
favorite
.
nil?
FavoriteJob
.
create
(
job:
job
,
user:
current_user
)
FavoriteJob
.
create
(
job:
@
job
,
user:
current_user
)
@favorite_exists
=
true
@favorite_exists
=
true
else
else
favorite
.
destroy
favorite
.
destroy
@favorite_exists
=
false
@favorite_exists
=
false
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
new_user_session_path
,
alert:
'
Please sign in
.'
}
format
.
html
{
redirect_to
new_user_session_path
,
alert:
'
You need to sign in or sign up before continuing
.'
}
format
.
js
{}
format
.
js
{}
end
end
end
end
...
@@ -36,4 +36,8 @@ class FavoriteJobsController < ApplicationController
...
@@ -36,4 +36,8 @@ class FavoriteJobsController < ApplicationController
def
favorite_query
def
favorite_query
@favorite_query
||=
FavoriteQuery
.
new
@favorite_query
||=
FavoriteQuery
.
new
end
end
def
check_params_job
@job
=
Job
.
find_by
(
id:
params
[
:job_id
])
or
not_found
end
end
end
app/controllers/jobs_controller.rb
View file @
bddaf152
...
@@ -30,7 +30,7 @@ class JobsController < ApplicationController
...
@@ -30,7 +30,7 @@ class JobsController < ApplicationController
else
else
history
.
touch
(
:updated_at
)
history
.
touch
(
:updated_at
)
end
end
HistoryJob
.
first
.
destroy
if
HistoryJob
.
count
>
20
HistoryJob
.
first
.
destroy
if
HistoryJob
.
count
>
HistoryJob
::
LIMIT_HISTORY
end
end
def
job_params
def
job_params
...
...
app/helpers/application_helper.rb
View file @
bddaf152
...
@@ -26,6 +26,6 @@ module ApplicationHelper
...
@@ -26,6 +26,6 @@ module ApplicationHelper
end
end
def
favorite_text
def
favorite_text
return
@favorite_exists
?
'Unfavorite'
:
'Favorite'
@favorite_exists
?
'Unfavorite'
:
'Favorite'
end
end
end
end
app/models/history_job.rb
View file @
bddaf152
class
HistoryJob
<
ApplicationRecord
class
HistoryJob
<
ApplicationRecord
belongs_to
:user
belongs_to
:user
belongs_to
:job
belongs_to
:job
LIMIT_HISTORY
=
20
end
end
app/views/favorite_jobs/index.html.slim
View file @
bddaf152
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
h3
.p-3.text-center
h3
.p-3.text-center
|
Favorite Jobs
|
Favorite Jobs
.
col-6.offset-md-5.tex
t-center
.
d-flex.justify-conten
t-center
=
paginate
@favorites
,
window:
1
=
paginate
@favorites
,
window:
1
=
form_with
(
url:
apply_path
,
method: :get
)
do
|
f
|
=
form_with
(
url:
apply_path
,
method: :get
)
do
|
f
|
-
@favorites
.
each
do
|
favorite
|
-
@favorites
.
each
do
|
favorite
|
.row.bg-white
.row.bg-white
.col-1.p-3.
border.card-body.text-dark.text
-center
.col-1.p-3.
card-body.text-dark.text-center.align-self
-center
=
f
.
radio_button
:job_id
,
favorite
.
job
.
id
,
class:
"form-check-input mt-0"
=
f
.
radio_button
:job_id
,
favorite
.
job
.
id
,
required:
true
,
class:
"form-check-input mt-0"
.col-9.p-3.
border.card-body.text-dark
.col-9.p-3.
align-self-center
h5
.mb-1
h5
.mb-1
=
link_to
favorite
.
job
.
title
,
detail_path
(
favorite
.
job
.
slug
)
=
link_to
favorite
.
job
.
title
,
detail_path
(
favorite
.
job
.
slug
)
p
.mb-1
p
.mb-1
...
@@ -21,12 +21,12 @@ h3.p-3.text-center
...
@@ -21,12 +21,12 @@ h3.p-3.text-center
=
favorite
.
job
.
cities
.
map
(
&
:name
).
uniq
.
join
(
' | '
)
=
favorite
.
job
.
cities
.
map
(
&
:name
).
uniq
.
join
(
' | '
)
p
.mb-1
p
.mb-1
=
truncate
(
favorite
.
job
.
overview
,
length:
250
)
=
truncate
(
favorite
.
job
.
overview
,
length:
250
)
.col-
sm-2.p-3.border.favourite
.col-
2.p-3.text-center.align-self-center
=
link_to
"Remove"
,
unfavorite_path
(
job_id:
favorite
.
job
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
},
class:
"btn btn-outline-primary"
=
link_to
"Remove"
,
unfavorite_path
(
job_id:
favorite
.
job
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
},
class:
"btn btn-outline-primary"
-
if
@favorites
.
any?
-
if
@favorites
.
any?
h6
.offset-md-4
.p-2
.d-flex.justify-content-center
.p-2
=
page_entries_info
@favorites
=
page_entries_info
@favorites
.
col-6.offset-md-5.tex
t-center
.
d-flex.justify-conten
t-center
=
paginate
@favorites
,
window:
1
=
paginate
@favorites
,
window:
1
.span.p-3.text-center
.span.p-3.text-center
=
f
.
submit
"Apply job"
,
class:
"btn btn-primary btn-lg"
=
f
.
submit
"Apply job"
,
class:
"btn btn-primary btn-lg"
...
...
app/views/history_jobs/index.html.slim
View file @
bddaf152
...
@@ -5,9 +5,9 @@ h3.p-3.text-center
...
@@ -5,9 +5,9 @@ h3.p-3.text-center
=
form_with
(
url:
apply_path
,
method: :get
)
do
|
f
|
=
form_with
(
url:
apply_path
,
method: :get
)
do
|
f
|
-
@histories
.
each
do
|
history
|
-
@histories
.
each
do
|
history
|
.row.bg-white
.row.bg-white
.col-1.p-3.
border.card-body.text-dark.text
-center
.col-1.p-3.
card-body.text-dark.text-center.align-self
-center
=
f
.
radio_button
:job_id
,
history
.
job
.
id
,
class:
"form-check-input mt-0"
=
f
.
radio_button
:job_id
,
history
.
job
.
id
,
required:
true
,
class:
"form-check-input mt-0"
.col-11.p-3.
border.card-body.text-dark
.col-11.p-3.
align-self-center
h5
.mb-1
h5
.mb-1
=
link_to
history
.
job
.
title
,
detail_path
(
history
.
job
.
slug
)
=
link_to
history
.
job
.
title
,
detail_path
(
history
.
job
.
slug
)
p
.mb-1
p
.mb-1
...
...
app/views/jobs/index.html.slim
View file @
bddaf152
...
@@ -28,11 +28,11 @@
...
@@ -28,11 +28,11 @@
p
.mb-1
p
.mb-1
=
truncate
(
job
.
overview
,
length:
250
)
=
truncate
(
job
.
overview
,
length:
250
)
.col-sm-2.p-3.favourite
.col-sm-2.p-3.favourite
-
unless
current_user
.
favorite_jobs
.
exists?
(
job
.
id
)
-
if
user_signed_in?
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
id:
'favorite_link'
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
id:
'favorite_link'
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
-
else
-
else
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
class:
"btn btn-outline-primary btn-lg"
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
class:
"btn btn-outline-primary btn-lg"
h6
.offset-md-4.px
-5
h6
.offset-md-4.px
=
page_entries_info
@jobs
=
page_entries_info
@jobs
h6
.offset-md-4
h6
.offset-md-4
=
paginate
@jobs
,
window:
1
=
paginate
@jobs
,
window:
1
\ 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