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
89c5bd8e
Commit
89c5bd8e
authored
Sep 09, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
creating export csv
parent
4e5ed11c
Pipeline
#1081
failed with stages
in 0 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
26 deletions
+98
-26
app/assets/stylesheets/form_login.scss
+7
-1
app/controllers/admins_controller.rb
+24
-3
app/controllers/users_controller.rb
+5
-0
app/models/admin.rb
+6
-13
app/models/job_applied.rb
+11
-0
app/views/admins/_datetime.html.erb
+34
-0
app/views/admins/_search_condition.html.erb
+10
-9
config/routes.rb
+1
-0
No files found.
app/assets/stylesheets/form_login.scss
View file @
89c5bd8e
...
@@ -24,4 +24,10 @@
...
@@ -24,4 +24,10 @@
font-style
:
italic
;
font-style
:
italic
;
font-size
:
16px
;
font-size
:
16px
;
}
}
.tilde
{
color
:
black
;
}
.datetime
{
margin
:
20px
;
padding
:
10px
;
}
app/controllers/admins_controller.rb
View file @
89c5bd8e
class
AdminsController
<
ApplicationController
class
AdminsController
<
ApplicationController
before_action
:sign_out_current_user
before_action
:sign_in_validation_admin
,
only:
[
:index
,
:destroy
]
def
index
def
index
@cities
=
City
.
all
@cities
=
City
.
all
@industries
=
Industry
.
all
@industries
=
Industry
.
all
@count_apply_job
=
JobApplied
.
count
@count_apply_job
=
JobApplied
.
count
@user_apply_job
=
JobApplied
.
all
.
order
(
updated_at: :desc
).
page
(
params
[
:page
]).
per
(
Job
::
LIMIT_PAGE
)
@user_apply_job
=
JobApplied
.
all
.
order
(
updated_at: :desc
).
page
(
params
[
:page
]).
per
(
Job
::
LIMIT_PAGE
)
@months
=
[[
'None'
,
''
]]
(
1
..
12
).
each
{
|
m
|
@months
<<
[
Date
::
MONTHNAMES
[
m
],
m
]}
@days
=
[
'None'
]
binding
.
pry
(
Admin
::
FIRST_DAY
..
Admin
::
LAST_DAY
).
each
{
|
d
|
@days
<<
d
}
@months
=
[
'None'
]
(
Admin
::
FIRST_MONTH
..
Admin
::
LAST_MONTH
).
each
{
|
m
|
@months
<<
m
}
@years
=
[
'None'
]
(
Admin
::
FIRST_YEAR
..
Admin
::
LAST_YEAR
).
each
{
|
y
|
@years
<<
y
}
end
end
def
new
def
new
...
@@ -30,9 +37,23 @@ class AdminsController < ApplicationController
...
@@ -30,9 +37,23 @@ class AdminsController < ApplicationController
redirect_to
root_path
redirect_to
root_path
end
end
def
download_csv
@user_apply_job
=
JobApplied
.
all
.
order
(
updated_at: :desc
)
respond_to
do
|
format
|
format
.
csv
{
send_data
@user_apply_job
.
to_csv
,
filename:
"test-
#{
Date
.
today
}
.csv"
}
end
end
private
private
def
sign_out_current_user
def
sign_out_current_user
sign_out
if
signed_in?
&&
current_user
.
admin
.
nil?
sign_out
if
signed_in?
&&
current_user
.
admin
.
nil?
end
end
def
sign_in_validation_admin
return
if
signed_in?
&&
current_user
.
admin?
store_location
flash
[
:warning
]
=
Settings
.
user
.
warning_signin
redirect_to
admin_login_path
end
end
end
app/controllers/users_controller.rb
View file @
89c5bd8e
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
before_action
:sign_out_admin
before_action
:sign_in_validation
,
only:
[
:update
,
:my_page
,
:my_info
]
before_action
:sign_in_validation
,
only:
[
:update
,
:my_page
,
:my_info
]
def
my_page
def
my_page
...
@@ -38,6 +39,10 @@ class UsersController < ApplicationController
...
@@ -38,6 +39,10 @@ class UsersController < ApplicationController
private
private
def
sign_out_admin
sign_out
if
signed_in?
&&
current_user
.
admin?
end
def
sign_in_validation
def
sign_in_validation
return
if
signed_in?
return
if
signed_in?
store_location
store_location
...
...
app/models/admin.rb
View file @
89c5bd8e
class
Admin
<
ApplicationRecord
class
Admin
<
ApplicationRecord
before_create
:create_remember_token
FIRST_DAY
=
1
LAST_DAY
=
31
def
self
.
new_remember_token
FIRST_MONTH
=
1
SecureRandom
.
urlsafe_base64
LAST_MONTH
=
12
end
def
self
.
digest
(
token
)
FIRST_YEAR
=
2015
Digest
::
SHA1
.
hexdigest
(
token
.
to_s
)
LAST_YEAR
=
2020
end
private
def
create_remember_token
self
.
remember_token
=
User
.
digest
(
User
.
new_remember_token
)
end
end
end
app/models/job_applied.rb
View file @
89c5bd8e
require
'csv'
class
JobApplied
<
ApplicationRecord
class
JobApplied
<
ApplicationRecord
before_save
{
self
.
email
=
email
.
downcase
}
before_save
{
self
.
email
=
email
.
downcase
}
mount_uploader
:cv_user
,
UserCvUploader
mount_uploader
:cv_user
,
UserCvUploader
...
@@ -12,4 +13,14 @@ class JobApplied < ApplicationRecord
...
@@ -12,4 +13,14 @@ class JobApplied < ApplicationRecord
validates
:email
,
presence:
true
,
length:
{
maximum:
200
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates
:email
,
presence:
true
,
length:
{
maximum:
200
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates
:cv_user
,
presence:
true
validates
:cv_user
,
presence:
true
def
self
.
to_csv
attributes
=
%w{title name cv_user email updated_at}
CSV
.
generate
(
headers:
true
)
do
|
csv
|
csv
<<
attributes
all
.
each
do
|
info_application
|
csv
<<
info_application
.
job
.
attributes
.
values_at
(
attributes
[
0
])
csv
<<
attributes
[(
1
..
4
)].
map
{
|
attr
|
info_application
.
send
(
attr
)
}
end
end
end
end
end
app/views/admins/_datetime.html.erb
0 → 100644
View file @
89c5bd8e
<div
class=
"row justify-content-lg-center"
>
<div
class=
"text col-1"
>
Date:
</div>
<select
class=
"form-control col-1"
>
<%=
@years
.
each
do
|
year
|
%>
<option>
<%=
year
%>
</option>
<%
end
%>
</select>
<select
class=
"form-control col-1"
>
<%=
@months
.
each
do
|
month
|
%>
<option>
<%=
month
%>
</option>
<%
end
%>
</select>
<select
class=
"form-control col-1"
>
<%=
@days
.
each
do
|
day
|
%>
<option>
<%=
day
%>
</option>
<%
end
%>
</select>
<h2
class=
"col-1 tilde"
>
~
</h2>
<select
class=
"form-control col-1"
>
<%=
@years
.
each
do
|
year
|
%>
<option>
<%=
year
%>
</option>
<%
end
%>
</select>
<select
class=
"form-control col-1"
>
<%=
@months
.
each
do
|
month
|
%>
<option>
<%=
month
%>
</option>
<%
end
%>
</select>
<select
class=
"form-control col-1"
>
<%=
@days
.
each
do
|
day
|
%>
<option>
<%=
day
%>
</option>
<%
end
%>
</select>
</div>
app/views/admins/_search_condition.html.erb
View file @
89c5bd8e
...
@@ -20,15 +20,16 @@
...
@@ -20,15 +20,16 @@
<%
end
%>
<%
end
%>
</select>
</select>
</div>
</div>
<div
class=
"row"
>
<div
class=
"datetime"
>
<div
class=
"text col-2"
>
Date
</div>
<%=
render
"datetime"
%>
<select
class=
"form-control"
id=
"exampleFormControlSelect1"
>
<%=
@months
.
each
do
|
month
|
%>
<option>
<%=
month
%>
</option>
<%
end
%>
</select>
</div>
</div>
<div
class=
"search-btn"
>
<div
class=
"row"
>
<button
class=
"btn btn-primary"
type=
"submit"
>
Search
</button>
<div
class=
"col-3"
></div>
<div
class=
"search-btn col-4"
>
<button
class=
"btn btn-primary"
type=
"submit"
>
Search
</button>
</div>
<div
class=
"download-csv-btn col-4"
>
<%=
link_to
(
'Download CSV'
,
download_csv_path
(
format: :csv
),
class:
'btn btn-info'
)
%>
</div>
</div>
</div>
</div>
</div>
config/routes.rb
View file @
89c5bd8e
...
@@ -37,6 +37,7 @@ Rails.application.routes.draw do
...
@@ -37,6 +37,7 @@ Rails.application.routes.draw do
get
'admin/login'
,
to:
'admins#new'
,
as: :admin_login
get
'admin/login'
,
to:
'admins#new'
,
as: :admin_login
delete
'admin/logout'
,
to:
'admins#destroy'
,
as: :admin_logout
delete
'admin/logout'
,
to:
'admins#destroy'
,
as: :admin_logout
get
'admin/applies'
,
to:
'admins#index'
,
as: :admin_page
get
'admin/applies'
,
to:
'admins#index'
,
as: :admin_page
get
'download-csv'
,
to:
'admins#download_csv'
,
as: :download_csv
resources
:applied_jobs
,
only:
[
:new
,
:create
]
resources
:applied_jobs
,
only:
[
:new
,
:create
]
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
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