Commit 57a0d779 by Ngô Trung Hưng

ID8_History

parent 13a1d576
Pipeline #990 canceled 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/
......@@ -24,7 +24,7 @@
}
.box_content_404 {
width: 100vw;
height: 100vh;
height: auto;
z-index: 2000;
// height: 900px;
position: fixed;
......
// Place all the styles related to the histories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
......@@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :cv, :password) }
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :cv, :password, :password_confirmation) }
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :cv, :password, :current_password) }
end
end
......@@ -6,6 +6,7 @@ class ApplyJobController < ApplicationController
def index
@jobs = current_user.applied_jobs.includes(:job).order(created_at: :desc).page(params[:page]).per(6)
return render 'error/page_not_found' if @jobs.blank?
end
def apply
......
# frozen_string_literal: true
class HistoriesController < ApplicationController
before_action :authenticate_user!
def index
histories = current_user.histories.order(created_at: :desc)
@jobs = histories.map(&:job)
end
end
......@@ -3,10 +3,11 @@
# Job controller
class JobController < ApplicationController
before_action :load_data_dropdown, only: :index
# after_action :add_job_to_history, only: :detail
after_action :add_job_to_history, only: :detail
def add_job_to_history
current_user.histories.create(session[:params_job_id]) if user_signed_in?
current_user.histories.find_or_create_by(job_id: session[:params_job_id]) if user_signed_in?
counter_history = current_user.histories.count
current_user.histories.destroy(current_user.histories.first) if counter_history > 20
session.delete(:params_job_id)
end
......@@ -17,8 +18,8 @@ class JobController < ApplicationController
end
def detail
session[:params_job_id] = params[:id]
@job = Job.find(params[:id]).decorate
session[:params_job_id] = @job.id
cities = @job.cities.first
industries = @job.industries.first
add_breadcrumb t('controller.job.detail.home'), root_path
......@@ -35,6 +36,8 @@ class JobController < ApplicationController
def render_result(obj)
@keyword = obj.name
@data = obj.jobs.page(params[:page])
return render 'error/page_not_found' if @data.blank?
render 'result_data'
end
end
module HistoriesHelper
end
<div class="con">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="box_jobs mini">
<div class="row">
<div class="d-none d-lg-block col-lg-1 d-md-block col-md-1 d-sm-block col-sm-1">
<div class="box_radio">
<%= form.radio_button(:job_id, data.id) %>
</div>
</div>
<div class="col-lg-10 col-md-10 col-sm-11">
<div class="box_info">
<div class="lol">
<%= link_to data.name, detail_job_path(id: data.id), class: 'job_name' %>
</div>
<div class="cop">
<h5 class="box_info_copany_name"><i class="far fa-building"></i> <%= data.company.name %></h5>
</div>
<div class="loc">
<h5 class="box_info_location"><i class="fas fa-map-marker-alt"></i>
<%= data.cities.map(&:name).join(' | ') %>
</h5>
</div>
<h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i>&nbsp;<%= "#{t('pages.index.salary')}: #{data.salary}" %></h5>
<div class="coc">
<div class="row">
<div class="col-lg-12">
<h5 class="box_info_des"><%= strip_tags(data.description) %></h5>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="box_my_page">
<div class="row">
<div class="col-lg-12">
<div class="box_my_page_header">
<h4><%= t('history.list') %></h4>
</div>
</div>
</div>
</div>
</div>
<div class="transform_margin"></div>
<% if @jobs.blank? %>
<div class="col-lg-12">
<div class="breadcrumb_total_search">
<span class="breadcrumb-item active">
<%= t('history.list_blank') %>
</span>
</div>
</div>
<div style="width: 100%; height: 55vh"></div>
<% else %>
<%= form_with url: apply_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
<div class="container">
<div class="box_scroll">
<% @jobs.each do |item| %>
<%= render 'histories/block_job_mini', data: item, form: f %>
<% end %>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="btn_apply_job in_favorite">
<%= f.submit t('pages.detail.btr_text_submit_cv'), name: nil, class: 'btn btn-apply_job in_favorite' %>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
......@@ -15,7 +15,7 @@
end %>
</li>
<li class="list_item_menu_header_right">
<%= link_to t('pages.index.history'), '#', class: 'link_item_menu_header_right' %>
<%= link_to t('pages.index.history'), list_histories_path, class: 'link_item_menu_header_right' %>
</li>
<li class="list_item_menu_header_right">
<%= link_to_if(user_signed_in?, t('pages.index.mypage'), my_page_path, class: 'link_item_menu_header_right') do
......@@ -60,7 +60,7 @@
end %>
</li>
<li class = "item_menu_mobile_vertical">
<%= link_to t('pages.index.history'), '#', class: 'link_item_menu_mobile' %>
<%= link_to t('pages.index.history'), list_histories_path, class: 'link_item_menu_mobile' %>
</li>
<li class="item_menu_mobile_vertical">
<%= link_to_if(user_signed_in?, t('pages.index.mypage'), my_page_path, class: 'link_item_menu_mobile') do
......
......@@ -22,7 +22,7 @@ Rails.application.configure do
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
config.consider_all_requests_local = false
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
......
......@@ -137,6 +137,10 @@ en:
liked: 'You have added job to favorites'
list: 'List of jobs you liked'
list_blank: 'You do not have a favorite job!'
history:
list: 'Histories'
list_blank: 'You do not have a histories'
see: 'See: '
activerecord:
attributes:
applied_job:
......
......@@ -137,6 +137,10 @@ vi:
liked: 'Bạn đã thêm công việc vào yêu thích.'
list: 'Danh sách công việc bạn đã thích'
list_blank: 'Bạn chưa công việc yêu thích!'
history:
list: 'Lịch sử'
list_blank: 'Bạn chưa xem công việc nào luôn á!'
see: 'Đã xem lúc: '
activerecord:
attributes:
applied_job:
......
......@@ -16,6 +16,8 @@ Rails.application.routes.draw do
get 'my/jobs', to: 'apply_job#index', as: :list_applied_jobs
# Fovorite
resources :favorite, only: %i[index create destroy]
# History
get 'history', to:'histories#index', as: :list_histories
# Details job
get 'detail/:id', to: 'job#detail', as: :detail_job
# Search
......
require 'test_helper'
class HistoriesControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class HistoryDecoratorTest < Draper::TestCase
end
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