Commit fe7cebed by Xuan Trung Le

fix bugs: jobs can apply when out of date

parent 4f6a51d3
class AppliesController < ApplicationController class AppliesController < ApplicationController
before_action :admin_can_not_do_this before_action :admin_can_not_do_this
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_deadline
def apply def apply
session[:job_id] = params[:job_id] if params[:job_id] session[:job_id] = params[:job_id] if params[:job_id]
if session[:candidate].present? if session[:candidate].present?
...@@ -45,4 +46,12 @@ class AppliesController < ApplicationController ...@@ -45,4 +46,12 @@ class AppliesController < ApplicationController
def application_params def application_params
params.require(:apply_job).permit(:name, :email, :cv) params.require(:apply_job).permit(:name, :email, :cv)
end end
def check_deadline
job = Job.find(params[:job_id])
if Date.today > job.expiry_date
flash[:notice] = "Job was expiried date"
redirect_back(fallback_location: root_path)
end
end
end end
...@@ -24,16 +24,17 @@ ...@@ -24,16 +24,17 @@
</div> </div>
<% end %> <% end %>
<div class="col-md-9"> <div class="col-md-9">
<h1>2.<%= @job.name %></h1> <h1><%= @job.name %></h1>
<p>3.<%= link_to @job.company.name, company_jobs_path(@job.company) %></p> <p><%= link_to @job.company.name, company_jobs_path(@job.company) %></p>
<p>4. Location: <p>Location:
<%- @job.cities.each_with_index do |city, index| -%> <%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %> <%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, city_jobs_path(city) %> <%= link_to city.name, city_jobs_path(city) %>
<%- end -%> <%- end -%>
</p> </p>
<p>5. Salary: <%= @job.salary %></p> <p>Salary: <%= @job.salary %></p>
<p>6 Long Description: <p>Deadline to apply: <%= l @job.expiry_date, format: :default %></p>
<p>Long Description:
<%= @job.description.html_safe %> <%= @job.description.html_safe %>
</p> </p>
</div> </div>
......
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