Commit bc985c5e by Hoang Nam Nguyen

fix conflic

parents 088baf75 2d2646d2
......@@ -13,5 +13,5 @@
//= require rails-ujs
//= require turbolinks
//= require jquery-3.2.1.min
//= require popper
//= require popper.min
//= require_tree .
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
//
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
}).call(this);
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
// Place all the styles related to the Search controller here.
// Place all the styles related to the Applies controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
......@@ -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
......@@ -139,3 +139,7 @@ footer.page-footer {
.dark-grey-text {
color: #4f4f4f !important;
}
.font_footer {
font-size: 70%;
}
\ No newline at end of file
// Place all the styles related to the TopPages controller here.
// Place all the styles related to the favorite controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
# include AppliesHelper
end
class AppliesController < ApplicationController
before_action :redirect_to_root, unless: :logged_in?, only: :create
def new
@user_apply = Apply.new(session[:apply] || {})
end
def create
@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
redirect_to confirm_apply_path
else
render 'new'
end
end
def confirm_apply
@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 redirect_to_root
redirect_to root_path
end
def user_apply_job
params.require(:apply).permit(:email, :name)
end
end
......@@ -45,6 +45,12 @@ class UsersController < ApplicationController
send_file downloadFile.file.file
end
def my_jobs
@user = current_user
@job = @user.applies
@job_pages= ::Kaminari.paginate_array(@user.applies).page(params[:page]).per(20)
end
private
def user_params
......
module AppliesHelper
# def apply_job(user_apply)
# apply[:user_apply_id] = user_apply.id
# binding.pry
# end
# def current_apply_job
# @current_apply_job ||= Apply.find_by(id: apply[:user_apply_id])
# end
# def applied_job?
# !current_apply_job.job_id.nil?
# end
end
module SessionsHelper
module SessionsHelper
def log_in(user)
session[:user_id] = user.id
end
......
......@@ -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},
format: {with: VALID_EMAIL_REGEX}
end
......@@ -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}
......@@ -50,6 +53,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
......
class CvUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
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:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process resize_to_fit: [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_whitelist
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end
<%= provide(:title, "Confirmation") %>
<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">
<!--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 %>
<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 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>
<!--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>
</div>
<!--set field cv -->
<div class="col-md-10 ">
<%= current_user.cv %>
</div>
<!--set field cv -->
</div>
<!--end field cv -->
<!--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 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
<%= 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(@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 class="text-danger"><%= f.label :name, "Full Name", class: 'form-label' %></i></strong>
</div>
<!--set field password -->
<div class="col-md-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<%= f.text_field :name, class: 'form-control' %>
</div>
</div>
<!--end set field password -->
<!--set field email -->
<div class="col-md-2">
<strong><i class="text-danger"><%= f.label :email %></i></strong>
</div>
<!--set field email -->
<div class="col-md-10">
<div class="input-group">
<span class="input-group-addon mb-5"><i class="fa fa-envelope" aria-hidden="true"></i></span>
<%= f.email_field :email, class: 'form-control mb-5' %>
</div>
</div>
<!--end field email -->
<div class="col-md-2">
<strong><i class="text-danger">My CV</i></strong>
</div>
<% 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">
<%= button_tag(type: "submit", class: "btn btn-danger btn-block") do %>
<i class="fa fa-check 4px"></i> Confirm
<% end %>
</div>
</div>
<!--end set button -->
<% end %>
</div>
</div>
<div class="container mt-5" >
<div class="row mb-5">
<div class="search_list titlejob col-md-10">
<%= link_to job['job_name'].join(','), job_detail_path(job['job_id']), class: 'search_list_jobs_title' %>
<% unless job['short_description'].nil? %>
<li class="detail_description">
......@@ -23,7 +22,9 @@
</div>
<div class="col-md-2 mt-2">
<%= link_to 'Favorite', '#', { class: 'btn btn-success'} %>
<%= link_to '',class: 'btn btn-success' do %>
<i class="fa fa-heartbeat"></i> Favorite
<% end %>
</div>
</div>
......
......@@ -6,7 +6,14 @@
<%= 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' } %>
<%= link_to 'Apply','#', {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 %>
</div>
</div>
......@@ -21,8 +28,7 @@
<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) %>
<a class="btn btn-success text-white w-25">Apply</a>
<a class="btn btn-success text-white w-25">Favorite</a>
<a class="btn btn-success text-white w-25" href ="<%= form_apply_path(id: @job.id)%>">Apply</a>
</div>
</div>
</div>
......
......@@ -2,7 +2,9 @@
<%= form_tag job_index_path, method: :get do %>
<div class="row search_field mt-5">
<%= search_field_tag 's', nil, placeholder: 'Search...', class: 'col-10 form-control' %>
<%= submit_tag 'Search',id: "search_button", class: 'col-1 btn btn-success form-control ml-3 ' %>
<%= button_tag(type: "submit", class: "col-1 btn btn-success form-control ml-3", id: "search_button") do %>
<i class="fa fa-search"> Search</i>
<% end %>
</div>
<% end %>
......
......@@ -27,7 +27,7 @@
</div>
<!--Footer Links-->
<div class="container mt-5 mb-4 text-center text-md-left">
<div class="container mt-5 mb-4 text-center text-md-left font_footer">
<div class="row mt-3">
<!--First column-->
<div class="col-md-3 col-lg-4 col-xl-3 mb-r dark-grey-text">
......
<div class="row">
<div class="col">
<a class="navbar-brand" href="http://zigexn.vn">
<a class="navbar-brand" href="<%= root_path %>">
<%= image_tag("logo.png", class: "navbar-brand", id: "logo") %>
</a>
</div>
......@@ -43,6 +43,12 @@
<i class="fa fa-user-circle-o"></i> Register
<% end %>
</li>
<% else %>
<li>
<%= link_to my_page_path(@current_user.id), class: 'btn btn-info distance mt-4 no-gutters' do %>
<i class="fa fa-home"></i> My Page
<% end %>
</li>
<% end %>
<li>
......
<% if @user_apply.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@user_apply.errors.count, "error") %>.
</div>
<ul>
<% @user_apply.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<a href="#">
<a href="<%=job_detail_path(job.id)%>">
<p>
<%= job.job_title %>
</p>
......
<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
<div class="container mt-5" >
<div class="row mb-5 ml-5">
<div class="search_list titlejob col-md-10">
<%= link_to apply.job.job_title,job_detail_path(apply.job.id),class: 'search_list_jobs_title' %>
<% if apply.job.short_description.present? %>
<li class="detail_description">
<%= truncate apply.job.short_description,length: 250 %>
<%= link_to 'read more',job_detail_path(apply.job.id)%></li>
</li>
<% end %>
<div class="row ml-0">
<li class="detail_description col-md-5">
<%= apply.job.cities.map(&:location).join(',') %>
</li>
<% if apply.job.salary.present? %>
<li class=" detail_description float-right text-success col-md-5">
<%= apply.job.salary%>
</li>
<% end -%>
</div>
</div>
</div>
</div>
\ No newline at end of file
<%= provide(:title,"Applied jobs")%>
<h1 class="text-center mt-5 text-danger">Applied Jobs</h1>
<div class="mt-4">
<%= paginate @job_pages,theme: 'twitter-bootstrap-4'%>
<%= render partial: "my_jobs",collection: @job, as: :apply %>
<%= paginate @job_pages,theme: 'twitter-bootstrap-4'%>
</div>
\ No newline at end of file
......@@ -53,13 +53,15 @@
<!--set button update -->
<div class="row ml-5 pb-5 pl-5">
<div class="col-md-4 text-center ">
<%= link_to 'Update', edit_user_path, { class: 'btn btn-success' } %>
<%= link_to edit_user_path,class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Update
<% end %>
</div>
<!--end set button update -->
<!--set button download -->
<div class="col-md-3">
<%= link_to 'My Jobs','#',{class: 'btn btn-success'}%>
<%= link_to my_jobs_path(@user.id),class: 'btn btn-danger' do %>
<i class="fa fa-list-ol"></i> MyJobs
<% end %>
</div>
</div>
<!--end set button download -->
......
......@@ -14,6 +14,7 @@ module VenJob
config.active_job.queue_adapter = :sidekiq
require 'carrierwave'
require 'carrierwave/orm/activerecord'
config.time_zone = 'Hanoi'
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
......
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
html_tag
end
......@@ -19,15 +19,21 @@ 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
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply
post 'apply/job/:id',controller: :applies,action: :create,as: :new_info
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 CreateApplies < ActiveRecord::Migration[5.1]
def change
create_table :applies do |t|
t.string :name
t.string :email
t.timestamps
end
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
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170927013828) do
ActiveRecord::Schema.define(version: 20171004020516) do
create_table "add_cv_to_users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "cv"
......@@ -18,6 +18,15 @@ ActiveRecord::Schema.define(version: 20170927013828) do
t.datetime "updated_at", null: false
end
create_table "applies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "job_id"
t.integer "user_id"
end
create_table "cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "location"
t.datetime "created_at", null: false
......@@ -85,6 +94,11 @@ ActiveRecord::Schema.define(version: 20170927013828) do
t.datetime "updated_at", null: false
t.string "password_digest"
t.string "cv"
t.string "reset_digest"
t.datetime "reset_sent_at"
t.string "activation_digest"
t.boolean "activated"
t.datetime "activated_at"
end
end
require 'test_helper'
class AppliesControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
email: MyString
two:
name: MyString
email: MyString
require 'test_helper'
class ApplyTest < 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