diff options
Diffstat (limited to 'app')
-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 |
5 files changed, 46 insertions, 2 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> + |