Commit 972348f5 by Hoang Nam Nguyen

'finish apply_page'

parent fdf3dc0c
......@@ -8991,4 +8991,8 @@ a.text-dark:focus, a.text-dark:hover {
.glyphicon-menu-up:before {
content: "\e260";
}
.field_with_errors {
@extend .has-danger;
}
/*# sourceMappingURL=bootstrap.css.map */
\ No newline at end of file
class AppliesController < ApplicationController
def new
@user_apply = Apply.new
@user_apply = Apply.new(session[:apply] || {})
end
def create
return if current_user.nil?
@user_apply = Apply.new(user_apply)
if @user_apply.save
redirect_to confirm_apply_path(id: @user_apply.id)
@user_apply = Apply.new(user_apply_job)
@user_apply.job_id = Job.find(params[:id]).id
@user_apply.user_id = @current_user.id
if @user_apply.valid?
session[:apply] = @user_apply.as_json
redirect_to confirm_apply_path
else
render 'new'
end
end
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
private
def user_apply
def user_apply_job
params.require(:apply).permit(:email, :name)
end
......
class PasswordResetsController < ApplicationController
before_action :get_user, only: [:edit, :update]
before_action :valid_user, only: [:edit, :update]
before_action :check_expiration, only: [:edit, :update]
before_action :get_user, :valid_user,:check_expiration, only: [:edit, :update]
def new
end
......
......@@ -27,8 +27,7 @@ class UsersController < ApplicationController
@user.validate_password = true
if @user.update_attributes(user_params)
@user.update_attributes(:activated => true)
@user.update_attributes(:activated_at => Time.zone.now)
@user.update_attributes(:activated => true,:activated_at => Time.zone.now)
flash[:success] = "Update success"
redirect_to my_page_path
else
......@@ -43,7 +42,10 @@ class UsersController < ApplicationController
def download_cv
@user = User.find(params[:id])
downloadFile = @user.cv
send_file downloadFile.current_path
send_file downloadFile.file.file
end
def my_jobs
end
private
......
......@@ -16,4 +16,12 @@ class UserMailer < ApplicationMailer
@user = User.find(user_id)
mail to: @user.email, subject: "Success Password"
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
class Apply < ApplicationRecord
belongs_to :user
belongs_to :job
validates :name, presence: true, length: {maximum: 200}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255},
......
......@@ -4,5 +4,7 @@ class Job < ApplicationRecord
has_many :job_industries
has_many :industries, through: :job_industries
belongs_to :company
has_many :applies
scope :recent, -> (num) { order(id: :desc).limit(num) }
end
class User < ApplicationRecord
has_many :applies
has_secure_password(validations: false)
attr_accessor :validate_name, :validate_password, :validate_confirm, :reset_token,
......@@ -8,6 +10,7 @@ class User < ApplicationRecord
validates :name, presence: true, length: { maximum: 200 }, if: :validate_name
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255},
format: {with: VALID_EMAIL_REGEX },
uniqueness: {case_sensitive: false}
......@@ -24,8 +27,7 @@ class User < ApplicationRecord
def create_reset_digest
self.reset_token = generate_token
update_attributes(:reset_digest => digest(reset_token))
update_attributes(:reset_sent_at => Time.zone.now)
update_attributes(:reset_digest => digest(reset_token),:reset_sent_at => Time.zone.now)
end
def digest(string)
......@@ -48,6 +50,9 @@ class User < ApplicationRecord
reset_sent_at < 1.day.ago
end
def applied_job?(job)
applies.pluck(:job_id).include?(job.id)
end
private
def downcase_email
......
<%= 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="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="row mt-3 mb-5 ml-5">
<!--set field email -->
<div class="col-md-2">
<strong><i>Email: </i></strong>
<div class="col-md-2">
<strong><i>Email: </i></strong>
</div>
<!--set field email -->
<div class="col-md-10">
<%= @user_apply.email %>
</div>
<!--end field password -->
</div>
<!--set field email -->
<div class="col-md-10">
<%= binding.pry %>
<%= @user_apply.email %>
</div>
<!--end field password -->
</div>
<!--set field Name -->
<!--set field Name -->
<div class="row mt-5 mb-5 ml-5">
<!--set field Name -->
<div class= "col-md-2">
<strong><i>Full Name: </i></strong>
<div class="row mt-5 mb-5 ml-5">
<!--set field Name -->
<div class= "col-md-2">
<strong><i>Full Name: </i></strong>
</div>
<!--set field name -->
<div class="col-md-10">
<%= @user_apply.name %>
</div>
<!--set field password -->
</div>
<!--set field name -->
<div class="col-md-10">
<%= @user_apply.name %>
</div>
<!--set field password -->
</div>
<!--set field cv -->
<div class="row mt-5 mb-5 ml-5">
<!--set field cv -->
<div class="col-md-2">
<strong><i>My CV</i></strong>
<!--set field cv -->
<div class="row mt-5 mb-5 ml-5">
<!--set field cv -->
<div class="col-md-2">
<strong><i>My CV</i></strong>
</div>
<!--set field cv -->
<div class="col-md-10 ">
<%= current_user.cv %>
</div>
<!--set field cv -->
</div>
<!--set field cv -->
<div class="col-md-10 ">
<%= current_user.cv %>
</div>
<!--set field cv -->
</div>
<!--end field cv -->
<!--end field cv -->
<!--set button update -->
<div class="row ml-5 pb-5 pl-5">
<div class="col-md-4 text-center ">
<%= link_to '#',class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Edit
<% end %>
<!--set button update -->
<div class="row ml-5 pb-5 pl-5">
<div class="col-md-4 text-center ">
<%= link_to form_apply_path(id: @user_apply.job.id),class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Edit
<% end %>
</div>
<div class="col-md-3">
<%= link_to '#',class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Done
<%= link_to finish_apply_path, class: 'btn btn-danger' do %>
<i class="fa fa-check-circle-o"></i> Done
<% end %>
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
</div>
\ 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") %>
<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>
<div class="row ml-5 mt-5">
<div class="col-md-10 col-md-offset-3">
<!--set message errors -->
<!--end set -->
<!--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'%>
<div class="row mt-3">
<!--set field password -->
<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>
<!--set field password -->
<div class="col-md-10">
......@@ -22,7 +37,7 @@
<!--end set field password -->
<!--set field email -->
<div class="col-md-2">
<strong><i><%= f.label :email %></i></strong>
<strong><i class="text-danger"><%= f.label :email %></i></strong>
</div>
<!--set field email -->
<div class="col-md-10">
......@@ -32,15 +47,18 @@
</div>
</div>
<!--end field email -->
<% if current_user.cv? %>
<div class="col-md-4">
<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 class="col-md-2">
<strong><i class="text-danger">My CV</i></strong>
</div>
</div>
<% end %>
<% if current_user.cv? %>
<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 -->
<div class="col-sm-2"></div>
<div class="col-sm-10">
......@@ -48,6 +66,7 @@
<i class="fa fa-check 4px"></i> Confirm
<% end %>
</div>
</div>
<!--end set button -->
<% end %>
</div>
......
......@@ -6,8 +6,11 @@
<%= link_to 'CITY',cities_path , { class: 'btn btn-success' } %>
<%= link_to 'INDUSTRY', industries_path, { class: 'btn btn-success' } %>
<%= link_to 'SHORT TITLE', '#', { class: 'btn btn-success' } %>
<% if logged_in? %>
<%= link_to 'Apply',form_apply_path(id: @job.id), {class: 'btn btn-primary float-right'} %>
<% if logged_in? && current_user.applied_job?(@job) %>
<%= 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 %>
<%= link_to 'Apply',login_user_path, {class: 'btn btn-primary float-right'} %>
<% end %>
......@@ -24,7 +27,7 @@
<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-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">Favorite</a>
</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 @@
<div class="col-md-3">
<%= link_to '#',class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> MyJobs
<i class="fa fa-list-ol"></i> MyJobs
<% end %>
</div>
</div>
......
......@@ -19,11 +19,12 @@ Rails.application.routes.draw do
get 'register/1',controller: :users,action: :new, as: :confirm_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
patch 'register/:id',controller: :users,action: :update,as: :update_user
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 '/login',controller: :sessions,action: :new,as: :login_user
post '/login',controller: :sessions,action: :create
delete '/logout',controller: :sessions,action: :destroy
......@@ -32,6 +33,7 @@ Rails.application.routes.draw do
get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply
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'
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