Commit c4212b67 by Đường Sỹ Hoàng

First commit

parent 79a857e7
......@@ -60,10 +60,15 @@ GEM
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
autoprefixer-rails (9.7.3)
execjs
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
msgpack (~> 1.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
byebug (11.0.1)
capybara (3.29.0)
......@@ -124,6 +129,7 @@ GEM
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
erubi (1.9.0)
execjs (2.7.0)
ffi (1.11.3)
globalid (0.4.2)
activesupport (>= 4.2.0)
......@@ -219,6 +225,11 @@ GEM
ruby_dep (1.5.0)
rubysl-open-uri (2.0.0)
rubyzip (2.0.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.2.1)
......@@ -285,6 +296,7 @@ PLATFORMS
DEPENDENCIES
activerecord-import
bootsnap (>= 1.4.2)
bootstrap-sass (= 3.3.7)
byebug
capybara (>= 2.15)
config
......
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link application.js
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,4 +12,5 @@
*
*= require_tree .
*= require_self
*= require bootstrap
*/
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/* universal */
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.center {
text-align: center;
background-color:gainsboro;
margin-left:260px;
}
/* typography */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: #777;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
/* header */
#logo {
float: left;
width: 50%;
}
#logo:hover {
color: #fff;
text-decoration: none;
}
#banner {
width: 100%;
padding: 0px;
}
.inverse {
overflow: hidden;
background-color: gray;
}
ul {
float: right;
list-style: none;
list-style-type: none;
margin: 0;
padding: 0;
width: 100px;
background-color: whitesmoke;
}
li {
float: left;
color: black;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
}
li.btn-navbar {
display: block;
padding: 10px 10px;
}
li.btn-navbar:hover {
background-color: mediumblue;
text-decoration: none;
text-align: center;
}
.Job {
display: block;
background-color: lightblue;
}
class JobsController < ApplicationController
def index
@jobs = Job.all
end
end
module JobsHelper
end
class Job < ApplicationRecord
has_many :user_jobs
has_many :city_jobs
scope :latest_job, -> {order(created_at: :desc).limit 5}
end
<div class="center jumbotron">
<head>
<title><%= yield(:title) %> Venjob</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<!--List of latest jobs-->
<div class="Job list">
<div class="Job-title-wrapper">
<h3>Latest</h3>
</div>
<div class="Job-content-wrapper">
<% @jobs.latest_job.each do |job| %>
<div class="Job content info">
<h4><%= job.title %></h4>
</div>
<% end %>
</div>
</div>
<!--List of top cities-->
<div class="City list">
<div class="City-title-wrapper">
<h3>City
</div>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<title>VenJob</title>
<title><%= yield(:title) %>Venjob</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<%= link_to image_tag("zigexn_logo.png", id: "logo", alt: "Venjob logo") %>
<nav>
<ul>
<li class="btn-navbar"><%=link_to "Login", '#' %></li>
<li class="btn-navbar"><%=link_to "Register", '#' %></li>
</ul>
<ul>
<ul>
<li class="btn-navbar"><%=link_to "Favorite", '#' %></li>
<li class="btn-navbar"><%=link_to "History", '#' %></li>
</ul>
</nav>
<%= link_to image_tag("banner.jpg", id: "banner", alt: "Venjob banner") %>
</div>
<div class="container">
<%= yield %>
</div>
</header>
</body>
</html>
Rails.application.routes.draw do
root to: "jobs#index"
get 'jobs/index'
devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resource :jobs do
collection {post :import}
end
end
require "csv"
namespace :job do
namespace :job do
desc "Import CSV file into database"
task import_csv: :environment do
csv_file = Settings.import_job.csv_file
......@@ -8,14 +9,12 @@ namespace :job do
company_params = {
email: row["contact email"],
name: row["company name"],
address: row["company address"],
code: row["company id"]
address: row["company address"]
}
company = Company.find_or_initialize_by(code: row["company id"])
company.update(company_params)
job_params = {
title: row["name"],
description: row["description"],
position: row["level"],
salary: row["salary"],
......@@ -23,10 +22,21 @@ namespace :job do
}
job = Job.find_or_initialize_by(title: row["name"], company_id: company.id)
job.update(job_params)
city_params = {
region: row["company province"]
}
city = City.find_or_initialize_by(name: row["work place"])
city.update(city_params)
city_job_params = {
city_id: city.id
}
city_job = CityJob.find_or_initialize_by(job_id: job.id)
city_job.update(city_job_params)
rescue
import_logger = ActiveSupport::Logger.new("log/import.log")
import_logger.error "Skip #{row}"
next
end
end
end
end
require 'test_helper'
class JobsControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get jobs_index_url
assert_response :success
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