Commit 972348f5 by Hoang Nam Nguyen

'finish apply_page'

parent fdf3dc0c
...@@ -8991,4 +8991,8 @@ a.text-dark:focus, a.text-dark:hover { ...@@ -8991,4 +8991,8 @@ a.text-dark:focus, a.text-dark:hover {
.glyphicon-menu-up:before { .glyphicon-menu-up:before {
content: "\e260"; content: "\e260";
} }
.field_with_errors {
@extend .has-danger;
}
/*# sourceMappingURL=bootstrap.css.map */ /*# sourceMappingURL=bootstrap.css.map */
\ No newline at end of file
class AppliesController < ApplicationController class AppliesController < ApplicationController
def new def new
@user_apply = Apply.new @user_apply = Apply.new(session[:apply] || {})
end end
def create def create
return if current_user.nil? return if current_user.nil?
@user_apply = Apply.new(user_apply) @user_apply = Apply.new(user_apply_job)
if @user_apply.save @user_apply.job_id = Job.find(params[:id]).id
redirect_to confirm_apply_path(id: @user_apply.id) @user_apply.user_id = @current_user.id
if @user_apply.valid?
session[:apply] = @user_apply.as_json
redirect_to confirm_apply_path
else else
render 'new' render 'new'
end end
end end
def confirm_apply def confirm_apply
@user_apply = Apply.find(params[:id]) @user_apply = Apply.new(session[:apply])
end
def finish
@user_apply = Apply.new(session[:apply])
@user_apply.save
UserMailer.apply_success(@user_apply.id).deliver_later
session[:apply] = nil
end end
private private
def user_apply def user_apply_job
params.require(:apply).permit(:email, :name) params.require(:apply).permit(:email, :name)
end end
......
class PasswordResetsController < ApplicationController class PasswordResetsController < ApplicationController
before_action :get_user, only: [:edit, :update] before_action :get_user, :valid_user,:check_expiration, only: [:edit, :update]
before_action :valid_user, only: [:edit, :update]
before_action :check_expiration, only: [:edit, :update]
def new def new
end end
......
...@@ -27,8 +27,7 @@ class UsersController < ApplicationController ...@@ -27,8 +27,7 @@ class UsersController < ApplicationController
@user.validate_password = true @user.validate_password = true
if @user.update_attributes(user_params) if @user.update_attributes(user_params)
@user.update_attributes(:activated => true) @user.update_attributes(:activated => true,:activated_at => Time.zone.now)
@user.update_attributes(:activated_at => Time.zone.now)
flash[:success] = "Update success" flash[:success] = "Update success"
redirect_to my_page_path redirect_to my_page_path
else else
...@@ -43,7 +42,10 @@ class UsersController < ApplicationController ...@@ -43,7 +42,10 @@ class UsersController < ApplicationController
def download_cv def download_cv
@user = User.find(params[:id]) @user = User.find(params[:id])
downloadFile = @user.cv downloadFile = @user.cv
send_file downloadFile.current_path send_file downloadFile.file.file
end
def my_jobs
end end
private private
......
...@@ -16,4 +16,12 @@ class UserMailer < ApplicationMailer ...@@ -16,4 +16,12 @@ class UserMailer < ApplicationMailer
@user = User.find(user_id) @user = User.find(user_id)
mail to: @user.email, subject: "Success Password" mail to: @user.email, subject: "Success Password"
end end
def apply_success(user_apply_id)
@user_apply = Apply.find(user_apply_id)
@user = User.find(@user_apply.user.id)
@job = Job.find(@user_apply.job.id)
@work_place = @job.cities.map(&:location).join(',')
mail to: @user.email, subject: "Thank you for apply with VeNJOB"
end
end end
class Apply < ApplicationRecord class Apply < ApplicationRecord
belongs_to :user
belongs_to :job
validates :name, presence: true, length: {maximum: 200} validates :name, presence: true, length: {maximum: 200}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255}, validates :email, presence: true, length: {maximum: 255},
......
...@@ -4,5 +4,7 @@ class Job < ApplicationRecord ...@@ -4,5 +4,7 @@ class Job < ApplicationRecord
has_many :job_industries has_many :job_industries
has_many :industries, through: :job_industries has_many :industries, through: :job_industries
belongs_to :company belongs_to :company
has_many :applies
scope :recent, -> (num) { order(id: :desc).limit(num) } scope :recent, -> (num) { order(id: :desc).limit(num) }
end end
class User < ApplicationRecord class User < ApplicationRecord
has_many :applies
has_secure_password(validations: false) has_secure_password(validations: false)
attr_accessor :validate_name, :validate_password, :validate_confirm, :reset_token, attr_accessor :validate_name, :validate_password, :validate_confirm, :reset_token,
...@@ -8,6 +10,7 @@ class User < ApplicationRecord ...@@ -8,6 +10,7 @@ class User < ApplicationRecord
validates :name, presence: true, length: { maximum: 200 }, if: :validate_name validates :name, presence: true, length: { maximum: 200 }, if: :validate_name
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255}, validates :email, presence: true, length: {maximum: 255},
format: {with: VALID_EMAIL_REGEX }, format: {with: VALID_EMAIL_REGEX },
uniqueness: {case_sensitive: false} uniqueness: {case_sensitive: false}
...@@ -24,8 +27,7 @@ class User < ApplicationRecord ...@@ -24,8 +27,7 @@ class User < ApplicationRecord
def create_reset_digest def create_reset_digest
self.reset_token = generate_token self.reset_token = generate_token
update_attributes(:reset_digest => digest(reset_token)) update_attributes(:reset_digest => digest(reset_token),:reset_sent_at => Time.zone.now)
update_attributes(:reset_sent_at => Time.zone.now)
end end
def digest(string) def digest(string)
...@@ -48,6 +50,9 @@ class User < ApplicationRecord ...@@ -48,6 +50,9 @@ class User < ApplicationRecord
reset_sent_at < 1.day.ago reset_sent_at < 1.day.ago
end end
def applied_job?(job)
applies.pluck(:job_id).include?(job.id)
end
private private
def downcase_email def downcase_email
......
<%= provide(:title, "Confirmation") %> <%= provide(:title, "Confirmation") %>
<h1 class="text-danger text-center">Confirmation</h1> <div class="row mt-5 mb-5">
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block "> New <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-danger btn-block text-white"> Confirm <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block"> Finish <span class="fa fa-stop-circle"></span></a>
</div>
</div>
<h1 class="text-danger text-center">Confirmation</h1>
<div class="row ml-5 ct_local pl-3 pt-5 mt-5 mb-5"> <div class="row ml-5 ct_local pl-3 pt-5 mt-5 mb-5">
<div class="col-md-10 col-md-offset-3"> <div class="col-md-10 col-md-offset-3">
<!--set field email -->
<div class="row mt-3 mb-5 ml-5">
<!--set field email -->
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
<!--set field email --> <div class="col-md-2">
<div class="row mt-3 mb-5 ml-5"> <strong><i>Email: </i></strong>
<!--set field email --> </div>
<div class="col-md-2"> <!--set field email -->
<strong><i>Email: </i></strong> <div class="col-md-10">
<%= @user_apply.email %>
</div>
<!--end field password -->
</div> </div>
<!--set field email --> <!--set field Name -->
<div class="col-md-10">
<%= binding.pry %>
<%= @user_apply.email %>
</div>
<!--end field password -->
</div>
<!--set field Name -->
<div class="row mt-5 mb-5 ml-5"> <div class="row mt-5 mb-5 ml-5">
<!--set field Name --> <!--set field Name -->
<div class= "col-md-2"> <div class= "col-md-2">
<strong><i>Full Name: </i></strong> <strong><i>Full Name: </i></strong>
</div>
<!--set field name -->
<div class="col-md-10">
<%= @user_apply.name %>
</div>
<!--set field password -->
</div> </div>
<!--set field name -->
<div class="col-md-10">
<%= @user_apply.name %>
</div>
<!--set field password -->
</div>
<!--set field cv --> <!--set field cv -->
<div class="row mt-5 mb-5 ml-5"> <div class="row mt-5 mb-5 ml-5">
<!--set field cv --> <!--set field cv -->
<div class="col-md-2"> <div class="col-md-2">
<strong><i>My CV</i></strong> <strong><i>My CV</i></strong>
</div>
<!--set field cv -->
<div class="col-md-10 ">
<%= current_user.cv %>
</div>
<!--set field cv -->
</div> </div>
<!--set field cv --> <!--end field cv -->
<div class="col-md-10 ">
<%= current_user.cv %>
</div>
<!--set field cv -->
</div>
<!--end field cv -->
<!--set button update --> <!--set button update -->
<div class="row ml-5 pb-5 pl-5"> <div class="row ml-5 pb-5 pl-5">
<div class="col-md-4 text-center "> <div class="col-md-4 text-center ">
<%= link_to '#',class: 'btn btn-danger' do %> <%= link_to form_apply_path(id: @user_apply.job.id),class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Edit <i class="fa fa-wrench"></i> Edit
<% end %> <% end %>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<%= link_to '#',class: 'btn btn-danger' do %> <%= link_to finish_apply_path, class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Done <i class="fa fa-check-circle-o"></i> Done
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file \ No newline at end of file
<%= provide(:title, "Done") %>
<div class="row mt-5 mb-5">
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block"> New <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block "> Confirm <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-danger btn-block text-white"> Finish <span class="fa fa-stop-circle"></span></a>
</div>
</div>
<h1 class="text-center text-danger mt-5">Thank you for apply</h1>
<h2 class="text-center mt-5 "><a href="<%=root_path %>" class="">Back to TOP page</a></h2>
\ No newline at end of file
<%= provide(:title, "Job Apply") %> <%= provide(:title, "Job Apply") %>
<div class="row mt-5 mb-5">
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-danger btn-block text-white"> New <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block "> Confirm <span class="fa fa-arrow-right"></span></a>
</div>
<div class="col-xs-6 col-md-4">
<a class="btn btn-lg btn-primary btn-block"> Finish <span class="fa fa-stop-circle"></span></a>
</div>
</div>
<h1 class="text-center text-danger">Apply Form</h1> <h1 class="text-center text-danger">Apply Form</h1>
<div class="row ml-5 mt-5"> <div class="row ml-5 mt-5">
<div class="col-md-10 col-md-offset-3"> <div class="col-md-10 col-md-offset-3">
<!--set message errors --> <!--set message errors -->
<!--end set --> <!--end set -->
<!--set field all --> <!--set field all -->
<%= form_for(:apply, url: new_info_path) do |f| %> <%= form_for(@user_apply, url: new_info_path) do |f| %>
<%= render 'shared/error_user_apply'%> <%= render 'shared/error_user_apply'%>
<div class="row mt-3"> <div class="row mt-3">
<!--set field password --> <!--set field password -->
<div class="col-md-2 mb-5"> <div class="col-md-2 mb-5">
<strong><i><%= f.label :name, "Full Name" %></i></strong> <strong><i class="text-danger"><%= f.label :name, "Full Name", class: 'form-label' %></i></strong>
</div> </div>
<!--set field password --> <!--set field password -->
<div class="col-md-10"> <div class="col-md-10">
...@@ -22,7 +37,7 @@ ...@@ -22,7 +37,7 @@
<!--end set field password --> <!--end set field password -->
<!--set field email --> <!--set field email -->
<div class="col-md-2"> <div class="col-md-2">
<strong><i><%= f.label :email %></i></strong> <strong><i class="text-danger"><%= f.label :email %></i></strong>
</div> </div>
<!--set field email --> <!--set field email -->
<div class="col-md-10"> <div class="col-md-10">
...@@ -32,15 +47,18 @@ ...@@ -32,15 +47,18 @@
</div> </div>
</div> </div>
<!--end field email --> <!--end field email -->
<% if current_user.cv? %> <div class="col-md-2">
<div class="col-md-4"> <strong><i class="text-danger">My CV</i></strong>
<strong><i>My CV</i></strong>
</div>
<div class="col-md-8 mb-5">
<%= link_to 'Download cv',downloadcv_path(id: @current_user.id) %>
</div> </div>
</div> <% if current_user.cv? %>
<% end %> <div class="col-md-10 mb-5 text-center">
<%= link_to 'Download cv',downloadcv_path(id: @current_user.id) %>
</div>
<% else %>
<div class ="col-md-10 mb-5">
<%= link_to 'Upload here',edit_account_activation_path(id: @current_user.id) %>
</div>
<% end %>
<!--end set field all --> <!--end set field all -->
<div class="col-sm-2"></div> <div class="col-sm-2"></div>
<div class="col-sm-10"> <div class="col-sm-10">
...@@ -48,6 +66,7 @@ ...@@ -48,6 +66,7 @@
<i class="fa fa-check 4px"></i> Confirm <i class="fa fa-check 4px"></i> Confirm
<% end %> <% end %>
</div> </div>
</div>
<!--end set button --> <!--end set button -->
<% end %> <% end %>
</div> </div>
......
...@@ -6,8 +6,11 @@ ...@@ -6,8 +6,11 @@
<%= link_to 'CITY',cities_path , { class: 'btn btn-success' } %> <%= link_to 'CITY',cities_path , { class: 'btn btn-success' } %>
<%= link_to 'INDUSTRY', industries_path, { class: 'btn btn-success' } %> <%= link_to 'INDUSTRY', industries_path, { class: 'btn btn-success' } %>
<%= link_to 'SHORT TITLE', '#', { class: 'btn btn-success' } %> <%= link_to 'SHORT TITLE', '#', { class: 'btn btn-success' } %>
<% if logged_in? %> <% if logged_in? && current_user.applied_job?(@job) %>
<%= link_to 'Apply',form_apply_path(id: @job.id), {class: 'btn btn-primary float-right'} %> <%= link_to 'Applied',root_path, {class: 'btn btn-primary float-right'} %>
<h1 class="text-danger mt-5"> You applied this job </h1>
<% elsif logged_in? %>
<%= link_to 'Apply',form_apply_path(job_id: @job.id), {class: 'btn btn-primary float-right'} %>
<% else %> <% else %>
<%= link_to 'Apply',login_user_path, {class: 'btn btn-primary float-right'} %> <%= link_to 'Apply',login_user_path, {class: 'btn btn-primary float-right'} %>
<% end %> <% end %>
...@@ -24,7 +27,7 @@ ...@@ -24,7 +27,7 @@
<h4 class="card-title text-primary"><%= @job.company.company_name %></h4> <h4 class="card-title text-primary"><%= @job.company.company_name %></h4>
<p class="card-texts">Location: <%= @job.cities.map(&:location).join(',') %></p> <p class="card-texts">Location: <%= @job.cities.map(&:location).join(',') %></p>
<p class="card-text"><a href="#">Salary: </a><%= @job.salary %></p> <p class="card-text"><a href="#">Salary: </a><%= @job.salary %></p>
<%= simple_format(@job.descripton) %> <%= simple_format(@job.descripton) %>
<a class="btn btn-success text-white w-25" href ="<%= form_apply_path(id: @job.id)%>">Apply</a> <a class="btn btn-success text-white w-25" href ="<%= form_apply_path(id: @job.id)%>">Apply</a>
<a class="btn btn-success text-white w-25">Favorite</a> <a class="btn btn-success text-white w-25">Favorite</a>
</div> </div>
......
<h1><%= @user.name %></h1>
<p>Thank you for applied with VenJOB. Your applied job's information is as follow: </p>
<p>Job Title: <%=@job.job_title%></p>
<p>Location: <%=@work_place%></p>
<p>Company: <%=@job.company.company_name%></p>
<p>Your submitted information:</p>
<p>Full Name: <%= @user_apply.name %></p>
<p>Email : <%= @user_apply.email %></p>
<p>Cv_link: <%= @user.cv%></p>
\ No newline at end of file
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<div class="col-md-3"> <div class="col-md-3">
<%= link_to '#',class: 'btn btn-danger' do %> <%= link_to '#',class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> MyJobs <i class="fa fa-list-ol"></i> MyJobs
<% end %> <% end %>
</div> </div>
</div> </div>
......
...@@ -19,11 +19,12 @@ Rails.application.routes.draw do ...@@ -19,11 +19,12 @@ Rails.application.routes.draw do
get 'register/1',controller: :users,action: :new, as: :confirm_email get 'register/1',controller: :users,action: :new, as: :confirm_email
post 'register/2',controller: :users,action: :create, as: :create_email post 'register/2',controller: :users,action: :create, as: :create_email
# get 'register/:id',controller: :users,action: :show, as: :show_email
get 'register/:id/edit',controller: :users,action: :edit,as: :edit_user get 'register/:id/edit',controller: :users,action: :edit,as: :edit_user
patch 'register/:id',controller: :users,action: :update,as: :update_user patch 'register/:id',controller: :users,action: :update,as: :update_user
get 'register/:id/my',controller: :users,action: :my_page,as: :my_page get 'register/:id/my',controller: :users,action: :my_page,as: :my_page
get 'my/jobs',controller: :users,action: :my_jobs,as: :my_jobs
get 'register/:id/download',controller: :users,action: :download_cv, as: :downloadcv get 'register/:id/download',controller: :users,action: :download_cv, as: :downloadcv
get '/login',controller: :sessions,action: :new,as: :login_user get '/login',controller: :sessions,action: :new,as: :login_user
post '/login',controller: :sessions,action: :create post '/login',controller: :sessions,action: :create
delete '/logout',controller: :sessions,action: :destroy delete '/logout',controller: :sessions,action: :destroy
...@@ -32,6 +33,7 @@ Rails.application.routes.draw do ...@@ -32,6 +33,7 @@ Rails.application.routes.draw do
get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply
post 'apply/job/:id',controller: :applies,action: :create,as: :new_info post 'apply/job/:id',controller: :applies,action: :create,as: :new_info
get 'confirm/:id', controller: :applies,action: :confirm_apply,as: :confirm_apply get 'apply/confirm', controller: :applies,action: :confirm_apply,as: :confirm_apply
get 'apply/finish',controller: :applies,action: :finish,as: :finish_apply
mount Sidekiq::Web => '/sidekiq' mount Sidekiq::Web => '/sidekiq'
end end
class DropInstalls < ActiveRecord::Migration[5.1]
def change
drop_table :apply_users
end
end
class AddJobIdUserIdToApplies < ActiveRecord::Migration[5.1]
def change
add_column :applies, :job_id, :integer
add_column :applies, :user_id, :integer
end
end
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