Commit ccc6289d by Trịnh Hoàng Phúc

Merge branch 'feature/design_template_ven_job' into 'master'

Feature/design template ven job

See merge request !7
parents 0933eacd 9f0f5e41
Pipeline #571 canceled with stages
in 0 seconds
...@@ -24,6 +24,8 @@ gem 'jbuilder', '~> 2.7' ...@@ -24,6 +24,8 @@ gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7' gem 'bcrypt', '~> 3.1.7'
gem 'devise' gem 'devise'
gem 'settingslogic'
# Use Active Storage variant # Use Active Storage variant
# gem 'image_processing', '~> 1.2' # gem 'image_processing', '~> 1.2'
......
...@@ -212,6 +212,7 @@ GEM ...@@ -212,6 +212,7 @@ GEM
selenium-webdriver (3.142.7) selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0) childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2) rubyzip (>= 1.2.2)
settingslogic (2.0.9)
spoon (0.0.6) spoon (0.0.6)
ffi ffi
spring (2.1.0) spring (2.1.0)
...@@ -282,6 +283,7 @@ DEPENDENCIES ...@@ -282,6 +283,7 @@ DEPENDENCIES
rails (~> 6.0.2, >= 6.0.2.2) rails (~> 6.0.2, >= 6.0.2.2)
sass-rails (>= 6) sass-rails (>= 6)
selenium-webdriver selenium-webdriver
settingslogic
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5) turbolinks (~> 5)
......
// Place all the styles related to the jobs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class CityController < ApplicationController class CitiesController < ApplicationController
def index def index
@cities = City.all @cities = City.all
end end
......
class HomeController < ApplicationController class HomeController < ApplicationController
def index def index
@amount_job = Job.count @amount_job = Job.count
@latest_10_jobs = Job.last(10) @latest_jobs = Job.last(Settings.home.limit)
@latest_8_cities = City.last(8) @latest_cities = City.last(Settings.home.limit - 2)
@latest_8_industries = Industry.last(8) @latest_industries = Industry.last(Settings.home.limit - 2)
end end
end end
class IndustryController < ApplicationController class IndustriesController < ApplicationController
def index def index
@industries = Industry.all @industries = Industry.all
end end
......
class JobController < ApplicationController
def index
if params[:city]
@jobs = Job.includes(:cities).where("cities.id = #{params[:city]}").references(:cities).page(params[:page])
@amount_job = Job.includes(:cities).where("cities.id = #{params[:city]}").references(:cities).count
elsif params[:industry]
@jobs = Job.includes(:industries).where("industries.id = #{params[:industry]}").references(:industries).page(params[:page])
@amount_job = Job.includes(:industries).where("industries.id = #{params[:industry]}").references(:industries).count
elsif params[:company]
@jobs = Job.where("company_id = #{params[:company]}").page(params[:page])
@amount_job = Job.where("company_id = #{params[:company]}").count
else
@jobs = Job.order("id DESC").page(params[:page])
@amount_job = Job.count
end
end
def show
@job = Job.find(params[:id])
@relate_jobs = Job.where("company_id = #{@job.company_id} and id != #{@job.id}").limit(3).order("id DESC")
end
end
class JobsController < ApplicationController
def index
if params[:city_id]
@jobs = Job.by_cities(params[:city_id]).page(params[:page])
@amount_job = Job.by_cities(params[:city_id]).count
elsif params[:industry_id]
@jobs = Job.by_industries(params[:industry_id]).page(params[:page])
@amount_job = Job.by_industries(params[:industry_id]).count
elsif params[:company_id]
@jobs = Job.by_companies(params[:company_id]).page(params[:page])
@amount_job = Job.by_companies(params[:company_id]).count
else
@jobs = Job.order("id DESC").page(params[:page])
@amount_job = Job.count
end
end
def show
@job = Job.find_by(id: params[:id])
if @job.present?
@title = @job.title
@relate_jobs = Job.where("company_id = ? and id != ?", @job.company_id, @job.id).order("id DESC")
else
@title = "Job was not found"
end
end
end
...@@ -9,4 +9,8 @@ class Job < ApplicationRecord ...@@ -9,4 +9,8 @@ class Job < ApplicationRecord
has_and_belongs_to_many :industries has_and_belongs_to_many :industries
has_and_belongs_to_many :cities has_and_belongs_to_many :cities
scope :by_cities, -> (city_id) {includes(:cities).where("cities.id = ?", city_id).references(:cities)}
scope :by_industries, -> (industry_id) {includes(:industries).where("industries.id = ?", industry_id).references(:industries)}
scope :by_companies, -> (company_id) {where("company_id = #{company_id}")}
end end
class Settings < Settingslogic
source "#{Rails.root}/config/settings.yml"
namespace Rails.env
end
\ No newline at end of file
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
<ul class="companies-overview"> <ul class="companies-overview">
<% @cities.each do |city| %> <% @cities.each do |city| %>
<li class="company-group"> <li class="company-group">
<a href="/jobs?city=<%= city.id %>"><%= city.title %> (<%= city.jobs.length %>)</a> <%= link_to jobs_with_city_path(city_id: city.id) do %>
<%= city.title %> (<%= city.jobs.count %>)
<% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
......
...@@ -46,29 +46,29 @@ ...@@ -46,29 +46,29 @@
<h3 class="widget-title widget-title--home">Total Jobs: <%= @amount_job %></h3> <h3 class="widget-title widget-title--home">Total Jobs: <%= @amount_job %></h3>
<div class="job_listings"> <div class="job_listings">
<ul class="job_listings"> <ul class="job_listings">
<% @latest_10_jobs.each do |job| %> <% @latest_jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time"> <li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo"> <div class="job_listing-logo">
<a href="/job/<%= job.id %>"> <%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>" /> <img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>" />
</a> <% end %>
</div> </div>
<div class="job_listing-about"> <div class="job_listing-about">
<div class="job_listing-position job_listing__column"> <div class="job_listing-position job_listing__column">
<h3 class="job_listing-title"> <h3 class="job_listing-title">
<a href="/job/<%= job.id %>"> <%= link_to job.title, job %>
<%= job.title %>
</a>
</h3> </h3>
<div class="job_listing-company"> <div class="job_listing-company">
<strong><a href="/jobs?company=<%= job.company_id %>"><%= job.company.title%></a></strong> <strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div> </div>
</div> </div>
<div class="job_listing-location job_listing__column"> <div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %> <% job.cities.each_with_index do |city, index| %>
<a class="google_map_link" href="/jobs?city=<%= city.id %>"> <%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.length - 1 %> <%= city.title %><%= ", " if index != job.cities.size - 1 %>
</a> <% end %>
<% end %> <% end %>
</div> </div>
<ul class="job_listing-meta job_listing__column"> <ul class="job_listing-meta job_listing__column">
...@@ -79,7 +79,9 @@ ...@@ -79,7 +79,9 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<a class="load_more_jobs" href="/jobs"><strong>Load more listings</strong></a> <%= link_to jobs_path, class: "load_more_jobs" do %>
<strong>Load more listings</strong>
<% end %>
</div> </div>
</div> </div>
</div> </div>
...@@ -109,14 +111,16 @@ ...@@ -109,14 +111,16 @@
Here we list our cities and how many people we’ve helped find a job and companies have found recruits. It's a pretty awesome stats area! Here we list our cities and how many people we’ve helped find a job and companies have found recruits. It's a pretty awesome stats area!
</p> </p>
<ul class="job-stats row showing-4"> <ul class="job-stats row showing-4">
<% @latest_8_cities.each do |city| %> <% @latest_cities.each do |city| %>
<li class="job-stat col-md-3 col-sm-6 col-xs-12"> <li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= city.jobs.length %></strong> <strong><%= city.jobs.count %></strong>
<a href="/jobs?city=<%= city.id %>"><%= city.title %></a> <%= link_to city.title, jobs_with_city_path(city_id: city.id) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<a class="load_more_jobs" href="/cities"><strong>Load more listings</strong></a> <%= link_to cities_path, class: "load_more_jobs" do %>
<strong>Load more listings</strong>
<% end %>
</div> </div>
</section> </section>
<section id="jobify_widget_feature_callout-3" class="widget widget--home widget--home--no-margin jobify_widget_feature_callout widget--home-feature-callout"> <section id="jobify_widget_feature_callout-3" class="widget widget--home widget--home--no-margin jobify_widget_feature_callout widget--home-feature-callout">
...@@ -140,14 +144,16 @@ ...@@ -140,14 +144,16 @@
<div class="container"> <div class="container">
<h3 class="widget-title widget-title--home">Top Industries</h3> <h3 class="widget-title widget-title--home">Top Industries</h3>
<ul class="job-stats row showing-4"> <ul class="job-stats row showing-4">
<% @latest_8_industries.each do |industry| %> <% @latest_industries.each do |industry| %>
<li class="job-stat col-md-3 col-sm-6 col-xs-12"> <li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= industry.jobs.length %></strong> <strong><%= industry.jobs.count %></strong>
<a href="/jobs?industry=<%= industry.id %>"><%= industry.title %></a> <%= link_to industry.title, jobs_with_industry_path(industry_id: industry.id) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<a class="load_more_jobs" href="/industries"><strong>Load more listings</strong></a> <%= link_to industries_path, class: "load_more_jobs" do %>
<strong>Load more listings</strong>
<% end %>
</div> </div>
</section> </section>
</div> </div>
\ No newline at end of file
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
<ul class="companies-overview"> <ul class="companies-overview">
<% @industries.each do |industry| %> <% @industries.each do |industry| %>
<li class="company-group"> <li class="company-group">
<a href="/jobs?industry=<%= industry.id %>"><%= industry.title %> (<%= industry.jobs.length %>)</a> <%= link_to jobs_with_industry_path(industry_id: industry.id) do %>
<%= industry.title %> (<%= industry.jobs.count %>)
<% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
......
...@@ -36,22 +36,26 @@ ...@@ -36,22 +36,26 @@
<% @jobs.each do |job| %> <% @jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time"> <li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo"> <div class="job_listing-logo">
<a href="/job/<%= job.id %>"> <%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>"> <img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>">
</a> <% end %>
</div> </div>
<div class="job_listing-about"> <div class="job_listing-about">
<div class="job_listing-position job_listing__column"> <div class="job_listing-position job_listing__column">
<h3 class="job_listing-title"> <h3 class="job_listing-title">
<a href="/job/<%= job.id %>"><%= job.title %></a> <%= link_to job.title, job %>
</h3> </h3>
<div class="job_listing-company"> <div class="job_listing-company">
<strong><a href="/jobs?company=<%= job.company_id %>"><%= job.company.title%></a></strong> <strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div> </div>
</div> </div>
<div class="job_listing-location job_listing__column"> <div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %> <% job.cities.each_with_index do |city, index| %>
<a class="google_map_link" href="/jobs?city=<%= city.id %>"><%= city.title %></a><%= ", " if index != job.cities.length - 1 %> <%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
<% end %> <% end %>
</div> </div>
<ul class="job_listing-meta job_listing__column"> <ul class="job_listing-meta job_listing__column">
...@@ -62,7 +66,6 @@ ...@@ -62,7 +66,6 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<a class="load_more_jobs" href="#" style="display:none;"><strong>Load more listings</strong></a>
<div class="job-manager-pagination"> <div class="job-manager-pagination">
<%= paginate @jobs %> <%= paginate @jobs %>
</div> </div>
......
<% content_for :title, @job.title %> <% content_for :title, @title %>
<div class="single_job_listing"> <div class="single_job_listing">
<% if @job.present? %>
<div class="page-header"> <div class="page-header">
<h1 class="page-title"> <h1 class="page-title">
<%= @job.title %> <%= @job.title %>
...@@ -9,12 +10,14 @@ ...@@ -9,12 +10,14 @@
<li class="job-type part-time"><%= "Salary: " + @job.salary %></li> <li class="job-type part-time"><%= "Salary: " + @job.salary %></li>
<li class="location"> <li class="location">
<% @job.cities.each_with_index do |city, index| %> <% @job.cities.each_with_index do |city, index| %>
<a class="google_map_link" href="/city/<%= city.id %>"><%= city.title %></a><%= "," if index != @job.cities.length - 1 %> <%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %></a><%= "," if index != @job.cities.count - 1 %>
<% end %>
<% end %> <% end %>
</li> </li>
<li class="date-posted"><%= @job.expiration_date %></li> <li class="date-posted"><%= @job.expiration_date %></li>
<li class="job-company"> <li class="job-company">
<a href="/jobs?company=<%= @job.company_id %>"><%= @job.company.title %></a> <%= link_to @job.company.title, jobs_with_city_path(city_id: @job.company_id) %>
</li> </li>
</ul> </ul>
</h3> </h3>
...@@ -26,7 +29,7 @@ ...@@ -26,7 +29,7 @@
</div> </div>
<div class="job-meta col-md-3 col-sm-6 col-xs-12"> <div class="job-meta col-md-3 col-sm-6 col-xs-12">
<aside class="widget widget--job_listing"> <aside class="widget widget--job_listing">
<img class="company_logo" src="<%= @job.company.logo != "" ? @job.company.logo : "" %>" alt="<%= @job.company.title %>" /> <img class="company_logo" src="<%= @job.company.logo != "" ? @job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= @job.company.title %>" />
</aside> </aside>
<aside class="widget widget--job_listing"> <aside class="widget widget--job_listing">
<div class="job_application application"> <div class="job_application application">
...@@ -48,7 +51,7 @@ ...@@ -48,7 +51,7 @@
<h3 class="widget-title widget-title--job_listing">Industry</h3> <h3 class="widget-title widget-title--job_listing">Industry</h3>
<div class="job_listing-categories"> <div class="job_listing-categories">
<% @job.industries.each_with_index do |industry, index| %> <% @job.industries.each_with_index do |industry, index| %>
<a href="industry/<%= industry.id %>" class="job-category"><%= industry.title %></a> <%= link_to industry.title, jobs_with_industry_path(industry_id: industry.id), class: "job-category" %>
<% end %> <% end %>
</div> </div>
</aside> </aside>
...@@ -61,22 +64,26 @@ ...@@ -61,22 +64,26 @@
<% @relate_jobs.each do |job| %> <% @relate_jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time"> <li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo"> <div class="job_listing-logo">
<a href="/job/<%= job.id %>"> <%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>"> <img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>" />
</a> <% end %>
</div> </div>
<div class="job_listing-about"> <div class="job_listing-about">
<div class="job_listing-position job_listing__column"> <div class="job_listing-position job_listing__column">
<h3 class="job_listing-title"> <h3 class="job_listing-title">
<a href="/job/<%= job.id %>"><%= job.title %></a> <%= link_to job.title, job %>
</h3> </h3>
<div class="job_listing-company"> <div class="job_listing-company">
<strong><%= job.company.title %></strong> <strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div> </div>
</div> </div>
<div class="job_listing-location job_listing__column"> <div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %> <% job.cities.each_with_index do |city, index| %>
<a class="google_map_link" href="/city/<%= city.id %>"><%= city.title %></a><%= ", " if index != job.cities.length - 1 %> <%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
<% end %> <% end %>
</div> </div>
<ul class="job_listing-meta job_listing__column"> <ul class="job_listing-meta job_listing__column">
...@@ -88,4 +95,21 @@ ...@@ -88,4 +95,21 @@
<% end %> <% end %>
</ul> </ul>
</div> </div>
<% else %>
<div class="page-header">
<h1 class="page-title">
Job was not found
</h1>
<h3 class="page-subtitle">
<ul class="job-listing-meta meta">
<li class="job-company">
<%= link_to "Back to home", root_path %>
</li>
<li class="location">
<%= link_to "Find a job", jobs_path %>
</li>
</ul>
</h3>
</div>
<% end %>
</div> </div>
\ No newline at end of file
...@@ -3,8 +3,11 @@ Rails.application.routes.draw do ...@@ -3,8 +3,11 @@ Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: 'home#index' root to: 'home#index'
get '/jobs/', to: 'job#index' resources :jobs, only: [:index, :show]
get '/job/:id', to: 'job#show'
get '/cities/', to: 'city#index' get '/jobs/city/:city_id', to: 'jobs#index', as: 'jobs_with_city'
get '/industries/', to: 'industry#index' get '/jobs/industry/:industry_id', to: 'jobs#index', as: 'jobs_with_industry'
get '/jobs/company/:company_id', to: 'jobs#index', as: 'jobs_with_company'
get '/cities/', to: 'cities#index', as: 'cities'
get '/industries/', to: 'industries#index', as: 'industries'
end end
defaults: &defaults
home:
limit: 10
development:
<<: *defaults
\ No newline at end of file
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