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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
f25be8dc
Commit
f25be8dc
authored
Sep 09, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1] admin search applied job
parent
cd4fd2f1
Pipeline
#1088
canceled with stages
in 0 seconds
Changes
8
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
21 deletions
+37
-21
app/controllers/applied_jobs_controller.rb
+9
-0
app/controllers/users_controller.rb
+1
-15
app/models/applied_job.rb
+1
-0
app/models/job.rb
+2
-0
app/views/shared/_header.html.erb
+2
-0
app/views/users/applied_jobs.html.erb
+5
-4
config/routes.rb
+1
-2
lib/common/search_applied_job.rb
+16
-0
No files found.
app/controllers/applied_jobs_controller.rb
View file @
f25be8dc
...
@@ -35,6 +35,10 @@ class AppliedJobsController < ApplicationController
...
@@ -35,6 +35,10 @@ class AppliedJobsController < ApplicationController
def
search
def
search
return
unless
current_user
.
admin
return
unless
current_user
.
admin
get_data_search_bar
@date
,
@applied_jobs
=
SearchAppliedJob
.
search
(
params
)
render
'users/applied_jobs'
end
end
private
private
...
@@ -42,4 +46,9 @@ class AppliedJobsController < ApplicationController
...
@@ -42,4 +46,9 @@ class AppliedJobsController < ApplicationController
def
applied_job_params
def
applied_job_params
params
.
require
(
:applied_job
).
permit
(
:job_id
,
:full_name
,
:email
,
:curriculum_vitae
)
params
.
require
(
:applied_job
).
permit
(
:job_id
,
:full_name
,
:email
,
:curriculum_vitae
)
end
end
def
get_data_search_bar
@locations
=
Location
.
select
(
:id
,
:city
)
@industries
=
Industry
.
select
(
:id
,
:name
)
end
end
end
app/controllers/users_controller.rb
View file @
f25be8dc
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
before_action
:authenticate_user!
,
only:
%i[my_page applied_jobs]
before_action
:authenticate_user!
,
only:
:my_page
def
show
def
show
@user
=
User
.
find_by
(
id:
params
[
:id
])
@user
=
User
.
find_by
(
id:
params
[
:id
])
end
end
def
my_page
;
end
def
my_page
;
end
def
applied_jobs
return
unless
current_user
.
admin
get_data_search_bar
@applied_jobs
=
AppliedJob
.
includes
(
:job
).
order
(
created_at: :desc
).
page
(
params
[
:page
]).
decorate
end
private
def
get_data_search_bar
@locations
=
Location
.
select
(
:id
,
:city
)
@industries
=
Industry
.
select
(
:id
,
:name
)
end
end
end
app/models/applied_job.rb
View file @
f25be8dc
class
AppliedJob
<
ApplicationRecord
class
AppliedJob
<
ApplicationRecord
scope
:of_email
,
->
(
email
)
{
where
(
email:
email
)
if
email
.
present?
}
EMAIL_REGEXN
=
/\A[a-zA-Z][\w\.]+@[a-zA-Z]+\.[a-zA-Z]+\z/
EMAIL_REGEXN
=
/\A[a-zA-Z][\w\.]+@[a-zA-Z]+\.[a-zA-Z]+\z/
belongs_to
:user
belongs_to
:user
...
...
app/models/job.rb
View file @
f25be8dc
...
@@ -4,6 +4,8 @@ class Job < ApplicationRecord
...
@@ -4,6 +4,8 @@ class Job < ApplicationRecord
.
where
(
"applied_jobs.user_id =
#{
user_id
}
"
)
.
where
(
"applied_jobs.user_id =
#{
user_id
}
"
)
.
select
(
'jobs.*, applied_jobs.created_at as applied_at'
)
.
select
(
'jobs.*, applied_jobs.created_at as applied_at'
)
end
end
scope
:of_industry
,
->
(
industry_id
)
{
joins
(
:industries
).
where
(
"industries.id =
#{
industry_id
}
"
)
if
industry_id
.
present?
}
scope
:of_location
,
->
(
location_id
)
{
joins
(
:locations
).
where
(
"locations.id =
#{
location_id
}
"
)
if
location_id
.
present?
}
NUMBER_LATEST_JOB
=
6
NUMBER_LATEST_JOB
=
6
WORDS_SHORT_DESCRIPTION
=
250
WORDS_SHORT_DESCRIPTION
=
250
...
...
app/views/shared/_header.html.erb
View file @
f25be8dc
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<div
class=
'collapse navbar-collapse'
id=
'navbarSupportedContent'
>
<div
class=
'collapse navbar-collapse'
id=
'navbarSupportedContent'
>
<ul
class=
'navbar-nav ml-auto'
>
<ul
class=
'navbar-nav ml-auto'
>
<%
if
user_signed_in?
%>
<%
if
user_signed_in?
%>
<%
unless
current_user
.
admin
%>
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<%=
link_to
favorites_path
,
class:
'nav-link text-white'
,
title:
'Favorite'
do
%>
<%=
link_to
favorites_path
,
class:
'nav-link text-white'
,
title:
'Favorite'
do
%>
<small
id=
"sum-favorited"
>
<%=
current_user
.
favorites
.
size
%>
</small>
<small
id=
"sum-favorited"
>
<%=
current_user
.
favorites
.
size
%>
</small>
...
@@ -23,6 +24,7 @@
...
@@ -23,6 +24,7 @@
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<%=
link_to
'My Page'
,
my_page_path
,
class:
'nav-link text-white'
%>
<%=
link_to
'My Page'
,
my_page_path
,
class:
'nav-link text-white'
%>
</li>
</li>
<%
end
%>
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<%=
link_to
'Log out'
,
destroy_user_session_path
,
method: :delete
,
class:
'nav-link text-white'
%>
<%=
link_to
'Log out'
,
destroy_user_session_path
,
method: :delete
,
class:
'nav-link text-white'
%>
</li>
</li>
...
...
app/views/users/applied_jobs.html.erb
View file @
f25be8dc
<h4
class=
"text-center py-3"
>
Applied Jobs
</h4>
<h4
class=
"text-center pt-4"
>
Applied Jobs
</h4>
<hr
class=
"divider"
>
<div
class=
'search-form text-center'
>
<div
class=
'search-form text-center'
>
<%=
form_tag
search_applied_jobs_path
,
class:
"mt-4 form-group"
,
enforce_utf8:
false
do
%>
<%=
form_tag
search_applied_jobs_path
,
method: :get
,
class:
"mt-4 form-group"
,
enforce_utf8:
false
do
%>
<%=
search_field_tag
:email
,
params
[
:email
],
placeholder:
'Email'
,
class:
'form-control my-2'
%>
<%=
search_field_tag
:email
,
params
[
:email
],
placeholder:
'Email'
,
class:
'form-control my-2'
%>
<%=
select_tag
:industry
,
options_from_collection_for_select
(
@industries
,
:id
,
:name
,
params
[
:industry
]),
prompt:
'All Industries'
,
class:
'form-control my-2'
%>
<%=
select_tag
:industry
,
options_from_collection_for_select
(
@industries
,
:id
,
:name
,
params
[
:industry
]),
prompt:
'All Industries'
,
class:
'form-control my-2'
%>
<%=
select_tag
:location
,
options_from_collection_for_select
(
@locations
,
:id
,
:city
,
params
[
:location
]),
prompt:
'All Locations'
,
class:
'form-control my-2'
%>
<%=
select_tag
:location
,
options_from_collection_for_select
(
@locations
,
:id
,
:city
,
params
[
:location
]),
prompt:
'All Locations'
,
class:
'form-control my-2'
%>
<div
class=
"d-flex justify-content-around my-2"
>
<div
class=
"d-flex justify-content-around my-2"
>
<%=
date_select
:applied_at
,
:from
,
<%=
date_select
:applied_at
,
:from
,
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
},
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
,
selected:
@date
[
:from
]
},
{
class:
'form-control mx-1'
}
%>
{
class:
'form-control mx-1'
}
%>
<strong
class=
"mx-3"
>
~
</strong>
<strong
class=
"mx-3"
>
~
</strong>
<%=
date_select
:applied_at
,
:to
,
<%=
date_select
:applied_at
,
:to
,
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
},
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
,
selected:
@date
[
:to
]
},
{
class:
'form-control mx-1'
}
%>
{
class:
'form-control mx-1'
}
%>
</div>
</div>
<%=
submit_tag
'Search'
,
name:
nil
,
class:
'btn btn-outline-success m-2'
%>
<%=
submit_tag
'Search'
,
name:
nil
,
class:
'btn btn-outline-success m-2'
%>
...
...
config/routes.rb
View file @
f25be8dc
...
@@ -5,8 +5,7 @@ Rails.application.routes.draw do
...
@@ -5,8 +5,7 @@ Rails.application.routes.draw do
get
'admin/login'
,
to:
'users/sessions#new'
,
as: :admin_login
get
'admin/login'
,
to:
'users/sessions#new'
,
as: :admin_login
end
end
get
'admin/applies'
,
to:
'users#applied_jobs'
,
as: :admin_applied_jobs
get
'admin/applies'
,
to:
'applied_jobs#search'
,
as: :search_applied_jobs
post
'admin/applies'
,
to:
'applied_jobs#search'
,
as: :search_applied_jobs
get
'cities'
,
to:
'locations#index'
get
'cities'
,
to:
'locations#index'
get
'industries'
,
to:
'industries#index'
get
'industries'
,
to:
'industries#index'
...
...
lib/common/search_applied_job.rb
0 → 100644
View file @
f25be8dc
module
SearchAppliedJob
def
self
.
search
(
params
)
date
=
{}
if
params
[
:email
].
nil?
applied_jobs
=
AppliedJob
.
includes
(
:job
).
order
(
created_at: :desc
).
page
(
params
[
:page
]).
per
(
2
).
decorate
date
[
:from
]
=
Date
.
today
date
[
:to
]
=
Date
.
today
else
date
[
:from
]
=
Date
.
new
(
params
[
:applied_at
][
"from(1i)"
].
to_i
,
params
[
:applied_at
][
"from(2i)"
].
to_i
,
params
[
:applied_at
][
"from(3i)"
].
to_i
)
date
[
:to
]
=
Date
.
new
(
params
[
:applied_at
][
"to(1i)"
].
to_i
,
params
[
:applied_at
][
"to(2i)"
].
to_i
,
params
[
:applied_at
][
"to(3i)"
].
to_i
)
job_ids
=
Job
.
of_industry
(
params
[
:industry
]).
of_location
(
params
[
:location
]).
pluck
(
:id
)
applied_jobs
=
AppliedJob
.
of_email
(
params
[
:email
]).
where
(
created_at:
date
[
:from
]
..
date
[
:to
],
job_id:
job_ids
).
page
(
params
[
:page
]).
per
(
2
)
end
[
date
,
applied_jobs
]
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