Commit 6b1c62b3 by Tô Ngọc Ánh

send email applied job success, refactor code

parent 78fc0282
Pipeline #934 canceled with stages
in 0 seconds
DB_USERNAME = 'root'
DB_PASSWORD = '123456789'
\ No newline at end of file
DB_PASSWORD = '123456789'
GMAIL_USERNAME = 'admin@venjob.com'
......@@ -15,9 +15,3 @@
//= require turbolinks
//= require jquery-3.5.1.slim.min
//= require_tree .
$(document).on('turbolinks:load', function() {
$('#applied_job_curriculum_vitae').change(function(){
$('#name_curriculum_vitae').text(this.files[0].name);
})
})
$(document).on('turbolinks:load', function() {
$('#applied_job_curriculum_vitae').change(function(){
$('#name_curriculum_vitae').text(this.files[0].name);
})
})
......@@ -13,82 +13,3 @@
*= require_tree .
*= require_self
*/
$main-color: #1da173;
.min-vh-80 {
min-height: 80vh;
}
.navbar {
background-color: $main-color;
}
.footer {
width: 100%;
height: 50px;
background-color: $main-color;
}
.divider {
width: 100px;
border-top: 2px solid $main-color
}
.vertical-divider {
position: relative;
padding: 0px 4px;
&::after {
content: '';
width: 1px;
height: 18px;
margin-left: 3px;
position: absolute;
border-right: 1px solid black;
top: 50%;
right: -3px;
transform: translateY(-50%);
}
&:last-child {
&::after {
display: none;
}
}
}
.card-img-rounded {
border-radius: 50%;
background-color: mediumseagreen;
height: 220px; width: 220px;
margin-top: 50px;
padding: 10px;
.card-img {
margin-top: 40px;
}
}
.ribbon::before, .ribbon::after {
content: "";
position: absolute;
height: 41px;
top: 0;
}
.ribbon::before {
left: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid transparent;
border-left: 20px solid white;
}
.ribbon::after {
right: 0;
border-top: 20px solid white;
border-bottom: 20px solid white;
border-right: 20px solid white;
border-left: 20px solid transparent;
}
.ribbon::before, .ribbon::after {
content: "";
position: absolute;
height: 41px;
top: 0;
}
.ribbon::before {
left: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid transparent;
border-left: 20px solid white;
}
.ribbon::after {
right: 0;
border-top: 20px solid white;
border-bottom: 20px solid white;
border-right: 20px solid white;
border-left: 20px solid transparent;
}
\ No newline at end of file
@import 'base';
.min-vh-80 {
min-height: 80vh;
}
.navbar {
background-color: $main-color;
}
.footer {
width: 100%;
height: 50px;
background-color: $main-color;
}
.divider {
width: 100px;
border-top: 2px solid $main-color
}
.vertical-divider {
position: relative;
padding: 0px 4px;
&::after {
content: '';
width: 1px;
height: 18px;
margin-left: 3px;
position: absolute;
border-right: 1px solid black;
top: 50%;
right: -3px;
transform: translateY(-50%);
}
&:last-child {
&::after {
display: none;
}
}
}
\ No newline at end of file
@import 'base';
.card-img-rounded {
border-radius: 50%;
background-color: $main-color;
height: 220px; width: 220px;
margin-top: 50px;
padding: 10px;
.card-img {
margin-top: 40px;
}
}
......@@ -19,9 +19,13 @@ class AppliedJobsController < ApplicationController
def finish
@applied_job = current_user.applied_jobs.new(applied_job_params)
@applied_job.curriculum_vitae = File.new(params[:applied_job][:curriculum_vitae])
@applied_job.save
AppliedJobMailer.with(applied_job: @applied_job).success_email.deliver_later
@applied_job.curriculum_vitae.retrieve_from_cache!(params[:applied_job][:curriculum_vitae])
if @applied_job.save
AppliedJobMailer.with(applied_job: @applied_job).success_email.deliver_later
else
flash[:error] = @applied_job.errors.full_messages
redirect_to new_applied_job_path(job_id: @applied_job.job_id)
end
end
private
......
class ApplicationMailer < ActionMailer::Base
default from: 'admin@venjob.com'
default from: 'no-reply@venjob.com'
layout 'mailer'
end
......@@ -2,6 +2,6 @@ class AppliedJobMailer < ApplicationMailer
def success_email
@applied_job = params[:applied_job]
mail(to: @applied_job.email, subject: "Your apply is successful!")
mail(to: @applied_job.email, subject: "Thank you for apply with VenJOB", bcc: ENV['GMAIL_USERNAME'])
end
end
......@@ -7,7 +7,7 @@ class AppliedJob < ApplicationRecord
validates :full_name, presence: true, length: { maximum: 200 }
validates :email, presence: true, format: { with: EMAIL_REGEXN }
validates :curriculum_vitae, presence: true
validates :user, uniqueness: { scope: :job, message: 'already applied this job' }
validates :user, uniqueness: { scope: :job, message: 'has already applied this job' }
mount_uploader :curriculum_vitae, CurriculumVitaeUploader
end
......@@ -17,6 +17,10 @@ class CurriculumVitaeUploader < CarrierWave::Uploader::Base
0.megabytes..5.megabytes
end
def asset_host
"http://localhost:3000"
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:
......
......@@ -15,7 +15,7 @@
<p>Your submitted information:</p>
<p>Full Name: <%= @applied_job.full_name %></p>
<p>Email: <%= @applied_job.email %></p>
<p>CV Link: <%= link_to @applied_job.curriculum_vitae.identifier, root_url + @applied_job.curriculum_vitae.url %></p>
<p>CV Link: <%= link_to @applied_job.curriculum_vitae.identifier, @applied_job.curriculum_vitae.url, target: '_blank' %></p>
<br>
<p>Thanks and best regards.</p>
</body>
......
......@@ -55,7 +55,7 @@
<%= link_to @applied_job.curriculum_vitae.url, target: '_blank', class: 'text-dark' do %>
<i class="fas fa-eye"></i>
<% end %>
<%= f.hidden_field :curriculum_vitae, class: 'd-none', value: @applied_job.curriculum_vitae.path %>
<%= f.hidden_field :curriculum_vitae, class: 'd-none', value: @applied_job.curriculum_vitae.cache_name %>
</div>
</div>
<div class="row my-3">
......
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