Commit 38b8dbb0 by Tô Ngọc Ánh

create new, confirm page

parent a4ec7e87
Pipeline #903 failed with stages
in 0 seconds
......@@ -15,3 +15,9 @@
//= 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);
})
})
......@@ -16,6 +16,10 @@
$main-color: #1da173;
.min-vh-80 {
min-height: 80vh;
}
.navbar {
background-color: $main-color;
}
......@@ -57,22 +61,22 @@ background-color: $main-color;
.ribbon::before, .ribbon::after {
content: "";
position: absolute;
height: 49px;
height: 41px;
top: 0;
}
.ribbon::before {
left: 0;
border-top: 24px solid transparent;
border-bottom: 24px solid transparent;
border-right: 24px solid transparent;
border-left: 24px solid white;
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: 24px solid white;
border-bottom: 24px solid white;
border-right: 24px solid white;
border-left: 24px solid transparent;
border-top: 20px solid white;
border-bottom: 20px solid white;
border-right: 20px solid white;
border-left: 20px solid transparent;
}
class AppliedJobsController < ApplicationController
before_action :authenticate_user!
def new
job = Job.find_by(id: params[:job_id])
if job.nil?
redirect_to root_path
return
end
@applied_job = job.applied_jobs.new(full_name: current_user.full_name,
email: current_user.email,
curriculum_vitae: current_user.curriculum_vitae)
end
def confirm
@applied_job = current_user.applied_jobs.new(applied_job_params)
@applied_job.curriculum_vitae = current_user.curriculum_vitae if params[:curriculum_vitae].nil?
redirect_to root_path if @applied_job.invalid?
end
def finish
end
private
def applied_job_params
params.require(:applied_job).permit(:job_id, :full_name, :email, :curriculum_vitae)
end
end
class AppliedJob < ApplicationRecord
EMAIL_REGEXN = /\A[a-zA-Z][\w\.]+@[a-zA-Z]+\.[a-zA-Z]+\z/
belongs_to :user
belongs_to :job
validates :full_name, presence: true, length: { maximum: 200 }
validates :email, presence: true, format: { with: EMAIL_REGEXN }
validates :curriculum_vitae, presence: true
mount_uploader :curriculum_vitae, CurriculumVitaeUploader
end
<div class="row my-5 border-top border-bottom">
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">1</span>
New
</h5>
</div>
<div class="col bg-success text-center ribbon">
<h5 class="text-white my-2">
<span class="badge badge-light">2</span> Confirm
</h5>
</div>
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">3</span> Finish
</h5>
</div>
</div>
<div class="row">
<div class="col-md-5 col-sm-12 mx-auto">
<div class="row">
<div class="col-5">
<h5 class="font-weight-bold">Full Name</h5>
</div>
<div class="col-7">
<h5><%= @applied_job.user.full_name %></h5>
</div>
</div>
<div class="row">
<div class="col-5">
<h5 class="font-weight-bold">Email</h5>
</div>
<div class="col-7">
<h5><%= @applied_job.user.email %></h5>
</div>
</div>
<div class="row">
<div class="col-5">
<h5 class="font-weight-bold">Curriculum Vitae</h5>
</div>
<div class="col-7">
<%= link_to @applied_job.curriculum_vitae.identifier, @applied_job.curriculum_vitae.url, download: @applied_job.curriculum_vitae.identifier %>
<%= link_to @applied_job.curriculum_vitae.url, target: '_blank', class: 'text-dark' do %>
<i class="fas fa-eye"></i>
<% end %>
</div>
</div>
<div class="row my-3">
<div class="col text-right">
<%= link_to 'Edit', new_applied_job_path, class: 'btn btn-outline-secondary btn-lg' %>
</div>
<div class="col text-left">
<%= link_to 'Done', '#', class: 'btn btn-outline-success btn-lg' %>
</div>
</div>
</div>
</div>
<div class="row my-5 border-top border-bottom">
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">1</span>
New
</h5>
</div>
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">2</span> Confirm
</h5>
</div>
<div class="col bg-success text-center ribbon">
<h5 class="text-white my-2">
<span class="badge badge-light">3</span> Finish
</h5>
</div>
</div>
<h3 class="text-center mt-5">Thank you for apply.</h3>
<br>
<h3 class="text-center">Back to <%= link_to 'TOP', root_path, class: 'text-danger text-decorate-none' %> page.</a></h3>
<div class="row my-5 border-top border-bottom">
<div class="col bg-success text-center ribbon">
<h5 class="text-white my-2">
<span class="badge badge-light">1</span>
New
</h5>
</div>
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">2</span> Confirm
</h5>
</div>
<div class="col bg-light text-center">
<h5 class="text-muted my-2">
<span class="badge badge-success">3</span> Finish
</h5>
</div>
</div>
<div class="apply-form mx-5 px-5">
<%= form_for @applied_job, url: confirm_applied_job_path do |f| %>
<%= f.hidden_field :job_id %>
<div class="d-flex justify-content-between my-3">
<%= f.label :full_name, class: 'mt-2 font-weight-bold' %>
<%= f.text_field :full_name, class: 'form-control w-75', maxlength: 200, required: true %>
</div>
<div class="d-flex justify-content-between my-3">
<%= f.label :email, class: 'mt-2 font-weight-bold' %>
<%= f.text_field :email, class: 'form-control w-75', required: true %>
</div>
<div class="d-flex justify-content-between my-3">
<span class="mt-2 font-weight-bold">Curriculum Vitae</span>
<div class="w-75 mt-2">
<span id="name_curriculum_vitae" class="mr-2">
<%= @applied_job.curriculum_vitae.identifier %>
</span>
<%= f.label :curriculum_vitae do %>
<i class="fas fa-file-upload fa-lg"></i>
<% end %>
<%= f.file_field :curriculum_vitae, accept: '.doc, .pdf, .xls, .xlsx, .zip', class: 'd-none' %>
</div>
</div>
<div class="actions text-center my-3">
<%= f.submit "Confirm", class: 'btn btn-outline-success btn-lg' %>
</div>
<% end %>
</div>
......@@ -26,8 +26,6 @@
<div class="form-group">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %>
<% if @minimum_password_length %>
<% end %>
</div>
<div class="form-group">
......
......@@ -31,12 +31,12 @@
<%= @job.description.html_safe %>
</div>
<div class="col-2">
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-success btn-lg' %>
<%= link_to 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' %>
</div>
</div>
<div class="row my-3">
<div class="col-6 text-right">
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-success btn-lg' %>
<%= link_to 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' %>
</div>
<div class="col-6 text-left">
<%= link_to 'Favorite', '#', class: 'btn btn-outline-danger btn-lg' %>
......
......@@ -8,5 +8,6 @@ Rails.application.routes.draw do
get 'my', to: 'users#my_page', as: :my_page
resources :users, only: :show
get 'apply', to: 'applied_jobs#new', as: :new_applied_job
post 'confirm', to: 'applied_jobs#confirm', as: :confirm_applied_job
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
require 'test_helper'
class HomeControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get home_index_url
assert_response :success
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user: one
job: one
full_name: MyString
email: MyString
curriculum_vitae: MyString
two:
user: two
job: two
full_name: MyString
email: MyString
curriculum_vitae: MyString
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
description: MyText
address: MyString
two:
name: MyString
description: MyText
address: MyString
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user: one
job: one
two:
user: two
job: two
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user: one
job: one
two:
user: two
job: two
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
two:
name: MyString
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
company: one
title: MyString
level: MyString
salary: MyString
experience: MyString
description: MyText
expiration_date: 2020-07-15
two:
company: two
title: MyString
level: MyString
salary: MyString
experience: MyString
description: MyText
expiration_date: 2020-07-15
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
area: MyString
city: MyString
two:
area: MyString
city: MyString
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
job: one
location: one
two:
job: two
location: two
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
email: MyString
full_name: MyString
curriculum_vitae: MyString
password: MyString
admin: false
two:
email: MyString
full_name: MyString
curriculum_vitae: MyString
password: MyString
admin: false
require 'test_helper'
class AppliedJobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class CompanyTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class FavoriteTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class HistoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class IndustryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class JobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class LocationTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class LocationsJobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# 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