Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Admin nav and admin users view.

  • Loading branch information...
commit 501cb074b6d566af010e5151de9458f9a6cadbc4 1 parent bb7a6f4
davertron authored March 13, 2012
1  Gemfile
@@ -12,6 +12,7 @@ gem 'bson_ext', '>= 1.5.2'
12 12
 
13 13
 gem 'sorcery'
14 14
 
  15
+gem 'will_paginate', '~> 3.0'
15 16
 
16 17
 # Gems used only for assets and not required
17 18
 # in production environments by default.
2  Gemfile.lock
@@ -133,6 +133,7 @@ GEM
133 133
     uglifier (1.2.3)
134 134
       execjs (>= 0.3.0)
135 135
       multi_json (>= 1.0.2)
  136
+    will_paginate (3.0.3)
136 137
 
137 138
 PLATFORMS
138 139
   ruby
@@ -148,3 +149,4 @@ DEPENDENCIES
148 149
   sqlite3
149 150
   turn
150 151
   uglifier
  152
+  will_paginate (~> 3.0)
3  app/assets/javascripts/admin/users.js.coffee
... ...
@@ -0,0 +1,3 @@
  1
+# Place all the behaviors and hooks related to the matching controller here.
  2
+# All this logic will automatically be available in application.js.
  3
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3  app/assets/stylesheets/admin/users.css.scss
... ...
@@ -0,0 +1,3 @@
  1
+// Place all the styles related to the Admin::Users controller here.
  2
+// They will automatically be included in application.css.
  3
+// You can use Sass (SCSS) here: http://sass-lang.com/
2  app/assets/stylesheets/landing.css.scss
@@ -70,7 +70,7 @@ $img_width: 924px;
70 70
   }
71 71
 }
72 72
 
73  
-.nav {
  73
+.landing-nav {
74 74
   padding: 10px 40px;
75 75
 
76 76
   .links {
7  app/controllers/admin/users_controller.rb
... ...
@@ -0,0 +1,7 @@
  1
+class Admin::UsersController < ApplicationController
  2
+  before_filter :requires_admin
  3
+
  4
+  def index
  5
+    @users = User.paginate(:page => params[:page])
  6
+  end
  7
+end
2  app/helpers/admin/users_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module Admin::UsersHelper
  2
+end
20  app/views/admin/users/index.html.erb
... ...
@@ -0,0 +1,20 @@
  1
+<table class="table table-striped">
  2
+  <thead>
  3
+    <tr>
  4
+      <th>Username</th>
  5
+      <th>E-mail</th>
  6
+      <th>Admin</th>
  7
+    </tr>
  8
+  </thead>
  9
+  <tbody>
  10
+    <% @users.each do |u| %>
  11
+      <tr>
  12
+        <td><%= u.username %></td>
  13
+        <td><%= u.email %></td>
  14
+        <td><%= u.is_admin %></td>
  15
+      </tr>
  16
+    <% end %>
  17
+  </tbody>
  18
+</table>
  19
+
  20
+<%= will_paginate @users %>
20  app/views/layouts/application.html.erb
@@ -4,7 +4,7 @@
4 4
     <title>SimpleTask</title>
5 5
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 6
     <link rel="shortcut icon" href="/favicon.ico" />
7  
-    
  7
+
8 8
     <%= stylesheet_link_tag    "application" %>
9 9
     <%= javascript_include_tag "application" %>
10 10
     <%= csrf_meta_tags %>
@@ -14,6 +14,24 @@
14 14
       <div class="navbar-inner">
15 15
         <div class="container">
16 16
           <a href="/" class="brand"><i class="icon-list-alt"></i>SimpleTask</a>
  17
+          <% if current_user and current_user.is_admin %>
  18
+            <div class="nav-collapse">
  19
+              <ul class="nav">
  20
+                <li><%= link_to 'Tasks', tasks_path %></li>
  21
+                <li class="dropdown">
  22
+                  <a href="#" class="dropdown-toggle">Admin<b class="caret"></b></a>
  23
+                  <ul class="dropdown-menu">
  24
+                    <li>
  25
+                      <%= link_to 'Dashboard', admin_dashboard_index_path %>
  26
+                    </li>
  27
+                    <li>
  28
+                      <%= link_to 'Users', admin_users_path %>
  29
+                    </li>
  30
+                  </ul>
  31
+                </li>
  32
+              </ul>
  33
+            </div>
  34
+          <% end %>
17 35
           <div class="user-info">
18 36
             <% if current_user %>
19 37
               <%= link_to current_user.username, edit_user_path(current_user.id) %> |
2  app/views/layouts/landing.html.erb
@@ -9,7 +9,7 @@
9 9
     <%= csrf_meta_tags %>
10 10
   </head>
11 11
   <body>
12  
-    <div class="nav">
  12
+    <div class="landing-nav">
13 13
       <div class="links">
14 14
         <%= link_to 'Register', :register %> |
15 15
         <%= link_to 'Login', :login %>
1  config/routes.rb
@@ -19,6 +19,7 @@
19 19
 
20 20
   namespace :admin do
21 21
     resources :dashboard
  22
+    resources :users
22 23
   end
23 24
   # The priority is based upon order of creation:
24 25
   # first created -> highest priority.
7  test/functional/admin/users_controller_test.rb
... ...
@@ -0,0 +1,7 @@
  1
+require 'test_helper'
  2
+
  3
+class Admin::UsersControllerTest < ActionController::TestCase
  4
+  # test "the truth" do
  5
+  #   assert true
  6
+  # end
  7
+end
4  test/unit/helpers/admin/users_helper_test.rb
... ...
@@ -0,0 +1,4 @@
  1
+require 'test_helper'
  2
+
  3
+class Admin::UsersHelperTest < ActionView::TestCase
  4
+end

0 notes on commit 501cb07

Please sign in to comment.
Something went wrong with that request. Please try again.