Commit 2822e541 by Đường Sỹ Hoàng

First job apply

parent 476404b3
class ApplyController < ApplicationController
def done
# ApplyMailer.notify(@apply).deliver
# redirect_to done_path(@apply)
end
def new
@apply = UserJob.new(user_job_params)
end
def confirm
#binding.pry
@job = Job.find_by(id: params[:job_id])
@apply = current_user.apply_jobs.new(apply_job_params.merge(job_id: @job.id))
# @apply = @job.user_job.new(user_job_param)
if @apply.save
redirect_to done_path
end
end
def create
end
private
def user_job_params
params.permit(:job_id, :cv_url, :first_name, :last_name, :username, :email)
end
def apply_job_params
params.permit(:job_id, :user_id, :cv_url, :first_name, :last_name, :username, :email)
end
end
class ApplyMailer < ApplicationMailer
default from: "noreply@gmail.com"
# def notify(done)
# @apply = done
# mail to: @apply.email, subject: "Thank you for apply with VenJob"
# end
end
class ApplyJob < UserJob
belongs_to :users
belongs_to :jobs
end
...@@ -4,6 +4,7 @@ class Job < ApplicationRecord ...@@ -4,6 +4,7 @@ class Job < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :cities, through: :city_jobs has_many :cities, through: :city_jobs
has_many :industries, through: :industry_jobs has_many :industries, through: :industry_jobs
has_many :apply_jobs
def self.latest_jobs def self.latest_jobs
@latest ||= order(created_at: :desc).take(Settings.top.job.limit) @latest ||= order(created_at: :desc).take(Settings.top.job.limit)
......
...@@ -5,6 +5,7 @@ class User < ApplicationRecord ...@@ -5,6 +5,7 @@ class User < ApplicationRecord
:recoverable, :rememberable, :validatable :recoverable, :rememberable, :validatable
has_many :user_jobs has_many :user_jobs
has_many :apply_jobs
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
VALID_USERNAME_REGEX = /\A[a-zA-Z0-9]+\z/ VALID_USERNAME_REGEX = /\A[a-zA-Z0-9]+\z/
......
<!--links menu-->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<%= link_to "Apply New", apply_path %>
</li>
<li class="breadcrumb-item active" aria-current="page">
Apply Confirm
</li>
<li class="breadcrumb-item">
<%= link_to "Apply Finish", "#" %>
</li>
</ol>
</nav>
<div class="row row-cols-1">
<div class="job-content-wrapper">
<dl class="row">
<dt class="col-sm-3">Username:</dt>
<dd class="col-sm-9"><%= @apply.username %></dd>
<dt class="col-sm-3">FirstName:</dt>
<dd class="col-sm-9"><%= @apply.first_name %></dd>
<dt class="col-sm-3">LastName:</dt>
<dd class="col-sm-9"><%= @apply.last_name %></dd>
<dt class="col-sm-3">Email:</dt>
<dd class="col-sm-9">
<%= @apply.email %>
</dd>
<dt class="col-sm-3">CV URL:</dt>
<dd class="col-sm-9">
<%= @apply.cv_url %>
</dd>
</dl>
<div class = "float-right">
<%= link_to "Done", done_path, class: "btn btn-primary" %>
</div>
<div class= "float-left">
<%= link_to "Edit", apply_path, class: "btn btn-primary" %>
</div>
</div>
</div>
<!--links menu-->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class = "breadcrumb-item">
<%= link_to "Apply New" %>
</li>
<li class="breadcrumb-item">
<%= link_to "Apply Confirmation", "#" %>
</li>
<li class = "breadcrumb-item active" aria-current="page">
Apply Finish
</li>
</ol>
</nav>
<h4>Thank you for apply</h4>
</br>
<p><%= link_to "Back to TOP page", root_path %></p>
<!--links menu-->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">
Apply New
</li>
<li class="breadcrumb-item">
<%= link_to "Apply Confirmation", "#" %>
</li>
<li class="breadcrumb-item">
<%= link_to "Apply Finish", "#" %>
</li>
</ol>
</nav>
<div class="container">
<div class="d-flex justify-content-center ">
<div class="card">
<div class="card-header text-center">
<h2>Apply Form</h2>
</div>
<%= form_for(:user_job, url: apply_path) do |f|%>
<div class= "field">
<%= f.label :username %>
</br>
<%= f.text_field :username, autofocus: true, length: 200 %>
</div>
<div class="field">
<%= f.label :first_name %>
</br>
<%= f.text_field :first_name, autofocus: true %>
</div>
<div class="field">
<%= f.label :last_name %>
</br>
<%= f.text_field :last_name, autofocus: true %>
</div>
<div class="field">
<%= f.label :email %>
</br>
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :CV_URL %>
</br>
<%= f.url_field :cv_url, autofocus: true %>
</div>
</br>
<div class = "actions">
<%= f.submit "Confirm", class: "btn btn-primary" %>
</div>
<% end %>
</div>
</div>
</div>
...@@ -40,10 +40,15 @@ ...@@ -40,10 +40,15 @@
<%= f.password_field :password_confirmation, autocomplete: "new-password" %> <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div> </div>
<div class="field">
<%= f.label :Upload_CV %><br />
<%= f.url_field :cv_url %>
</div>
</br> </br>
<div class="actions text-center"> <div class="actions text-center">
<%= f.submit "Sign up", class: "btn-primary" %> <%= f.submit "Sign up", class: "btn btn-primary" %>
</div> </div>
<% end %> <% end %>
</div> </div>
......
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h4>Dear<%= @apply.username %></h4>
<p>
Thank you for applied with VenJob.Your applied job's information is a follow:
</p>
</br>
<!--<dl>
<dt>Job Title:</dt>
<dd><%= @job.title %></dd>
<dt>City:</dt>
<dd><%= @city.name %></dd>
<dt>Company:</dt>
<dd><%= @comapny.name %></dd>
</dd> -->
<p>Your submit information:</p>
</br>
<dl>
<dt>First Name:</dt>
<dd><%= @apply.first_name %></dd>
<dt>Last Name:</dt>
<dd><%= @apply.last_name %></dd>
<dt>Email:</dt>
<dd><%= @apply.email %></dd>
<dt>Email:</dt>
<dd><%= @apply.cv_url %></dd>
</dd>
</br>
<p>Best,</p>
</body>
</html>
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
<dt class="col-sm-3">Requirement:</dt> <dt class="col-sm-3">Requirement:</dt>
<dd class="col-sm-9"><%= simple_format @job.requirement %></dd> <dd class="col-sm-9"><%= simple_format @job.requirement %></dd>
</dl> </dl>
<% if user_signed_in? %>
<%= link_to "Apply", apply_path, class: "btn btn-primary" %>
<% else %>
<%= link_to "Login", login_path, class: "btn btn-primary" %>
<% end %>
</div> </div>
</div </div
...@@ -21,6 +21,9 @@ Rails.application.routes.draw do ...@@ -21,6 +21,9 @@ Rails.application.routes.draw do
get "jobs/city/:city_id", to: "jobs#index", as: "city_jobs" get "jobs/city/:city_id", to: "jobs#index", as: "city_jobs"
get "jobs/industry/:industry_id", to: "jobs#index", as: "industry_jobs" get "jobs/industry/:industry_id", to: "jobs#index", as: "industry_jobs"
get "detail/:job_id", to: "jobs#show", as: "job" get "detail/:job_id", to: "jobs#show", as: "job"
get "apply/:job_id", to: "apply#new", as: "apply"
post "apply/:job_id/", to: "apply#confirm", as: "confirm"
get "done", to: "apply#done", as: "done"
concern :paginatable do concern :paginatable do
get "(page/:page)", action: :index, on: :collection, as: "" get "(page/:page)", action: :index, on: :collection, as: ""
......
class AddCvUrlToUserJobs < ActiveRecord::Migration[6.0]
def change
add_column :user_jobs, :cv_url, :text
end
end
class AddUsernameToUserJobs < ActiveRecord::Migration[6.0]
def change
add_column :user_jobs, :username, :string
end
end
class AddFirstNameLastNameToUserJobs < ActiveRecord::Migration[6.0]
def change
add_column :user_jobs, :first_name, :string
add_column :user_jobs, :last_name, :string
end
end
class AddEmailToUserJobs < ActiveRecord::Migration[6.0]
def change
add_column :user_jobs, :email, :string
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_01_06_041448) do ActiveRecord::Schema.define(version: 2020_01_13_080045) do
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name" t.string "name"
...@@ -77,6 +77,11 @@ ActiveRecord::Schema.define(version: 2020_01_06_041448) do ...@@ -77,6 +77,11 @@ ActiveRecord::Schema.define(version: 2020_01_06_041448) do
t.datetime "applied_at" t.datetime "applied_at"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.text "cv_url"
t.string "username"
t.string "first_name"
t.string "last_name"
t.string "email"
t.index ["job_id"], name: "index_user_jobs_on_job_id" t.index ["job_id"], name: "index_user_jobs_on_job_id"
t.index ["user_id", "job_id"], name: "index_user_jobs_on_user_id_and_job_id" t.index ["user_id", "job_id"], name: "index_user_jobs_on_user_id_and_job_id"
t.index ["user_id"], name: "index_user_jobs_on_user_id" t.index ["user_id"], name: "index_user_jobs_on_user_id"
......
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