fix mentor's comments

parent 1615a264
Pipeline #1043 canceled with stages
in 0 seconds
......@@ -31,4 +31,3 @@
/config/master.key
config/local_env.yml
public/uploads
class AppliedJobsController < ApplicationController
before_action :sign_in_validation, only: %i[new confirmation create show]
before_action :validate_apply_job, only: [:new, :confirmation]
before_action :validate_apply_job, only: %i[new confirmation create]
def new
apply_info = session[:apply_job] || {}
apply_info[:job_id] = params[:job_id]
apply_info['name'] ||= current_user.name
apply_info['email'] ||= current_user.email
apply_info[:name] ||= current_user.name
apply_info[:email] ||= current_user.email
session[:apply_job] = {:job_id => apply_info[:job_id]}
@job_applied = current_user.job_applieds.new(name: apply_info['name'],
email: apply_info['email'])
@job_applied = current_user.job_applieds.new(name: apply_info[:name],
email: apply_info[:email])
cache_cv = session[:cv] || {}
@job_applied.cv_user.retrieve_from_cache!(cache_cv['url'].gsub('/uploads/tmp/','')) if session[:cv].present?
@job_applied.cv_user.retrieve_from_cache!(session[:cv]) if session[:cv].present?
@job_applied.cv_user = current_user.cv_user if @job_applied.cv_user.blank?
end
def show
@applied_jobs = current_user.job_applieds.order("job_applieds.updated_at DESC").page(params[:page]).per(Job::LIMIT_PAGE)
@applied_jobs = current_user.job_applieds.order(updated_at: :desc).page(params[:page]).per(Job::LIMIT_PAGE)
end
def confirmation
......@@ -33,22 +30,22 @@ class AppliedJobsController < ApplicationController
render :new
end
session[:apply_job] = @job_applied
session[:cv] = @job_applied.cv_user
session[:cv] = @job_applied.cv_user.cache_name
end
def create
@job = Job.find_by(id: session[:apply_job]['job_id'])
@job_applied = current_user.job_applieds.new(apply_params)
@job_applied.job_id = session[:apply_job]['job_id'] if @job_applied.job_id.blank?
@job_applied.job_id = @job.id if @job_applied.job_id.blank?
@job_applied.cv_user.retrieve_from_cache!(apply_params[:cv_user])
if @job_applied.save
JobAppliedMailer.apply_job(@job_applied, @job).deliver_later
JobAppliedMailer.sending_admin(@job_applied, @job, ENV['GMAIL_USERNAME']).deliver_later
AppliedJobMailer.apply_job(@job_applied, @job).deliver_later
AppliedJobMailer.sending_admin(@job_applied, @job, ENV['GMAIL_USERNAME']).deliver_later
session.delete(:apply_job)
else
flash[:danger] = @job_applied.errors.full_messages.join('<br>')
redirect_to apply_job_path(job_id: session[:apply_job]['job_id'])
end
session.delete(:apply_job)
end
private
......
class JobAppliedMailer < ActionMailer::Base
class AppliedJobMailer < ActionMailer::Base
def apply_job(user, job)
@job = job
@user = user
......
......@@ -20,6 +20,10 @@ class UserCvUploader < CarrierWave::Uploader::Base
def extension_whitelist
%w(doc pdf xls xlsx zip)
end
def content_type_blacklist
%w(text/json application/json)
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url(*args)
# # For Rails 3.1+ asset pipeline compatibility:
......
......@@ -19,12 +19,12 @@ Rails.application.routes.draw do
get '/registation/3', to: 'users#registation', as: :registation
get 'apply', to: 'job_applieds#new', as: :apply_job
get 'apply', to: 'applied_jobs#new', as: :apply_job
post 'confirm', to: 'job_applieds#confirmation', as: :confirm_job
post 'done', to: 'job_applieds#create', as: :finished_apply
post 'confirm', to: 'applied_jobs#confirmation', as: :confirm_job
post 'done', to: 'applied_jobs#create', as: :finished_apply
get '/my/jobs', to: 'job_applieds#show', as: :my_jobs
get '/my/jobs', to: 'applied_jobs#show', as: :my_jobs
resources :jobs
get 'detail/:id', to: 'jobs#show', as: :job_detail
......@@ -33,7 +33,7 @@ Rails.application.routes.draw do
get 'jobs/industry/:converted_name', to: 'jobs#industry_jobs', as: :industry_jobs
get 'jobs/company/:converted_name', to: 'jobs#company_jobs', as: :company_jobs
resources :job_applieds,only: [:new, :create]
resources :applied_jobs, only: [:new, :create]
resources :reset_passwords, only: [:edit, :update]
resources :confirmations, only: [:new]
resources :top_pages, only: [:index]
......
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