Commit 7e991bbd by Ngô Trung Hưng

create function admin

parent ef3031b4
Pipeline #1070 failed with stages
in 0 seconds
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the admin controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.new_admin {
width: 100%;
}
@mixin admin_select {
margin-top: 10px;
border: 1px solid #ced4da;
border-radius: 0.25rem;
height: 40px;
padding-top: 0.375rem;
padding-right: 0.75rem;
padding-bottom: 0.375rem;
padding-left: 0.6rem;
}
@mixin admin_select__child {
border: none;
width: 100%;
height: 100%;
background-color: transparent;
font-weight: 400;
font-size: 1rem;
color: #495057;
cursor: pointer;
&:focus {
outline: none;
}
}
.admin_box_search__filter_city_id {
@include admin_select()
}
.admin_box_search__filter_industry_id {
@include admin_select()
}
.admin_box_search__filter_date {
@include admin_select();
border: none !important;
padding-left: 0 !important;
padding-right: 0 !important;
margin-top: 0px;
select {
@include admin_select();
margin-top: 0px;
&:focus {
outline: none;
}
}
}
.admin_box_search__filter_date__past_time {
width: 100%;
text-align: center;
}
.admin_box_search__filter_date__current_time {
width: 100%;
text-align: center;
}
.admin_box_search__btn {
margin-top: 10px;
}
.admin_box_search__download {
width: 100%;
text-align: right;
margin-top: 10px;
}
.symbol_to {
font-size: 26px;
font-weight: 600;
}
.btn-admin-search {
width: 100%;
}
#apply_city_id {
@include admin_select__child()
}
#apply_industry_id {
@include admin_select__child()
}
\ No newline at end of file
class AdminController < ApplicationController
before_action :authenticate_admin!, only: :index
before_action :load_data_dropdown
def routing
return redirect_to new_admin_session_path if !admin_signed_in?
redirect_to applies_path
end
def index
debugger
# data_time = Apply.parse_datetime(params[:apply])
puts 'ahihi'
@apply = Apply.new
end
def load_data_dropdown
@industries = Industry.order(name: :asc)
@cities = City.select(:id, :name)
end
end
......@@ -16,6 +16,11 @@ class ApplicationController < ActionController::Base
{ locale: I18n.locale }
end
def after_sign_in_path_for(resource)
return applies_path if resource.model_name == Admin.name
stored_location_for(resource) || root_path
end
protected
def configure_permitted_parameters
......
......@@ -10,7 +10,4 @@ class RegistrationsController < Devise::RegistrationsController
my_page_path
end
def after_sign_in_path_for(resource)
stored_location_for(resource) || root_path
end
end
class AdminDecorator < Draper::Decorator
delegate_all
# Define presentation-specific methods here. Helpers are accessed through
# `helpers` (aka `h`). You can override attributes, for example:
#
# def created_at
# helpers.content_tag :span, class: 'time' do
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
class Apply
include ActiveModel::Model
attr_accessor :email, :city_id, :industry_id, :past_time, :current_time
def self.parse_datetime(params)
times = {}
past_time = ''
current_time = ''
3.times do |i|
past_time << params["past_time(#{i+1}i)"] << '-'
current_time << params["current_time(#{i+1}i)"] << '-'
end
times[:past_time] = past_time.chop
times[:current_time] = current_time.chop
times
end
end
module AdminHelper
end
......@@ -25,4 +25,8 @@ module ApplicationHelper
obj.errors.full_messages.each { |mess| errors << "#{mess}<br>" }
flash[:error] = errors.join('<br>').html_safe
end
def is_url_admin?
request.url.include?('admin/login')
end
end
class Admin < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
end
<%= render 'layouts/padding' %>
<div class="box_search_candidate">
<div class="box_text_five_jobs">
<span><%= t('pages.index.admin_applied') %></span>
</div>
<div class="container">
<%= form_for @apply, enforce_utf8: false, method: :get do |f| %>
<div class="admin_box_search">
<div class="admin_box_search__filter_string">
<div class="row">
<div class="col-lg-12">
<%= f.text_field :email, placeholder: 'Email', class: 'form-control' %>
</div>
</div>
</div>
<div class="admin_box_search__filter_id">
<div class="row">
<div class="col-lg-6">
<div class="admin_box_search__filter_city_id">
<%= f.select :city_id, options_from_collection_for_select(@cities, 'id', 'name'), prompt: t('pages.banner.all_locations') %>
</div>
</div>
<div class="col-lg-6">
<div class="admin_box_search__filter_industry_id">
<%= f.select :industry_id, options_from_collection_for_select(@industries, 'id', 'name'), prompt: t('pages.banner.all_industries') %>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="admin_box_search__filter_date">
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="admin_box_search__filter_date__past_time">
<%= f.date_select :past_time, order: [:year, :month, :day], start_year: Time.now.year - 10, end_year: Time.now.year%>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="admin_box_search__filter_date__current_time">
<%= f.date_select :current_time, order: [:year, :month, :day], start_year: Time.now.year - 10, end_year: Time.now.year%>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="admin_box_search__btn">
<%= f.submit t('admin.search'), class: 'btn btn-success btn-admin-search'%>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="admin_box_search__btn">
<%= link_to t('admin.dl'), '#', class: 'btn btn-primary btn-admin-search' %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<%= render 'box_filter' %>
<%= render 'shared/scroll_top' %>
<div class="" style="width: 100%; height: 300vh;"></div>
\ No newline at end of file
<% provide(:title, 'Sign in') %>
<% provide(:title, is_url_admin? ? 'Admin' : 'Sign in') %>
<div class="container">
<div class="box_form">
<div class="row">
<div class="col-lg-12">
<h2 style="text-align: center"><%= t('devise.title_signin') %></h2><hr>
<h2 style="text-align: center"><%= is_url_admin? ? 'Admin' : t('devise.title_signin') %></h2><hr>
</div>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="row">
......@@ -43,9 +43,11 @@
</div>
<div class="col-lg-6">
<%= f.submit t('devise.title_signin'), class: 'btn btn-info btn-info-custom' %>
<% if !is_url_admin? %>
<div style="text-align: center; margin-top: 10px">
<%= link_to t('devise.ask_forget_password'), new_password_path(resource_name), class: 'link_ct' %>
<%= link_to t('devise.ask_forget_password'), new_password_path(resource_name), class: 'link_ct'%>
</div>
<% end %>
</div>
</div><br>
<% end %>
......
......@@ -7,8 +7,17 @@
<label for="mobile-nav" class="lbn-nav">&#9776</label>
<label for="mobile-nav" class="overlay"></label>
<div class = "override"></div>
<div class="header_top_menu_right">
<ul class="list_menu_header_right">
<% if admin_signed_in? %>
<li class="list_item_menu_header_right">
<%= link_to t('pages.index.signout'), destroy_user_session_path, method: :delete, class: 'link_item_menu_header_right'%>
</li>
<li class="list_item_menu_header_right">
<span class="link_item_menu_header_right"><i class="far fa-question-circle"></i></span>
</li>
<% else %>
<li class="list_item_menu_header_right">
<%= link_to_if(!user_signed_in?, t('pages.index.favorite'), favorite_index_path, class: 'link_item_menu_header_right') do
link_to "(#{current_user.favorites.count}) #{t('pages.index.favorite')}", favorite_index_path, class: 'link_item_menu_header_right number_favorite'
......@@ -46,6 +55,7 @@
</ul>
</div>
</li>
<% end %>
</ul>
</div>
<%# mobile %>
......@@ -54,6 +64,10 @@
<%= link_to image_tag('avatar.png', alt: 'avatar', class: 'avatar_manu'), '#' %>
<div class = "menu_mobile_vertical">
<ul class = "list_menu_mobile_vertical">
<% if admin_signed_in? %>
<li class="item_menu_mobile_vertical">
<%= link_to t('pages.index.signout'), destroy_user_session_path, method: :delete, class: 'link_item_menu_mobile'%>
<% else %>
<li class = "item_menu_mobile_vertical">
<%= link_to_if(!user_signed_in?, t('pages.index.favorite'), favorite_index_path, class: 'link_item_menu_mobile') do
link_to "(#{current_user.favorites.count}) #{t('pages.index.favorite')}", favorite_index_path, class: 'link_item_menu_mobile number_favorite'
......@@ -84,6 +98,7 @@
link_to t('pages.index.vi'), {locale: 'vi'}, {class: 'link_item_menu_mobile'}
end %>
</li>
<% end %>
</ul>
</div>
<div>
......
......@@ -14,19 +14,19 @@ default: &default
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: '1'
password: 'Trunghung5055@'
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: venjob_development
database: hungnt_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: venjob_test
database: hungnt_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
......
......@@ -22,7 +22,7 @@ Rails.application.configure do
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = false
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
......
......@@ -29,6 +29,7 @@ en:
en: 'English'
setting: 'Settings'
applied_at: 'Applied_at'
admin_applied: 'Applied Jobs'
banner:
slogan: 'VENJOB HUMAN RESOURCE PLATFORM'
slogan_2: 'Instantly discover the best jobs on VenJob'
......@@ -147,3 +148,6 @@ en:
user_id: ''
favorite:
user_id: ''
admin:
search: 'Search'
dl: 'Download CSV'
......@@ -29,6 +29,7 @@ vi:
en: 'Tiếng Anh'
setting: 'Cài đặt'
applied_at: 'Ứng tuyển lúc: '
admin_applied: 'Danh sách thí sinh ứng tuyển'
banner:
slogan: 'NỀN TẢNG TUYỂN DỤNG NHÂN SỰ VENJOB'
slogan_2: 'Khám phá ngay những việc làm tốt nhất trên VenJob'
......@@ -147,4 +148,7 @@ vi:
user_id: ''
favorite:
user_id: ''
admin:
search: 'Tìm kiếm'
dl: 'Tải về CSV'
\ No newline at end of file
......@@ -4,8 +4,13 @@ Rails.application.routes.draw do
get 'setting', to: 'users#set_lang', as: :set_lang
scope '(:locale)', locale: /en|vi/ do
devise_for :users, controllers: { registrations: 'registrations' }
devise_for :admins, path: 'admin', path_names: { sign_in: 'login', sign_out: 'logout'}
root 'home#index'
get 'admin/applies', to: 'admin#index', as: :applies
get 'admin', to: 'admin#routing', as: :admin
get 'register/:code', to: 'users#confirm_sign_up', as: :confirm_sign_up
get 'industries', to: 'industry#index', as: :industry_index
get 'cities', to: 'city#index', as: :city_index
......
# frozen_string_literal: true
class DeviseCreateAdmins < ActiveRecord::Migration[5.2]
def change
create_table :admins do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at
t.timestamps null: false
end
add_index :admins, :email, unique: true
add_index :admins, :reset_password_token, unique: true
# add_index :admins, :confirmation_token, unique: true
# add_index :admins, :unlock_token, unique: true
end
end
......@@ -10,7 +10,27 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_08_17_004611) do
ActiveRecord::Schema.define(version: 2020_09_07_010650) do
create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admins_on_email", unique: true
t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true
end
create_table "applied_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.bigint "user_id"
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
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