Commit fda07d77 by Xuan Trung Le

fix bugs

parent fe7cebed
......@@ -12,35 +12,15 @@
//
//= require rails-ujs
//= require_tree .
//= require jquery-3.2.1.min.js
//= require bootstrap.min.js
//= require javascripts/jquery-3.2.1.min.js
//= require javascripts/bootstrap.min.js
//= require javascripts/bootstrap.min.js
//= require bootstrap-datetimepicker.min.js
$(document).ready(function(){
// this function to hide message after 5s
$('.message').delay(5000).fadeOut('slow');
<<<<<<< a6a6bfc98ed7e35fb9415714f7cf725ec5a0b69a
$(document).on('change', 'input[name=job_id]', function(event) {
event.preventDefault();
$('#apply').removeAttr('disabled')
=======
// this function to select date
$('.form_date').datetimepicker({
language: 'en',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0
>>>>>>> fix bugs
});
// set min-height css for content
windowHeight = $(document).height();
menuHeight = $('.navbar').height();
footHeight = $('.footer').height();
$('.content').css("min-height", windowHeight - (menuHeight + footHeight))
});
require 'rsolr'
require "csv"
require 'uri'
class Admins::AppliesController < ApplicationController
def index
@cities = City.pluck(:id, :name)
if params[:commit]
# get condition here
condition = get_condition
......@@ -13,18 +13,16 @@ class Admins::AppliesController < ApplicationController
@applications = ApplyJob.where(job_id: job_id).includes(:job, :user)
if params[:commit].eql? 'Down csv'
flash[:notice] = 'Down csv'
down_csv(@applications)
return
end
else
# get applications
@applications = ApplyJob.includes(:job, :user)
end
puts params[:commit]
end
def down_csv(applications)
# handle data
data_csv = []
applications.each do |application|
......@@ -36,19 +34,8 @@ class Admins::AppliesController < ApplicationController
candidate[:applied_at] = application.created_at
data_csv << candidate
end
# create new csv file
CSV.open("file.csv", "wb") do |csv|
# write header
csv << data_csv.first.keys
# write values
data_csv.each_with_index do |data, i|
csv << data.values
end
end
# down file.csv into local
send_file "#{Rails.root}/file.csv", type: 'application/csv'
column_names = data_csv.first.keys
send_data ApplyJob.to_csv(column_names, data_csv), filename: "applications-#{Date.today}.csv"
end
private
......@@ -61,7 +48,7 @@ class Admins::AppliesController < ApplicationController
# Direct connection
connect
# use get method to query
response = @solr.get 'select', :params => condition
response = @solr.get 'select', params: condition
response
end
......
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :clear_session_candidate, :admin_can_not_do_this
def clear_session_candidate
session[:candidate] = {}
......
......@@ -4,10 +4,7 @@ class ApplyJob < ApplicationRecord
validates_size_of :cv, maximum: 5.megabytes, message: 'size should be less than 5MB'
validates :email, presence: true
validates :name, presence: true
<<<<<<< 132d97c26c67214fbdb21f17fdf70e66ae6c833b
# CarrierWave
mount_uploader :cv, CvUploader
=======
>>>>>>> fig bugs
end
<% @applications.each do |application| %>
<% applications.each do |application| %>
<div class="job-intro well mr0 mrBot20">
<h4 class="mr0"><%= link_to application.job.name, job_path(application.job) %></h4>
<p><%= "Candidate Name: #{application.user.name}" %></p>
......
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