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
Huỳnh Thiên Phước
venjob
Commits
d91084a9
Commit
d91084a9
authored
Sep 01, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created ID 8-9
parent
c4b23a2b
Pipeline
#1054
failed with stages
in 0 seconds
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
34 deletions
+15
-34
app/controllers/favorite_jobs_controller.rb
+2
-2
app/controllers/history_jobs_controller.rb
+1
-20
app/controllers/jobs_controller.rb
+4
-2
app/models/job.rb
+2
-0
app/views/favorite_jobs/index.html.erb
+2
-2
app/views/history_jobs/_history_job.html.erb
+2
-3
app/views/history_jobs/destroy.js.erb
+0
-2
app/views/history_jobs/index.html.erb
+1
-1
config/routes.rb
+1
-2
No files found.
app/controllers/favorite_jobs_controller.rb
View file @
d91084a9
...
...
@@ -27,9 +27,9 @@ class FavoriteJobsController < ApplicationController
page_number
=
@count
/
Job
::
LIMIT_PAGE
link_url
=
request
.
referer
.
to_s
.
split
(
"="
)
return
redirect_to
link_url
[
0
]
+
"="
+
page_number
.
to_s
if
count_on_page
==
0
&&
link_url
[
1
].
to_i
==
page_number
+
1
return
redirect_to
link_url
[
0
]
+
"="
+
page_number
.
to_s
if
count_on_page
==
Job
::
DIVISIBLE
&&
link_url
[
1
].
to_i
==
page_number
+
1
return
redirect_to
request
.
referer
if
count_on_page
==
0
return
redirect_to
request
.
referer
if
count_on_page
==
Job
::
DIVISIBLE
end
end
...
...
app/controllers/history_jobs_controller.rb
View file @
d91084a9
...
...
@@ -4,26 +4,7 @@ class HistoryJobsController < ApplicationController
def
index
@count
=
current_user
.
histories
.
count
@history_jobs
=
current_user
.
histories
.
order_history
.
page
(
params
[
:page
]).
per
(
Job
::
LIMIT_PAGE
)
end
def
destroy
@job
=
Job
.
find_by_id
(
params
[
:job_id
])
@unfollow
=
current_user
.
remove_history!
(
params
[
:job_id
])
respond_to
{
|
format
|
format
.
js
}
if
request
.
referer
.
include?
(
"history"
)
@count
=
current_user
.
histories
.
count
count_on_page
=
@count
%
Job
::
LIMIT_PAGE
page_number
=
@count
/
Job
::
LIMIT_PAGE
link_url
=
request
.
referer
.
to_s
.
split
(
"="
)
return
redirect_to
link_url
[
0
]
+
"="
+
page_number
.
to_s
if
count_on_page
==
0
&&
link_url
[
1
].
to_i
==
page_number
+
1
return
redirect_to
request
.
referer
if
count_on_page
==
0
end
@history_jobs
=
current_user
.
histories
.
order_history
end
private
...
...
app/controllers/jobs_controller.rb
View file @
d91084a9
...
...
@@ -32,9 +32,11 @@ class JobsController < ApplicationController
if
signed_in?
@user
=
JobApplied
.
where
(
user_id:
current_user
.
id
,
job_id:
params
[
:id
])
history_jobs
=
current_user
.
histories
.
order_history
history_jobs
.
last
.
destroy
if
history_jobs
.
count
>=
Job
::
LIMIT_HISTORY
founded_history
=
current_user
.
histories
.
find_by
(
job_id:
params
[
:id
])
binding
.
pry
return
founded_history
.
update
(
job_id:
params
[
:id
])
if
founded_history
.
present?
return
founded_history
.
update
(
updated_at:
Time
.
current
.
utc
)
if
founded_history
.
present?
history
=
current_user
.
histories
.
create!
(
job_id:
params
[
:id
])
end
...
...
app/models/job.rb
View file @
d91084a9
...
...
@@ -18,6 +18,8 @@ class Job < ApplicationRecord
has_many
:users
,
through: :histories
LIMIT_PAGE
=
20
LIMIT_HISTORY
=
20
DIVISIBLE
=
0
scope
:limit_job
,
->
{
includes
(
:cities
,
:company
).
order
(
created_at: :desc
).
limit
(
5
)
}
...
...
app/views/favorite_jobs/index.html.erb
View file @
d91084a9
...
...
@@ -5,13 +5,13 @@
<div
class=
"favorite-page"
>
<%=
form_tag
apply_job_path
(
job_id:
params
[
:job_id
]),
method: :get
,
enforce_utf8:
false
do
%>
<%=
render
partial:
"favorite_jobs/favorite_job"
,
collection:
@favorited_jobs
%>
<div
class=
"row justify-content-center"
>
<div
class=
"row justify-content-center
apply-btn
"
>
<%=
submit_tag
'Apply Job'
,
name:
nil
,
class:
'btn btn-lg btn-danger'
%>
</div>
<%
end
%>
</div>
<%=
paginate
@favorited_jobs
,
outer_window:
2
,
window:
1
%>
<%
else
%>
<h1
class=
"let-favorite"
>
Let's
Save Job in Your Favorite
</h1>
<h1
class=
"let-favorite"
>
Let's
Favorite Job
</h1>
<%
end
%>
</div>
app/views/history_jobs/_history_job.html.erb
View file @
d91084a9
...
...
@@ -11,17 +11,16 @@
<%
end
%>
</div>
<div
class=
"row"
>
<div
class=
"introduction col-1
0
"
>
<div
class=
"introduction col-1
2
"
>
<%=
strip_tags
(
history_job
.
job
.
format_desc
)
%>
<br>
<%=
link_to
'Read more..'
,
job_detail_path
(
history_job
.
job
.
id
)
%>
</div>
<div
class=
"col-6"
>
▼
<%=
history_job
.
job
.
cities
.
map
(
&
:name
).
join
(
' | '
)
%>
</div>
<div
class=
"salary col-
3
"
>
<div
class=
"salary col-
6
"
>
Salary:
<%=
history_job
.
job
.
salary
%>
</div>
<%=
link_to
"Remove"
,
remove_history_job_path
(
job_id:
history_job
.
job
.
id
),
method: :delete
,
remote:
true
,
class:
"btn btn-danger"
,
id:
"button-remove"
%>
</div>
</div>
</div>
...
...
app/views/history_jobs/destroy.js.erb
deleted
100644 → 0
View file @
c4b23a2b
$(".job-id-
<%=
@job
.
id
%>
").remove();
$(".count-histories-jobs").html("
<%=
@count
%>
");
app/views/history_jobs/index.html.erb
View file @
d91084a9
...
...
@@ -4,7 +4,7 @@
<div
class=
"history-page"
>
<%=
form_tag
apply_job_path
(
job_id:
params
[
:job_id
]),
method: :get
,
enforce_utf8:
false
do
%>
<%=
render
partial:
"history_jobs/history_job"
,
collection:
@history_jobs
%>
<div
class=
"row justify-content-center"
>
<div
class=
"row justify-content-center
apply-btn
"
>
<%=
submit_tag
'Apply Job'
,
name:
nil
,
class:
'btn btn-lg btn-danger'
%>
</div>
<%
end
%>
...
...
config/routes.rb
View file @
d91084a9
...
...
@@ -37,10 +37,9 @@ Rails.application.routes.draw do
delete
'unfavorite_job'
,
to:
'favorite_jobs#destroy'
,
as: :unfavorite_job
get
'favorite'
,
to:
'favorite_jobs#index'
,
as: :favorite_jobs
delete
'remove_history'
,
to:
'history_jobs#destroy'
,
as: :remove_history_job
get
'history'
,
to:
'history_jobs#index'
,
as: :history_jobs
resources
:history_jobs
,
only:
[
:
destroy
,
:
index
]
resources
:history_jobs
,
only:
[
:index
]
resources
:favorite_jobs
,
only:
[
:create
,
:destroy
,
:index
]
resources
:job_applieds
,
only:
[
:new
,
:create
]
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
...
...
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