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
fefcd9b2
Commit
fefcd9b2
authored
Oct 26, 2017
by
Xuan Trung Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update link to download cv my page
parent
5336f4c6
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
173 additions
and
93 deletions
+173
-93
app/assets/javascripts/application.js
+3
-0
app/controllers/application_controller.rb
+1
-0
app/controllers/applies_controller.rb
+0
-1
app/controllers/cities_controller.rb
+1
-0
app/controllers/industries_controller.rb
+1
-0
app/controllers/jobs_controller.rb
+1
-0
app/controllers/my_pages_controller.rb
+9
-0
app/helpers/application_helper.rb
+3
-0
app/models/job.rb
+6
-9
app/models/user.rb
+18
-12
app/models/view_job.rb
+4
-0
app/views/jobs/show.html.erb
+12
-3
app/views/layouts/_menu.html.erb
+10
-2
app/views/my_pages/history.html.erb
+27
-18
app/views/my_pages/index.html.erb
+36
-29
config/environments/development.rb
+12
-12
config/routes.rb
+9
-1
db/migrate/20171026030532_create_view_jobs.rb
+10
-0
db/schema.rb
+10
-6
No files found.
app/assets/javascripts/application.js
View file @
fefcd9b2
...
...
@@ -17,4 +17,7 @@
$
(
document
).
ready
(
function
(){
$
(
'.message'
).
delay
(
5000
).
fadeOut
(
'slow'
);
$
(
document
).
on
(
'change'
,
'input[name=job_id]'
,
function
(
event
)
{
$
(
'#apply'
).
removeAttr
(
'disabled'
)
});
});
app/controllers/application_controller.rb
View file @
fefcd9b2
class
ApplicationController
<
ActionController
::
Base
protect_from_forgery
with: :exception
before_action
:authenticate_user!
helper_method
:clear_session_candidate
def
clear_session_candidate
...
...
app/controllers/applies_controller.rb
View file @
fefcd9b2
class
AppliesController
<
ApplicationController
before_action
:authenticate_user!
def
apply
session
[
:job_id
]
=
params
[
:job_id
]
if
params
[
:job_id
]
if
session
[
:candidate
].
present?
...
...
app/controllers/cities_controller.rb
View file @
fefcd9b2
class
CitiesController
<
ApplicationController
skip_before_action
:authenticate_user!
def
index
@cities
=
City
.
city_list
end
...
...
app/controllers/industries_controller.rb
View file @
fefcd9b2
class
IndustriesController
<
ApplicationController
skip_before_action
:authenticate_user!
def
index
@industries
=
Industry
.
industry_list
end
...
...
app/controllers/jobs_controller.rb
View file @
fefcd9b2
class
JobsController
<
ApplicationController
before_action
:set_job
,
only:
[
:show
]
skip_before_action
:authenticate_user!
,
only:
[
:index
,
:city
,
:industry
,
:company
,
:show
]
def
index
@jobs
=
Job
.
top_list
.
includes
(
:company
)
@cities
=
City
.
top_cities
.
includes
(
:country
)
...
...
app/controllers/my_pages_controller.rb
View file @
fefcd9b2
...
...
@@ -10,4 +10,13 @@ class MyPagesController < ApplicationController
def
history
@jobs
=
current_user
.
viewed_jobs
.
includes
(
:apply_jobs
).
includes
(
:company
).
limit
(
20
)
end
def
download_cv
if
File
.
exist?
(
current_user
.
cv
.
path
)
send_file
current_user
.
cv
.
path
else
flash
[
:notice
]
=
'File not exist!'
redirect_back
(
fallback_location:
root_path
)
end
end
end
app/helpers/application_helper.rb
View file @
fefcd9b2
module
ApplicationHelper
def
user_has_applied?
(
job
)
current_user
&&
current_user
.
applied?
(
job
)
?
true
:
false
end
end
app/models/job.rb
View file @
fefcd9b2
...
...
@@ -8,10 +8,8 @@ class Job < ApplicationRecord
has_many
:industries
,
through: :industries_jobs
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
has_many
:view_jobs
has_many
:users_has_viewed
,
through: :view_jobs
,
class_name:
'User'
,
source: :user
scope
:top_list
,
->
{
order
(
updated_date: :desc
).
limit
(
Settings
.
top
.
job_per_page
)
}
...
...
@@ -58,19 +56,18 @@ class Job < ApplicationRecord
puts
"Saving
#{
item
[
:name
]
}
......................................"
if
job
.
save
puts
"Job was successfully created"
puts
'Job was successfully created'
else
puts
"Error..."
puts
'Error...'
end
end
end
def
self
.
filter_link_exist
(
links
)
return
links
-
Job
.
where
(
original_link:
links
).
pluck
(
:original_link
)
links
-
Job
.
where
(
original_link:
links
).
pluck
(
:original_link
)
end
def
applied_at
(
user_id
)
self
.
apply_jobs
.
select
{
|
application
|
application
.
user_id
=
user_id
}.
first
.
created_at
apply_jobs
.
select
{
|
application
|
application
.
user_id
=
user_id
}.
first
.
created_at
end
end
app/models/user.rb
View file @
fefcd9b2
...
...
@@ -5,10 +5,8 @@ class User < ApplicationRecord
has_many
:applied_jobs
,
through: :apply_jobs
,
class_name:
'Job'
,
source: :job
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
has_many
:view_jobs
has_many
:viewed_jobs
,
through: :view_jobs
,
class_name:
'Job'
,
source: :job
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
...
...
@@ -23,15 +21,8 @@ class User < ApplicationRecord
validates
:name
,
presence:
true
,
length:
{
maximum:
200
},
unless: :skip_validation
validates_size_of
:cv
,
maximum:
5
.
megabytes
,
message:
'size should be less than 5MB'
private
def
password_required?
return
false
if
skip_validation
super
end
def
view
(
job
)
viewed_jobs
<<
job
unless
viewed
_jobs
.
include
?
(
job
)
viewed_jobs
<<
job
unless
viewed?
(
job
)
end
def
like
(
job
)
...
...
@@ -41,4 +32,19 @@ class User < ApplicationRecord
def
unlike
(
job
)
liked_jobs
.
delete
(
job
.
id
)
end
def
viewed?
(
job
)
viewed_jobs
.
include?
(
job
)
end
def
applied?
(
job
)
applied_jobs
.
include?
(
job
)
end
private
def
password_required?
return
false
if
skip_validation
super
end
end
app/models/view_job.rb
0 → 100644
View file @
fefcd9b2
class
ViewJob
<
ApplicationRecord
belongs_to
:user
belongs_to
:job
end
app/views/jobs/show.html.erb
View file @
fefcd9b2
...
...
@@ -18,6 +18,11 @@
</ol>
</ol>
<div
class=
"job"
>
<%
if
user_has_applied?
(
@job
)
%>
<div
class=
"alert alert-success"
role=
"alert"
>
You have applied this job.
</div>
<%
end
%>
<div
class=
"col-md-9"
>
<h1>
2.
<%=
@job
.
name
%>
</h1>
<p>
3.
<%=
link_to
@job
.
company
.
name
,
company_jobs_path
(
@job
.
company
)
%>
</p>
...
...
@@ -33,14 +38,18 @@
</p>
</div>
<div
class=
"col-md-3"
>
<%=
link_to
"Apply"
,
apply_applies_path
(
job_id:
@job
.
id
),
class:
"btn btn-primary btn-lg"
%>
<%=
link_to
"Apply"
,
apply_applies_path
(
job_id:
@job
.
id
),
class:
"btn btn-primary btn-lg
#{
user_has_applied?
(
@job
)
?
'disabled'
:
''
}
btn-block"
%>
</div>
<div
class=
"action"
>
<div
class=
"col-md-6"
>
<%=
link_to
"Apply"
,
apply_applies_path
(
job_id:
@job
.
id
),
class:
"btn btn-default btn-lg"
%>
<%=
link_to
"Apply"
,
apply_applies_path
(
job_id:
@job
.
id
),
class:
"btn btn-primary btn-lg
#{
user_has_applied?
(
@job
)
?
'disabled'
:
''
}
btn-block"
%>
</div>
<div
class=
"col-md-6"
>
<%=
link_to
"Favorite"
,
"#"
,
class:
"btn btn-
default btn-lg
"
%>
<%=
link_to
"Favorite"
,
"#"
,
class:
"btn btn-
primary btn-lg btn-block
"
%>
</div>
</div>
...
...
app/views/layouts/_menu.html.erb
View file @
fefcd9b2
...
...
@@ -14,14 +14,22 @@
<i
class=
"fa fa-user"
aria-hidden=
"true"
></i>
My Page
<%
end
%>
</li>
<li><a
href=
"#"
><i
class=
"fa fa-plus"
aria-hidden=
"true"
></i>
Logout
</a></li>
<li>
<%=
link_to
destroy_user_session_path
,
method: :delete
do
%>
<i
class=
"fa fa-sign-out"
aria-hidden=
"true"
></i>
Logout
<%
end
%>
</li>
<%-
else
-%>
<li>
<%=
link_to
new_user_session_path
do
%>
<i
class=
"fa fa-sign-in"
aria-hidden=
"true"
></i>
Login
<%
end
%>
</li>
<li><a
href=
"#"
><i
class=
"fa fa-plus"
aria-hidden=
"true"
></i>
Register
</a></li>
<li>
<%=
link_to
register_path
(
step:
1
)
do
%>
<i
class=
"fa fa-plus-circle"
aria-hidden=
"true"
></i>
Register
<%
end
%>
</li>
<%-
end
-%>
<li><a
href=
"#"
><i
class=
"fa fa-star"
aria-hidden=
"true"
></i></span>
Favorite
</a></li>
<li>
...
...
app/views/my_pages/history.html.erb
View file @
fefcd9b2
...
...
@@ -4,26 +4,35 @@
<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>
<%=
form_tag
apply_applies_path
,
method: :get
do
%>
<tbody>
<%-
@jobs
.
each
do
|
job
|
-%>
<tr>
<td
class=
"col-md-1 position-relative"
>
<%=
radio_button_tag
"job_id"
,
job
.
id
,
false
,
class:
"mid-heigth"
,
disabled:
user_has_applied?
(
job
)
?
true
:
false
%>
</td>
<td
class=
"col-md-9"
>
<h4
class=
"mr0"
>
<%=
link_to
job
.
name
+
"
#{
user_has_applied?
(
job
)
?
' (APPLIED)'
:
''
}
"
,
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
%>
<tr>
<td></td>
<td>
<%=
submit_tag
"Applys"
,
class:
"btn btn-primary btn-lg btn-block"
,
id:
"apply"
,
disabled:
true
%>
</td>
<td></td>
</tr>
</tbody>
<%
end
%>
</table>
</div>
<%=
button_to
"Apply"
,
nil
,
class:
"btn btn-primary btn-lg"
%>
</div>
</div>
</div>
app/views/my_pages/index.html.erb
View file @
fefcd9b2
<div
class=
"row"
>
<div
class=
"container"
>
<h2>
MY PAGE
</h2>
<div
class=
"input-group"
>
<span
class=
"input-group-addon"
id=
"basic-addon1"
>
Mail
</span>
<input
type=
"text"
value=
"
<%=
@user
.
email
%>
"
class=
"form-control"
placeholder=
"Email"
aria-describedby=
"basic-addon1"
disabled
>
</div>
<br>
<div
class=
"input-group"
>
<span
class=
"input-group-addon"
id=
"basic-addon1"
>
Name
</span>
<input
type=
"text"
value=
"
<%=
@user
.
name
%>
"
class=
"form-control"
placeholder=
"Name"
aria-describedby=
"basic-addon1"
disabled
>
</div>
<br>
<span>
My Cv
</span>
<span>
<%=
link_to
@user
.
cv
,
"#"
%>
</span>
<br>
<div
class=
"col-md-6"
>
<%=
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"
%>
<div
class=
"col-sm-6 col-md-offset-3 toppad"
>
<div
class=
"panel panel-info"
>
<div
class=
"panel-heading"
>
<h3
class=
"panel-title"
>
My Page
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
" col-md-12"
>
<table
class=
"table table-user-information"
>
<tbody>
<tr>
<td>
Name:
</td>
<td>
<%=
@user
.
name
%>
</td>
</tr>
<tr>
<td>
email:
</td>
<td>
<%=
@user
.
email
%>
</td>
</tr>
<tr>
<td>
CV:
</td>
<td>
<%=
link_to
@user
.
cv
.
file
.
filename
,
download_my_pages_path
%>
</td>
</tr>
</tbody>
</table>
<div
class=
"col-md-6"
>
<%=
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"
%>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
config/environments/development.rb
View file @
fefcd9b2
...
...
@@ -48,16 +48,16 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
#
config.action_mailer.delivery_method = :smtp
#
config.action_mailer.smtp_settings = { address: 'localhost',
#
port: 1025 }
config
.
action_mailer
.
smtp_settings
=
{
address:
"smtp.gmail.com"
,
port:
587
,
domain:
"example.com"
,
authentication:
"plain"
,
enable_starttls_auto:
true
,
user_name:
ENV
[
"GMAIL_USER"
],
password:
ENV
[
"GMAIL_PASSWORD"
]
}
config
.
action_mailer
.
delivery_method
=
:smtp
config
.
action_mailer
.
smtp_settings
=
{
address:
'localhost'
,
port:
1025
}
#
config.action_mailer.smtp_settings = {
#
address: "smtp.gmail.com",
#
port: 587,
#
domain: "example.com",
#
authentication: "plain",
#
enable_starttls_auto: true,
#
user_name: ENV["GMAIL_USER"],
#
password: ENV["GMAIL_PASSWORD"]
#
}
end
config/routes.rb
View file @
fefcd9b2
Rails
.
application
.
routes
.
draw
do
require
'sidekiq/web'
root
'jobs#index'
devise_for
:users
,
:controllers
=>
{
:registrations
=>
"registrations"
}
devise_for
:users
,
:controllers
=>
{
registrations:
'registrations'
}
as
:user
do
get
'register/:step'
,
to:
'registrations#new'
,
as: :register
patch
'complete_registering'
=>
'registrations#complete_registering_user'
...
...
@@ -21,6 +21,14 @@ Rails.application.routes.draw do
get
'my'
=>
'my_pages#index'
get
'my/jobs'
=>
'my_pages#my_job'
,
as: :jobs
get
'history'
=>
'my_pages#history'
,
as: :history
get
'download'
=>
'my_pages#download_cv'
end
end
resources
:applies
do
collection
do
get
:apply
post
:confirm
post
:done
end
end
end
db/migrate/20171026030532_create_view_jobs.rb
0 → 100644
View file @
fefcd9b2
class
CreateViewJobs
<
ActiveRecord
::
Migration
[
5.1
]
def
change
create_table
:view_jobs
do
|
t
|
t
.
references
:user
,
index:
true
t
.
references
:job
,
index:
true
t
.
timestamps
end
end
end
db/schema.rb
View file @
fefcd9b2
...
...
@@ -10,12 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
<<<<<<<
Updated
upstream
ActiveRecord
::
Schema
.
define
(
version:
20171024093324
)
do
=======
ActiveRecord
::
Schema
.
define
(
version:
20171018012604
)
do
>>>>>>>
Stashed
changes
ActiveRecord
::
Schema
.
define
(
version:
20171026030532
)
do
create_table
"apply_jobs"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
t
.
bigint
"job_id"
...
...
@@ -131,4 +126,13 @@ ActiveRecord::Schema.define(version: 20171018012604) do
t
.
index
[
"reset_password_token"
],
name:
"index_users_on_reset_password_token"
,
unique:
true
end
create_table
"view_jobs"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
t
.
bigint
"user_id"
t
.
bigint
"job_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"job_id"
],
name:
"index_view_jobs_on_job_id"
t
.
index
[
"user_id"
],
name:
"index_view_jobs_on_user_id"
end
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