Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step9 #169

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Step9 #169

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9d57977
add bootstrap to project
valery0510 Oct 17, 2016
0d6c969
add bootstrap flash function
valery0510 Oct 17, 2016
9f6b53d
add bootstrap flash function and layout
valery0510 Oct 17, 2016
1c558a9
add bootstrap html
valery0510 Oct 17, 2016
961318f
hw day1
valery0510 Oct 17, 2016
5a2a3b1
create jobs index
valery0510 Oct 18, 2016
fa508d4
replace root with jobs#index
valery0510 Oct 18, 2016
3199925
implement groups#new
valery0510 Oct 18, 2016
e6d52b9
implement jobs#create
valery0510 Oct 18, 2016
c9862a4
implement jobs#edit
valery0510 Oct 18, 2016
d47d5b8
implement jobs#update
valery0510 Oct 18, 2016
9757038
implement jobs#destroy
valery0510 Oct 18, 2016
25b62ea
user can login/logout/signup
valery0510 Oct 18, 2016
6e68594
add user_id to group
valery0510 Oct 18, 2016
17d05aa
show job's creator info
valery0510 Oct 18, 2016
238c1a0
peopel can't see edit button unless he is job ownerz'
valery0510 Oct 18, 2016
7a0c414
add validation to title
valery0510 Oct 18, 2016
6d7cb39
add validation to title apply to edit/update
valery0510 Oct 18, 2016
83d5835
implement part 2
valery0510 Oct 18, 2016
c52eebf
fiexed part 2
valery0510 Oct 19, 2016
a61ddc8
more modifications
valery0510 Oct 19, 2016
d133487
modifications that should have been made yesterday
valery0510 Oct 19, 2016
4064cd1
implement step 3
valery0510 Oct 19, 2016
9a5de1c
implement step 4
valery0510 Oct 19, 2016
988dadd
minor modification
valery0510 Oct 20, 2016
907bc20
implement step 5
valery0510 Oct 20, 2016
82c7aa2
implement order
valery0510 Oct 24, 2016
ea388a3
add resume and hook job/user relation
valery0510 Oct 24, 2016
9950e60
add resumes nested route
valery0510 Oct 24, 2016
c28eb9e
add resume button
valery0510 Oct 24, 2016
2e04078
implement resume create function
valery0510 Oct 24, 2016
95cfcce
add order by created_at to job's resume
valery0510 Oct 24, 2016
fc56c42
using scope to write order by created_at to job's resume
valery0510 Oct 24, 2016
adda2b3
added carrierwave
valery0510 Oct 24, 2016
9bc08a7
implement resume upload
valery0510 Oct 24, 2016
e5148ac
admin can see resume list
valery0510 Oct 25, 2016
fe24637
add user sidebar, enable king&nobody as in is_admin
valery0510 Oct 26, 2016
8c8acb5
add user authority
valery0510 Oct 28, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
source 'https://gems.ruby-china.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
Expand Down Expand Up @@ -35,6 +35,13 @@ group :development, :test do
gem 'byebug', platform: :mri
end

gem 'bootstrap-sass'
gem 'simple_form'
gem 'devise'
gem "font-awesome-rails"
gem 'carrierwave'
gem 'annotate'

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
Expand Down
43 changes: 41 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEM
remote: https://rubygems.org/
remote: https://gems.ruby-china.org/
specs:
actioncable (5.0.0)
actionpack (= 5.0.0)
Expand Down Expand Up @@ -38,9 +38,24 @@ GEM
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
annotate (2.7.1)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
arel (7.1.0)
autoprefixer-rails (6.5.0.1)
execjs
bcrypt (3.1.11)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.2)
byebug (9.0.5)
carrierwave (0.11.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
mimemagic (>= 0.3.0)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
Expand All @@ -50,9 +65,17 @@ GEM
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
devise (4.2.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
responders
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.14)
font-awesome-rails (4.6.3.1)
railties (>= 3.2, < 5.1)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
Expand All @@ -63,6 +86,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -74,13 +98,15 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
orm_adapter (0.5.0)
pkg-config (1.1.7)
puma (3.5.2)
rack (2.0.1)
Expand Down Expand Up @@ -113,13 +139,18 @@ GEM
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
sass (3.4.22)
sass-rails (5.0.5)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
simple_form (3.3.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
spring (1.7.2)
spring-watcher-listen (2.0.0)
listen (>= 2.7, < 4.0)
Expand All @@ -142,6 +173,8 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
warden (1.2.6)
rack (>= 1.0)
web-console (3.3.1)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand All @@ -155,14 +188,20 @@ PLATFORMS
ruby

DEPENDENCIES
annotate
bootstrap-sass
byebug
carrierwave
coffee-rails (~> 4.2)
devise
font-awesome-rails
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)
puma (~> 3.0)
rails (~> 5.0.0)
sass-rails (~> 5.0)
simple_form
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
Expand All @@ -172,4 +211,4 @@ DEPENDENCIES
web-console

BUNDLED WITH
1.12.5
1.13.1
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/jobs.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/resumes.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/users.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap/alert
//= require bootstrap/dropdown
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/jobs.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/resumes.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/welcome.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/jobs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin::jobs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/resumes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin::resumes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin::users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
*
*= require_tree .
*= require_self
*= require font-awesome
*/

@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome";
3 changes: 3 additions & 0 deletions app/assets/stylesheets/jobs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the jobs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 4 additions & 0 deletions app/assets/stylesheets/resumes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Place all the styles related to the resumes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import "bootstrap";
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/welcome.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the welcome controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
77 changes: 77 additions & 0 deletions app/controllers/admin/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class Admin::JobsController < ApplicationController
before_filter :authenticate_user!, only: [:new, :create, :update, :edit, :destroy]
before_filter :require_is_admin
layout "admin"

def require_is_admin
if !current_user.admin?
flash[:alert] = 'You are not admin 🙃'
redirect_to root_path
end
end

def show
@job = Job.find(params[:id])
end

def index
@jobs = Job.all.order("created_at DESC")
end

def new
@job = Job.new
end

def create
@job = Job.new(job_params)

if @job.save!
redirect_to admin_jobs_path
else
render :new
end
end

def edit
@job = Job.find(params[:id])
end

def update
@job = Job.find(params[:id])
if @job.update(job_params)
redirect_to admin_jobs_path
else
render :edit
end
end

def destroy
@job = Job.find(params[:id])

@job.destroy

redirect_to admin_jobs_path
end

def publish
@job = Job.find(params[:id])
@job.publish!

redirect_to :back
end

def hide
@job = Job.find(params[:id])

@job.hide!

redirect_to :back
end

private

def job_params
params.require(:job).permit(:title, :description, :wage_upper_bound, :wage_lower_bound, :contact_email,:is_hidden)
end

end
12 changes: 12 additions & 0 deletions app/controllers/admin/resumes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Admin::ResumesController < ApplicationController
before_filter :authenticate_user!
before_filter :require_is_admin
layout "admin"

def index
@job = Job.find(params[:job_id])
@resumes = @job.resumes.recent
end


end
23 changes: 23 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Admin::UsersController < ApplicationController

layout "admin"

def index
@users = User.all_except(current_user)
end

def king
@user = User.find(params[:id])
@user.is_admin = true
@user.save
redirect_to :back
end

def nobody
@user = User.find(params[:id])
@user.is_admin = false
@user.save
redirect_to :back
end

end
4 changes: 4 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class AdminController < ApplicationController
def jobs
end
end
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

def require_is_admin
if !current_user.admin?
flash[:alert] = 'You are not admin 🙃'
redirect_to root_path
end
end
end
Loading