diff options
-rw-r--r-- | app/controllers/application.rb | 7 | ||||
-rw-r--r-- | app/controllers/list_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/new_controller.rb | 3 | ||||
-rw-r--r-- | app/helpers/list_helper.rb | 2 | ||||
-rw-r--r-- | app/views/list/index.rhtml | 21 | ||||
-rw-r--r-- | config/routes.rb | 5 | ||||
-rw-r--r-- | test/functional/list_controller_test.rb | 18 |
7 files changed, 67 insertions, 4 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index a230262cd..f681b46c8 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application.rb,v 1.9 2007-10-03 20:01:45 louise Exp $ +# $Id: application.rb,v 1.10 2007-10-08 15:16:22 francis Exp $ class ApplicationController < ActionController::Base @@ -82,6 +82,11 @@ class ApplicationController < ActionController::Base return true end + # Return logged in user + def authenticated_user + return User.find(session[:user]) + end + # For redirects to POST requests before_filter :post_redirect def post_redirect diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb new file mode 100644 index 000000000..16a0d0695 --- /dev/null +++ b/app/controllers/list_controller.rb @@ -0,0 +1,15 @@ +# app/controllers/list_controller.rb: +# Show all of the FOI requests in the system. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: list_controller.rb,v 1.1 2007-10-08 15:16:22 francis Exp $ + + +class ListController < ApplicationController + + def index + @info_request_pages, @info_requests = paginate :info_requests, :per_page => 25 + end +end diff --git a/app/controllers/new_controller.rb b/app/controllers/new_controller.rb index 1952ace06..175393502 100644 --- a/app/controllers/new_controller.rb +++ b/app/controllers/new_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: new_controller.rb,v 1.1 2007-10-08 14:58:27 francis Exp $ +# $Id: new_controller.rb,v 1.2 2007-10-08 15:16:22 francis Exp $ class NewController < ApplicationController def index @@ -25,6 +25,7 @@ class NewController < ApplicationController if not @info_request.valid? render :action => 'index' elsif check_authentication + @info_request.user = authenticated_user @info_request.save end diff --git a/app/helpers/list_helper.rb b/app/helpers/list_helper.rb new file mode 100644 index 000000000..eaa1d0e15 --- /dev/null +++ b/app/helpers/list_helper.rb @@ -0,0 +1,2 @@ +module ListHelper +end diff --git a/app/views/list/index.rhtml b/app/views/list/index.rhtml new file mode 100644 index 000000000..6ec13b488 --- /dev/null +++ b/app/views/list/index.rhtml @@ -0,0 +1,21 @@ + + +<h1>All FOI requests</h1> + +<table> + <tr> + <th>Title</th> + <th>Requester</th> + <th>Created</th> + + </tr> + +<% for info_request in @info_requests %> + <tr class="<%= cycle('odd', 'even') %>"> + <td><%= link_to info_request.title, :action => 'show', :id => info_request %></td> + <td><%= info_request.user.name %></td> + <td><%= info_request.created_at %></td> + </tr> +<% end %> +</table> + diff --git a/config/routes.rb b/config/routes.rb index cb0ad52ec..034aba48a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: routes.rb,v 1.7 2007-10-08 14:58:28 francis Exp $ +# $Id: routes.rb,v 1.8 2007-10-08 15:16:23 francis Exp $ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. @@ -13,11 +13,12 @@ ActionController::Routing::Routes.draw do |map| # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action map.connect "/new/:action", :controller => 'new', :action => 'index' + map.connect "/list/:action", :controller => 'list', :action => 'index' map.connect '/admin/:action', :controller => 'admin', :action => 'index' map.connect '/admin/body/:action/:id', :controller => 'admin_public_body' - map.connect "/:action/:id", :controller => 'frontpage' + map.connect "/:action/:id", :controller => 'index' # Sample of named route: # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' diff --git a/test/functional/list_controller_test.rb b/test/functional/list_controller_test.rb new file mode 100644 index 000000000..d347f44cb --- /dev/null +++ b/test/functional/list_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'list_controller' + +# Re-raise errors caught by the controller. +class ListController; def rescue_action(e) raise e end; end + +class ListControllerTest < Test::Unit::TestCase + def setup + @controller = ListController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end |