Commit a1a78ac9 by Van Hau Le

Merge branch 'feature/admin_page' into 'master'

Feature/admin page

See merge request !22
parents 2f65fef8 71dc2fcf
......@@ -27,7 +27,6 @@ gem 'config'
gem 'draper'
gem 'rsolr'
gem 'rsolr-ext'
gem 'pry'
gem 'nokogiri'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
......
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.1)
actionpack (= 6.0.1)
actioncable (6.0.2.1)
actionpack (= 6.0.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.1)
actionpack (= 6.0.1)
activejob (= 6.0.1)
activerecord (= 6.0.1)
activestorage (= 6.0.1)
activesupport (= 6.0.1)
actionmailbox (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
mail (>= 2.7.1)
actionmailer (6.0.1)
actionpack (= 6.0.1)
actionview (= 6.0.1)
activejob (= 6.0.1)
actionmailer (6.0.2.1)
actionpack (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.1)
actionview (= 6.0.1)
activesupport (= 6.0.1)
rack (~> 2.0)
actionpack (6.0.2.1)
actionview (= 6.0.2.1)
activesupport (= 6.0.2.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.1)
actionpack (= 6.0.1)
activerecord (= 6.0.1)
activestorage (= 6.0.1)
activesupport (= 6.0.1)
actiontext (6.0.2.1)
actionpack (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
nokogiri (>= 1.8.5)
actionview (6.0.1)
activesupport (= 6.0.1)
actionview (6.0.2.1)
activesupport (= 6.0.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.1)
activesupport (= 6.0.1)
activejob (6.0.2.1)
activesupport (= 6.0.2.1)
globalid (>= 0.3.6)
activemodel (6.0.1)
activesupport (= 6.0.1)
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.0.1)
activemodel (= 6.0.1)
activesupport (= 6.0.1)
activerecord-import (1.0.3)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activerecord-import (1.0.4)
activerecord (>= 3.2)
activestorage (6.0.1)
actionpack (= 6.0.1)
activejob (= 6.0.1)
activerecord (= 6.0.1)
activestorage (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
marcel (~> 0.3.1)
activesupport (6.0.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
......@@ -64,16 +64,16 @@ GEM
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (3.0.3)
annotate (3.1.0)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 14.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
bootsnap (1.4.6)
msgpack (~> 1.0)
builder (3.2.3)
byebug (11.0.1)
capybara (3.29.0)
builder (3.2.4)
byebug (11.1.1)
capybara (3.31.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
......@@ -81,7 +81,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
carrierwave (2.0.2)
carrierwave (2.1.0)
activemodel (>= 5.0.0)
activesupport (>= 5.0.0)
addressable (~> 2.6)
......@@ -90,12 +90,11 @@ GEM
mini_mime (>= 0.1.3)
childprocess (3.0.0)
coderay (1.1.2)
concurrent-ruby (1.1.5)
config (2.0.0)
activesupport (>= 4.2)
concurrent-ruby (1.1.6)
config (2.2.1)
deep_merge (~> 1.2, >= 1.2.1)
dry-schema (~> 1.0)
crass (1.0.5)
dry-validation (~> 1.0, >= 1.0.0)
crass (1.0.6)
deep_merge (1.2.1)
devise (4.7.1)
bcrypt (~> 3.0)
......@@ -103,15 +102,16 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
draper (3.1.0)
draper (4.0.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
activemodel-serializers-xml (>= 1.0)
activesupport (>= 5.0)
request_store (>= 1.0)
dry-configurable (0.9.0)
dry-configurable (0.11.3)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-equalizer (~> 0.2)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
......@@ -119,12 +119,12 @@ GEM
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.0)
dry-initializer (3.0.2)
dry-logic (1.0.5)
dry-initializer (3.0.3)
dry-logic (1.0.6)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-schema (1.4.1)
dry-schema (1.4.3)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-core (~> 0.4)
......@@ -132,42 +132,49 @@ GEM
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.2)
dry-types (1.2.1)
dry-types (1.3.1)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.2, >= 0.2.2)
dry-equalizer (~> 0.3)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.4.2)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-schema (~> 1.4, >= 1.4.3)
erubi (1.9.0)
faraday (0.17.1)
faraday (1.0.0)
multipart-post (>= 1.2, < 3)
ffi (1.11.3)
ffi (1.12.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.7.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
image_processing (1.9.3)
image_processing (1.10.3)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.13, < 3)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
ruby-vips (>= 2.0.17, < 3)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
kaminari (1.1.1)
kaminari (1.2.0)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
kaminari-actionview (= 1.2.0)
kaminari-activerecord (= 1.2.0)
kaminari-core (= 1.2.0)
kaminari-actionview (1.2.0)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
kaminari-core (= 1.2.0)
kaminari-activerecord (1.2.0)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kaminari-core (= 1.2.0)
kaminari-core (1.2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
......@@ -180,73 +187,73 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_magick (4.9.5)
mimemagic (0.3.4)
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
msgpack (1.3.1)
minitest (5.14.0)
msgpack (1.3.3)
multipart-post (2.1.1)
mysql2 (0.5.3)
nio4r (2.5.2)
nokogiri (1.10.5)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.1)
puma (3.12.1)
rack (2.0.7)
public_suffix (4.0.3)
puma (3.12.4)
rack (2.2.2)
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.1)
actioncable (= 6.0.1)
actionmailbox (= 6.0.1)
actionmailer (= 6.0.1)
actionpack (= 6.0.1)
actiontext (= 6.0.1)
actionview (= 6.0.1)
activejob (= 6.0.1)
activemodel (= 6.0.1)
activerecord (= 6.0.1)
activestorage (= 6.0.1)
activesupport (= 6.0.1)
rails (6.0.2.1)
actioncable (= 6.0.2.1)
actionmailbox (= 6.0.2.1)
actionmailer (= 6.0.2.1)
actionpack (= 6.0.2.1)
actiontext (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
activemodel (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
bundler (>= 1.3.0)
railties (= 6.0.1)
railties (= 6.0.2.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.1)
actionpack (= 6.0.1)
activesupport (= 6.0.1)
railties (6.0.2.1)
actionpack (= 6.0.2.1)
activesupport (= 6.0.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.6.0)
request_store (1.4.1)
regexp_parser (1.7.0)
request_store (1.5.0)
rack (>= 1.4)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rsolr (2.2.1)
rsolr (2.3.0)
builder (>= 2.1.2)
faraday (>= 0.9.0)
rsolr-ext (1.0.3)
rsolr (>= 1.0.2)
ruby-vips (2.0.16)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby_dep (1.5.0)
rubyzip (2.0.0)
rubyzip (2.2.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
......@@ -258,7 +265,7 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.142.6)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
spring (2.1.0)
......@@ -272,13 +279,13 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.3)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.5)
tzinfo (1.2.6)
thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
......@@ -287,11 +294,11 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.1.3)
webdrivers (4.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webpacker (4.2.0)
webpacker (4.2.2)
activesupport (>= 4.2)
rack-proxy (>= 0.6.1)
railties (>= 4.2)
......@@ -300,7 +307,7 @@ GEM
websocket-extensions (0.1.4)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.2.1)
zeitwerk (2.3.0)
PLATFORMS
ruby
......
class AdminsController < ApplicationController
before_action :authenticate_user!, only: :index
def index
redirect_to root_path unless current_user.role?
params[:search_user]
@applied_jobs = get_applied_jobs
@user = User.find_by(email: params[:search_user])
end
private
def get_applied_jobs
if params[:search_user]
user = User.find_by(email: params[:search_user])
return redirect_to admin_path, notice: "User/job not found!" if user.blank?
applied_jobs = user.jobs
applied_jobs.page(params[:page]).per(Settings.job.per_page)
else
applied_jobs = Job.joins(:user_jobs).where.not(user_jobs: { applied_at: nil}).distinct
applied_jobs.page(params[:page]).per(Settings.job.per_page)
end
end
end
......@@ -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)
job.user_jobs.find_by(user_id: current_user.id).applied_at
end
end
......@@ -35,4 +35,8 @@ class User < ApplicationRecord
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
def self.list_emails
@emails ||= all.pluck(:email)
end
end
<div class="box">
<div class="job_data">
<dl class="job_data_row">
<dt>Title</dt>
<dd><%= link_to applied_job.title, job_path(applied_job.id) %></dd>
</dl>
<dl class="job_data_row">
<dt>Salary</dt>
<dd><%= applied_job.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_job) %></dd>
</dl>
<% end %>
</div>
</div>
<h4>Search user's applied jobs:</h4>
<%= form_tag(admin_path, method: :get) do |f| %>
<%= select_tag :search_user, options_for_select(User.list_emails, params[:search_user]), include_blank: "Choose user's email" %>
<%= submit_tag "Search" %>
<% end %>
<%= render partial: "applied_job", collection: @applied_jobs %>
......@@ -20,4 +20,5 @@ Rails.application.routes.draw do
end
end
end
get "admin", to: "admins#index", as: :admin
end
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment