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
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xuan Trung Le
venjob
Commits
d291ccb3
Commit
d291ccb3
authored
Oct 25, 2017
by
Xuan Trung Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add history page
parent
9e535171
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
97 additions
and
8 deletions
+97
-8
app/controllers/jobs_controller.rb
+1
-0
app/controllers/my_pages_controller.rb
+4
-0
app/models/job.rb
+4
-0
app/models/user.rb
+16
-0
app/models/users_job.rb
+4
-0
app/views/layouts/_menu.html.erb
+6
-2
app/views/my_pages/history.html.erb
+29
-0
app/views/my_pages/index.html.erb
+1
-1
config/routes.rb
+6
-4
db/migrate/20171024093324_create_users_jobs.rb
+11
-0
db/schema.rb
+15
-1
No files found.
app/controllers/jobs_controller.rb
View file @
d291ccb3
...
...
@@ -7,6 +7,7 @@ class JobsController < ApplicationController
end
def
show
current_user
.
view
(
Job
.
find
(
params
[
:id
]))
if
current_user
end
def
city
...
...
app/controllers/my_pages_controller.rb
View file @
d291ccb3
...
...
@@ -6,4 +6,8 @@ class MyPagesController < ApplicationController
def
my_job
@jobs
=
current_user
.
applied_jobs
.
includes
(
:apply_jobs
).
includes
(
:company
)
end
def
history
@jobs
=
current_user
.
viewed_jobs
.
includes
(
:apply_jobs
).
includes
(
:company
).
limit
(
20
)
end
end
app/models/job.rb
View file @
d291ccb3
...
...
@@ -9,6 +9,10 @@ class Job < ApplicationRecord
has_many
:cities_jobs
has_many
:cities
,
through: :cities_jobs
has_many
:users_jobs
has_many
:views
,
->
{
where
(
action: :VIEW
)
},
class_name:
'UsersJob'
has_many
:users_has_viewed
,
through: :views
,
class_name:
'User'
,
source: :user
scope
:top_list
,
->
{
order
(
updated_date: :desc
).
limit
(
Settings
.
top
.
job_per_page
)
}
def
self
.
create_new_jobs
(
arr_jobs
)
...
...
app/models/user.rb
View file @
d291ccb3
...
...
@@ -4,8 +4,24 @@ class User < ApplicationRecord
has_many
:favorite_jobs
has_many
:liked_jobs
,
through: :favorite_jobs
,
class_name:
'Job'
,
source: :job
has_many
:users_jobs
has_many
:jobs_views
,
->
{
where
(
action: :VIEW
)
},
class_name:
'UsersJob'
has_many
:viewed_jobs
,
through: :jobs_views
,
class_name:
'Job'
,
source: :job
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
def
view
(
job
)
viewed_jobs
<<
job
unless
viewed_jobs
.
include?
(
job
)
end
def
like
(
job
)
liked_jobs
<<
job
unless
liked_jobs
.
include?
(
job
)
end
def
unlike
(
job
)
liked_jobs
.
delete
(
job
.
id
)
end
end
app/models/users_job.rb
0 → 100644
View file @
d291ccb3
class
UsersJob
<
ApplicationRecord
belongs_to
:user
belongs_to
:job
end
app/views/layouts/_menu.html.erb
View file @
d291ccb3
...
...
@@ -11,7 +11,7 @@
<ul
class=
"nav navbar-nav navbar-right"
>
<%-
if
current_user
-%>
my_pages
<li>
<%=
link_to
my_pages_path
do
%>
<%=
link_to
my_
my_
pages_path
do
%>
<i
class=
"fa fa-user"
aria-hidden=
"true"
></i>
My Page
<%
end
%>
</li>
...
...
@@ -26,7 +26,11 @@
<%-
end
-%>
<li><a
href=
"#"
><i
class=
"fa fa-star"
aria-hidden=
"true"
></i></span>
Favorite
</a></li>
<li><a
href=
"#"
><i
class=
"fa fa-history"
aria-hidden=
"true"
></i></span>
History
</a></li>
<li>
<%=
link_to
history_my_pages_path
do
%>
<i
class=
"fa fa-history"
aria-hidden=
"true"
></i>
History
<%
end
%>
</li>
</ul>
</div>
</nav>
app/views/my_pages/history.html.erb
0 → 100644
View file @
d291ccb3
<div
class=
"row"
>
<div
class=
"container"
>
<div
class=
"jobs clearfix"
>
<div
class=
"job col-md-12"
>
<h3>
History
</h3>
<table
class=
"table"
>
<tbody>
<%-
@jobs
.
each
do
|
job
|
-%>
<tr>
<td
class=
"col-md-1 position-relative"
>
<input
type=
"radio"
name=
"rbn-apply-job"
class=
"mid-heigth"
>
</td>
<td
class=
"col-md-9"
>
<h4
class=
"mr0"
>
<%=
link_to
job
.
name
,
job_path
(
job
)
%>
</h4>
<p><strong>
Description:
</strong>
<%=
strip_tags
(
job
.
description
)[
0
...
250
]
%>
...
</p>
<p>
<span>
<%=
"<strong>Loacation</strong>:
#{
job
.
company
.
location
}
"
.
html_safe
%>
</span>
<span
class=
"navbar-right"
>
<%=
"<strong>Salary</strong>:
#{
job
.
salary
}
"
.
html_safe
%>
</span>
</p>
</td>
</tr>
<%
end
%>
</tbody>
</table>
</div>
<%=
button_to
"Apply"
,
nil
,
class:
"btn btn-primary btn-lg"
%>
</div>
</div>
</div>
app/views/my_pages/index.html.erb
View file @
d291ccb3
...
...
@@ -25,7 +25,7 @@
<span>
<%=
link_to
@user
.
cv
,
"#"
%>
</span>
<br>
<div
class=
"col-md-6"
>
<%=
link_to
"Update"
,
"#"
,
class:
"btn btn-primary navbar-right"
%>
<%=
link_to
"Update"
,
edit_user_registration_path
,
class:
"btn btn-primary navbar-right"
%>
</div>
<div
class=
"col-md-6"
>
<%=
link_to
"My jobs"
,
jobs_my_pages_path
,
class:
"btn btn-primary"
%>
...
...
config/routes.rb
View file @
d291ccb3
...
...
@@ -6,14 +6,16 @@ Rails.application.routes.draw do
resources
:industries
,
only:
[
:index
,
:show
]
resources
:jobs
do
collection
do
get
'city/:city_id'
=>
"jobs#city"
,
as: :city
get
'industry/:industry_id'
=>
"jobs#industry"
,
as: :industry
get
'company/:company_id'
=>
"jobs#company"
,
as: :company
get
'city/:city_id'
=>
'jobs#city'
,
as: :city
get
'industry/:industry_id'
=>
'jobs#industry'
,
as: :industry
get
'company/:company_id'
=>
'jobs#company'
,
as: :company
end
end
resources
:my_pages
,
only:
[
:index
]
do
resources
:my_pages
,
path:
''
,
only:
[
:index
]
do
collection
do
get
'my'
=>
'my_pages#index'
get
'my/jobs'
=>
'my_pages#my_job'
,
as: :jobs
get
'history'
=>
'my_pages#history'
,
as: :history
end
end
end
db/migrate/20171024093324_create_users_jobs.rb
0 → 100644
View file @
d291ccb3
class
CreateUsersJobs
<
ActiveRecord
::
Migration
[
5.1
]
def
change
create_table
:users_jobs
do
|
t
|
t
.
references
:user
,
foreign_key:
true
t
.
references
:job
,
foreign_key:
true
t
.
string
:action
t
.
timestamps
end
end
end
db/schema.rb
View file @
d291ccb3
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201710
16091830
)
do
ActiveRecord
::
Schema
.
define
(
version:
201710
24093324
)
do
create_table
"apply_jobs"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
t
.
bigint
"job_id"
...
...
@@ -18,6 +18,8 @@ ActiveRecord::Schema.define(version: 20171016091830) do
t
.
string
"cv"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"name"
,
null:
false
t
.
string
"email"
,
null:
false
t
.
index
[
"job_id"
],
name:
"index_apply_jobs_on_job_id"
t
.
index
[
"user_id"
],
name:
"index_apply_jobs_on_user_id"
end
...
...
@@ -124,4 +126,16 @@ ActiveRecord::Schema.define(version: 20171016091830) do
t
.
index
[
"reset_password_token"
],
name:
"index_users_on_reset_password_token"
,
unique:
true
end
create_table
"users_jobs"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
t
.
bigint
"user_id"
t
.
bigint
"job_id"
t
.
string
"action"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"job_id"
],
name:
"index_users_jobs_on_job_id"
t
.
index
[
"user_id"
],
name:
"index_users_jobs_on_user_id"
end
add_foreign_key
"users_jobs"
,
"jobs"
add_foreign_key
"users_jobs"
,
"users"
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