append conditions in apply_job

parent d02b7680
Pipeline #1020 failed with stages
in 0 seconds
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
.industry:last-child::after, .location:last-child::after { .industry:last-child::after, .location:last-child::after {
content: ""; content: "";
} }
.my-job-label { .my-job-label, .let-apply{
padding: 30px; padding: 30px;
margin: 30px; margin: 30px;
} }
class JobAppliedsController < ApplicationController class JobAppliedsController < ApplicationController
before_action :sign_in_validation, only: [:new, :confirmation, :create] before_action :sign_in_validation, only: [:new, :confirmation, :create, :show]
before_action :find_job_id, only: [:new] before_action :find_job_id, only: [:new]
def new def new
end end
def show def show
arr_job_id = current_user.job_applieds.pluck(:job_id) @jobs = Job.applied_job(current_user.id).page(params[:page]).per(Job::LIMIT_PAGE)
@jobs = Job.where(id: arr_job_id).order(updated_at: :asc)
end end
def confirmation def confirmation
@founded_job = JobApplied.where(user_id: current_user.id, job_id: apply_params[:job_id])
return redirect_to apply_job_path(job_id: apply_params[:job_id]), flash: {danger: Settings.user.applied_job.applied} if @founded_job.present?
@user = current_user.job_applieds.new(apply_params) @user = current_user.job_applieds.new(apply_params)
@user.cv_user = current_user.cv_user if apply_params[:cv_user].blank? @user.cv_user = current_user.cv_user if apply_params[:cv_user].blank?
if @user.invalid? if @user.invalid?
......
class ConfirmationMailer < ActionMailer::Base class ConfirmationMailer < ActionMailer::Base
def register_email(user) def register_email(user)
@user = user @user = user
mail(to: user.email, subject: 'Welcome To VeNJOB! Confirm Your Email') mail(to: user.email, subject: Settings.email.confirmation)
end end
end end
...@@ -2,6 +2,6 @@ class JobAppliedMailer < ActionMailer::Base ...@@ -2,6 +2,6 @@ class JobAppliedMailer < ActionMailer::Base
def apply_job(user, job) def apply_job(user, job)
@job = job @job = job
@user = user @user = user
mail(to: user.email, subject: 'Thank your for apply with VeNJOB') mail(to: user.email, subject: Settings.email.job_applied)
end end
end end
class ResetPasswordMailer < ActionMailer::Base class ResetPasswordMailer < ActionMailer::Base
def reset_password(user) def reset_password(user)
@user = user @user = user
mail(to: user.email, subject: 'VeNJOB Password Assistance') mail(to: user.email, subject: Settings.email.reset_password)
end end
end end
...@@ -19,6 +19,9 @@ class Job < ApplicationRecord ...@@ -19,6 +19,9 @@ class Job < ApplicationRecord
LIMIT_PAGE = 20 LIMIT_PAGE = 20
scope :applied_job, ->(user_id) { joins(:job_applieds)
.where("job_applieds.user_id = #{user_id}")
.order("job_applieds.updated_at DESC") }
scope :limit_job, -> { includes(:cities, :company).order(created_at: :desc).limit(5) } scope :limit_job, -> { includes(:cities, :company).order(created_at: :desc).limit(5) }
def company_name def company_name
......
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
<%= link_to 'Read more..', job_detail_path(job.id) %> <%= link_to 'Read more..', job_detail_path(job.id) %>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-6">
<%= job.cities.map(&:name).join(' | ') %> <%= job.cities.map(&:name).join(' | ') %>
</div> </div>
<div class="salary col-4"> <div class="salary col-3">
Salary: <%= job.salary %> Salary: <%= job.salary %>
</div> </div>
<div class="applied-at col-4"> <div class="applied-at col-3">
<strong>Applied at:</strong> <strong>Applied at:</strong>
<% job.job_applieds.each do |info| %> <% job.job_applieds.where(user_id: current_user.id).each do |info| %>
<%= info.updated_at.strftime('%d/%m/%Y') %> <%= info.updated_at.strftime('%d/%m/%Y') %>
<% end %> <% end %>
</div> </div>
......
<div class="container"> <div class="container">
<% if @jobs.count > 0 %>
<h1 class="text-center my-job-label">My Job</h1> <h1 class="text-center my-job-label">My Job</h1>
<%= paginate @jobs, outer_window: 2, window: 1 %>
<%= render partial: "job_applieds/my_jobs", collection: @jobs, as: :job %> <%= render partial: "job_applieds/my_jobs", collection: @jobs, as: :job %>
<%= paginate @jobs, outer_window: 2, window: 1 %>
<% else %>
<h1 class="let-apply">Let's apply job</h1>
<% end %>
</div> </div>
...@@ -18,3 +18,10 @@ user: ...@@ -18,3 +18,10 @@ user:
existed: 'Email existed. Please change !!!' existed: 'Email existed. Please change !!!'
format_failed: 'Email formated invalid' format_failed: 'Email formated invalid'
applied_job:
applied: 'You applied for this job'
email:
confirmation: 'Welcome To VeNJOB! Confirm Your Email'
reset_password: 'VeNJOB Password Assistance'
job_applied: 'Thank your for apply with VeNJOB'
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