Commit 2324f19a by Nguyen Ngoc Nghia

Merge branch 'feature/applied_jobs' into 'master'

Feature/applied jobs

See merge request !19
parents b3f131ec 9f44af60
class JobsController < ApplicationController class JobsController < ApplicationController
before_action :authenticate_user!, only: [:apply, :confirm_apply, :finish_apply, :applied_jobs]
before_action :find_user, only: :apply_available
def index def index
if params[:city_id] if params[:city_id]
@city = City.find(params[:city_id]) @city = City.find(params[:city_id])
...@@ -39,9 +42,17 @@ class JobsController < ApplicationController ...@@ -39,9 +42,17 @@ class JobsController < ApplicationController
end end
end end
def apply_available
user_jobs.find_by(job_id: @job_id, user_id: @user.id)
end
private private
def confirm_apply_info_params def confirm_apply_info_params
params.require(:confirm_apply_info).permit(:job_id, :first_name, :last_name, :email) params.require(:confirm_apply_info).permit(:job_id, :first_name, :last_name, :email)
end end
def find_user
@user = User.find_by(:id)
end
end end
class Users::MyPagesController < ApplicationController class Users::MyPagesController < ApplicationController
before_action :authenticate_user!, only: [:show]
def show def show
end end
def applied_jobs
@applied_jobs = current_user.jobs.includes(:cities).decorate
end
end end
...@@ -43,9 +43,4 @@ class Job < ApplicationRecord ...@@ -43,9 +43,4 @@ class Job < ApplicationRecord
def self.latest_job def self.latest_job
@latest_job ||= order(updated_at: :desc).take(Settings.top.job.limit) @latest_job ||= order(updated_at: :desc).take(Settings.top.job.limit)
end end
def apply_available
user = User.find_by(:id)
user_jobs.find_by(job_id: @job_id, user_id: user.id)
end
end end
<h1>Applied jobs</h1>
<%= render partial: "jobs/job", collection: @applied_jobs %>
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
<h3>My CV: <%= current_user.cv_path %></h3> <h3>My CV: <%= current_user.cv_path %></h3>
<%= link_to "Edit", edit_user_registration_path, class: "btn btn-lg btn-primary" %> <%= link_to "Edit", edit_user_registration_path, class: "btn btn-lg btn-primary" %>
<%= link_to "My jobs", "#", class: "btn btn-lg btn-primary" %> <%= link_to "My jobs", applied_jobs_users_my_page_path, class: "btn btn-lg btn-primary" %>
</div> </div>
<h1>Applied jobs</h1>
<%= render partial: "jobs/job", collection: @applied_jobs %>
...@@ -2,15 +2,22 @@ Rails.application.routes.draw do ...@@ -2,15 +2,22 @@ Rails.application.routes.draw do
resources :companies, only: :index resources :companies, only: :index
resources :industries, only: :index resources :industries, only: :index
resources :cities, only: :index resources :cities, only: :index
resources :jobs, only: [:index, :show] resources :jobs, only: [:index, :show] do
get "jobs/city/:city_id", to: "jobs#index", as: :city_jobs collection do
get "jobs/industry/:industry_id", to: "jobs#index", as: :industry_jobs get "city/:city_id", action: :index, as: :city
get "industry/:industry_id", action: :index, as: :industry
end
end
get "apply", to: "jobs#apply" get "apply", to: "jobs#apply"
get "confirm", to: "jobs#confirm_apply" get "confirm", to: "jobs#confirm_apply"
post "done", to: 'jobs#finish_apply' post "done", to: 'jobs#finish_apply'
devise_for :users devise_for :users
root "tops#index" root "tops#index"
namespace :users do namespace :users do
resource :my_page, only: :show resource :my_page, only: :show do
collection do
get "jobs", action: :applied_jobs, as: :applied_jobs
end
end
end end
end end
...@@ -8,5 +8,6 @@ ...@@ -8,5 +8,6 @@
"@rails/webpacker": "^4.2.0", "@rails/webpacker": "^4.2.0",
"turbolinks": "^5.2.0" "turbolinks": "^5.2.0"
}, },
"version": "0.1.0" "version": "0.1.0",
"license": "UNLICENSED"
} }
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