Skip to content

Commit

Permalink
#17 Admin home student list added.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhanoguzhan committed Aug 29, 2013
1 parent ff249c6 commit 0b7586a
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 24 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gem 'bootstrap-sass', :git => 'git://github.com/thomas-mcdonald/bootstrap-sass.g
gem 'simple_form', "3.0.0.rc"
gem 'country_select'
gem "datagrid", :git => "git://github.com/bogdan/datagrid.git"
gem 'will_paginate', '~> 3.0'

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ GEM
multi_json (~> 1.0, >= 1.0.2)
warden (1.2.3)
rack (>= 1.0)
will_paginate (3.0.4)

PLATFORMS
ruby
Expand All @@ -159,3 +160,4 @@ DEPENDENCIES
sqlite3
turbolinks
uglifier (>= 1.3.0)
will_paginate (~> 3.0)
4 changes: 2 additions & 2 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def index
end

def admin
@report_user = Report::Campaign.new(params[:report_user])
@assets = @report_user.assets.page(params[:page])
@grid = Grids::UsersGrid.new(params[:grid])
@assets = @grid.assets.paginate(:page => params[:page])
end

def user
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update



redirect_to users_path
redirect_to home_index_path


end
Expand Down
17 changes: 0 additions & 17 deletions app/grids/users_grid.rb

This file was deleted.

5 changes: 5 additions & 0 deletions app/models/grids.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Grids
def self.table_name_prefix
'grids_'
end
end
23 changes: 23 additions & 0 deletions app/models/grids/users_grid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Grids::UsersGrid

include Datagrid

scope do
::User.includes(:profile)
end

filter(:id, :integer)
filter(:email, :string)
filter(:created_at, :date, :range => true)

column(:id)
column(:email, :header => "Name") do
self.profile.name
end
column(:email, :header => "Surname") do
self.profile.surname
end
column(:created_at) do |model|
model.created_at.to_date
end
end
3 changes: 0 additions & 3 deletions app/views/home/admin.html.erb

This file was deleted.

7 changes: 7 additions & 0 deletions app/views/home/admin.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.page-header
.h1
Admin Home

%div== Total #{@assets.total_entries}
= datagrid_table(@grid, @assets, :html => {:class => "table table-hover"})
= will_paginate @assets
Empty file removed app/views/users/index.html.erb
Empty file.
3 changes: 3 additions & 0 deletions app/views/users/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%div== Total #{assets.total_entries}
= datagrid_table(@grid, @assets)
= will_paginate assets
Empty file removed app/views/users/show.html.erb
Empty file.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LesEtoiles::Application.routes.draw do
get "home/index"
get "home/index", to: "home#index", as: "home_index"

devise_for :admins
devise_for :teachers
Expand Down

0 comments on commit 0b7586a

Please sign in to comment.