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 Ngoc Nghia
VeNJOB
Commits
4c7dfb8c
Commit
4c7dfb8c
authored
Mar 03, 2020
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
choose user's email
parent
4d284329
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
11 deletions
+30
-11
app/controllers/users/admins_controller.rb
+10
-6
app/helpers/job_helper.rb
+4
-0
app/views/layouts/_notice.html.erb
+5
-0
app/views/users/admins/_applied_jobs.html.erb
+10
-4
app/views/users/admins/index.html.erb
+1
-1
No files found.
app/controllers/users/admins_controller.rb
View file @
4c7dfb8c
...
...
@@ -4,7 +4,9 @@ class Users::AdminsController < ApplicationController
def
index
redirect_to
root_path
unless
current_user
.
role?
params
[
:search_user
]
||=
""
get_applied_jobs
(
params
[
:search_user
])
@applied_jobs
=
get_applied_jobs
(
params
[
:search_user
])
@user
=
User
.
find_by
(
email:
params
[
:search_user
])
@users
=
User
.
all
end
private
...
...
@@ -14,18 +16,20 @@ class Users::AdminsController < ApplicationController
end
def
get_applied_jobs
(
email
)
@
applied_jobs
=
[]
applied_jobs
=
[]
if
email
!=
""
user
s
=
User
.
find_by
(
email:
email
)
re
direct_to
users_admin_path
if
users
.
nil
?
user
=
User
.
find_by
(
email:
email
)
re
turn
redirect_to
users_admin_path
,
notice:
"User/job not found!"
if
user
.
blank
?
@applied_jobs
=
users
.
jobs
applied_jobs
=
user
.
jobs
elsif
email
=
""
||
nil
all_applied_jobs
=
UserJob
.
where
.
not
(
applied_at:
nil
).
to_a
(
0
..
all_applied_jobs
.
count
-
1
).
each
do
|
each_job
|
@
applied_jobs
<<
(
all_applied_jobs
[
each_job
].
job
)
applied_jobs
<<
(
all_applied_jobs
[
each_job
].
job
)
end
applied_jobs
end
end
end
app/helpers/job_helper.rb
View file @
4c7dfb8c
...
...
@@ -3,4 +3,8 @@ module JobHelper
params
[
:city_id
]
?
"City:
#{
@jobs
[
0
][
"city"
]
}
"
:
(
params
[
:industry_id
]
?
"Industry:
#{
@jobs
[
0
][
"industry"
]
}
"
:
params
[
:search
])
end
def
job_applied_at
(
job_id
)
UserJob
.
where
.
not
(
applied_at:
nil
).
find_by
(
job_id:
job_id
).
applied_at
end
end
app/views/layouts/_notice.html.erb
0 → 100644
View file @
4c7dfb8c
<%
flash
.
each
do
|
type
,
msg
|
%>
<div>
<%=
msg
%>
</div>
<%
end
%>
app/views/users/admins/_applied_jobs.html.erb
View file @
4c7dfb8c
...
...
@@ -5,12 +5,18 @@
<dd>
<%=
link_to
applied_jobs
.
title
,
job_path
(
applied_jobs
.
id
)
%>
</dd>
</dl>
<dl
class=
"job_data_row"
>
<dt>
Short description
</dt>
<dd>
<%=
applied_jobs
.
description
&
.
truncate
(
250
)
%>
</dd>
</dl>
<dl
class=
"job_data_row"
>
<dt>
Salary
</dt>
<dd>
<%=
applied_jobs
.
salary
%>
</dd>
</dl>
<%
if
@user
.
present?
%>
<dl
class=
"job_data_row"
>
<dt>
User's email:
</dt>
<dd>
<%=
@user
.
email
%>
</dd>
</dl>
<dl
class=
"job_data_row"
>
<dt>
Applied at:
</dt>
<dd>
<%=
job_applied_at
(
applied_jobs
.
id
)
%>
</dd>
</dl>
<%
end
%>
</div>
</div>
app/views/users/admins/index.html.erb
View file @
4c7dfb8c
<h4>
Search user's applied jobs:
</h4>
<%=
form_tag
(
users_admin_path
,
method: :get
)
do
|
f
|
%>
<%=
text_field_tag
:search_user
,
params
[
:search_user
],
placeholder:
"Enter
user's email"
%>
<%=
select_tag
:search_user
,
options_from_collection_for_select
(
@users
,
"email"
,
"email"
,
params
[
:search_user
]),
include_blank:
"Choose
user's email"
%>
<%=
submit_tag
"Search"
%>
<%
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