diff options
-rw-r--r-- | app/controllers/body_controller.rb | 18 | ||||
-rw-r--r-- | app/helpers/body_helper.rb | 2 | ||||
-rw-r--r-- | app/views/body/index.rhtml | 2 | ||||
-rw-r--r-- | app/views/body/show.rhtml | 11 | ||||
-rw-r--r-- | app/views/index/index.rhtml | 21 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 15 | ||||
-rw-r--r-- | app/views/list/index.rhtml | 7 | ||||
-rw-r--r-- | app/views/new/index.rhtml | 55 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | public/stylesheets/main.css | 186 | ||||
-rw-r--r-- | test/functional/body_controller_test.rb | 18 | ||||
-rw-r--r-- | todo.txt | 13 |
12 files changed, 239 insertions, 112 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb new file mode 100644 index 000000000..2027e13a1 --- /dev/null +++ b/app/controllers/body_controller.rb @@ -0,0 +1,18 @@ +# app/controllers/body_controller.rb: +# Show information about a public body. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: body_controller.rb,v 1.1 2007-10-11 22:01:36 francis Exp $ + +class BodyController < ApplicationController + def show + @public_bodies = PublicBody.find(:all, :conditions => [ "short_name = ?", params[:short_name] ]) + if @public_bodies.size > 1 + raise "Two bodies with the same short name: " . params[:short_name] + end + @public_body = @public_bodies[0] + end + +end diff --git a/app/helpers/body_helper.rb b/app/helpers/body_helper.rb new file mode 100644 index 000000000..55c49196a --- /dev/null +++ b/app/helpers/body_helper.rb @@ -0,0 +1,2 @@ +module BodyHelper +end diff --git a/app/views/body/index.rhtml b/app/views/body/index.rhtml new file mode 100644 index 000000000..646269bf7 --- /dev/null +++ b/app/views/body/index.rhtml @@ -0,0 +1,2 @@ +<h1>Body#index</h1> +<p>Find me in app/views/body/index.rhtml</p> diff --git a/app/views/body/show.rhtml b/app/views/body/show.rhtml new file mode 100644 index 000000000..f454a8b4d --- /dev/null +++ b/app/views/body/show.rhtml @@ -0,0 +1,11 @@ +<% @title = h(@public_body.name) + " (" + h(@public_body.short_name) + ")" %> + +<h2><%=@title%></h2> + +<p>Freedom of Information requests made to this body:</p> +<ul> +<% for info_request in @public_body.info_requests %> +<li><%= link_to h(info_request.title), :controller => 'request', :action => 'index', :id => info_request %></li> +<% end %> +</ul> + diff --git a/app/views/index/index.rhtml b/app/views/index/index.rhtml index 65ba3a2e8..f44aa95b3 100644 --- a/app/views/index/index.rhtml +++ b/app/views/index/index.rhtml @@ -1,5 +1,20 @@ +<div id="frontpage"> -<p id="explanation">Make requests for information from the UK Government -<br>Find information that others requested -</p> + <div id="make_requests"> + <h1>Make requests for information from the UK Government</h1> + <% form_for(:info_request, @info_request, :url => { :controller => :new, :action => :index }, :html => { :id => 'public_body_form', :class => 'plaque' } ) do |f| %> + <p>Choose which public body you would like information from.</p> + <%= @public_bodies = PublicBody.find(:all, :order => "name") + f.collection_select(:public_body_id, @public_bodies, :id, :name) %> + <p><%= submit_tag "Submit >>" %></p> + <% end %> + </div> + + <div id="find_information"> + <h1>Find information that others requested</h1> + <p><a href="/list">View all information</a></p> + </div> + + +</div> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 3c7d86ce7..1153ce602 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -6,14 +6,13 @@ <%= stylesheet_link_tag 'main' %> </head> <body> - <h1 id="header"> - <% if controller.controller_name == 'index' and controller.action_name == 'index' %> - Freedom of Information Filer and Archive - <% else %> - <a href="/">Freedom of Information Filer and Archive</a> - <% end %> - <span id="beta">Beta</span> - </h1> + <div id="header"> + <h1> + <a href="/">Government Spy</a> + <span id="beta">Beta</span> + </h1> + <div id="tagline">Freeing your information from them</div> + </div> <ul id="navigation"> <li><a href="/list">All Requests</a></li> <li><a href="/new">New Request</a></li> diff --git a/app/views/list/index.rhtml b/app/views/list/index.rhtml index 60d1ae0ba..47b3bfc55 100644 --- a/app/views/list/index.rhtml +++ b/app/views/list/index.rhtml @@ -1,10 +1,10 @@ -<% @title = "All FOI requests" %> +<% @title = "Recent Freedom of Information requests" %> <h2><%=@title%></h2> -<p> -<table> +<table id="list_requests"> <tr> + <th>Public body</th> <th>Title</th> <th>Requester</th> <th>Created</th> @@ -13,6 +13,7 @@ <% for info_request in @info_requests %> <tr class="<%= cycle('odd', 'even') %>"> + <td><%= link_to h(info_request.public_body.short_name), :controller => 'body', :action => 'show', :short_name => info_request.public_body.short_name %></td> <td><%= link_to h(info_request.title), :controller => 'request', :action => 'index', :id => info_request %></td> <td><%= link_to h(info_request.user.name), :controller => 'user', :action => 'index', :name => info_request.user.name %></td> <td><%= simple_date(info_request.created_at) %></td> diff --git a/app/views/new/index.rhtml b/app/views/new/index.rhtml index 84d0198bc..b513c9a4c 100644 --- a/app/views/new/index.rhtml +++ b/app/views/new/index.rhtml @@ -4,37 +4,42 @@ <% form_for(:info_request, @info_request, :url => { :action => :create }, :html => { :id => 'writeForm' } ) do |f| %> - <h1>New FOI request</h1> + <label for="heading"> </label> + <h1>New Freedom of Information request</h1> - <p><strong>Privacy warning:</strong> All information that you enter, except - for your email address, will be displayed publically on this website.</p> - - <p> + <p> <label for="public_body_id">Public body:</label> - <%= + <%= @public_bodies = PublicBody.find(:all, :order => "name") f.collection_select(:public_body_id, @public_bodies, :id, :name) - %> - </p> - - - <p> - <label for="info_request_title">Summary:</label> - <%= f.text_field :title, :size => 50 %> - <br>(a one line summary of the information you are requesting, e.g. 'Crime statistics by ward level for Wales') - </p> - - <% fields_for :outgoing_message do |o| %> - <p> - <label for="outgoing_message_body">Your letter:</label> + %> + </p> + + + <p> + <label for="info_request_title">Summary:</label> + <%= f.text_field :title, :size => 50 %> + </p> + <div class="form_note"> + (a one line summary of the information you are requesting, + <br>e.g. 'Crime statistics by ward level for Wales') + </div> + + <% fields_for :outgoing_message do |o| %> + <p> + <label for="outgoing_message_body">Your letter:</label> <%= o.text_area :body, :rows => 20, :cols => 60 %> - </p> - <% end %> + </p> + <% end %> + + <p class="form_note"> + <strong>Privacy warning:</strong> All information that you enter, except + for your email address, will be displayed publically on this website. + </p> - <p> - <label for="commit"> </label> - <%= submit_tag "Create request >>" %> - </p> + <div class="form_button"> + <%= submit_tag "Create public request >>" %> + </div> </div> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 84c14e6b9..be9a1f7f3 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.11 2007-10-10 16:06:17 francis Exp $ +# $Id: routes.rb,v 1.12 2007-10-11 22:01:37 francis Exp $ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. @@ -16,6 +16,7 @@ ActionController::Routing::Routes.draw do |map| map.connect "/list/:action", :controller => 'list' map.connect "/request/:id", :controller => 'request', :action => 'index' map.connect "/user/:name", :controller => 'user', :action => 'index' + map.connect "/body/:short_name", :controller => 'body', :action => 'show' map.connect '/admin/:action', :controller => 'admin', :action => 'index' map.connect '/admin/body/:action/:id', :controller => 'admin_public_body' diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index a1943d2a6..d337a45ff 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -24,79 +24,40 @@ a:hover, a:active { color: #ff0000; } -form { - margin: 0; - padding: 1em; - background-color: #97E300; - -moz-border-radius: 1em; - border-radius: 1em; -} - -select, input, textarea { - font-size: 99%; -} - -label { - float: left; - text-align: right; - padding-right: 0.5em; - width: 10em; - margin-bottom: 0.5em; -} - -/* Flashes */ - -#errorExplanation, #error, #notice { - text-align: center; - font-size: larger; - padding: 4px; - margin: 1em; -} -#errorExplanation, #error { - color: #cc0000; - background-color: #ffcccc; - border: solid 1px #cc0000; -} -#notice { - color: #00cc00; - background-color: #eeffee; - border: solid 1px #00cc00; -} - -/* Form error highlighting */ - -.fieldWithErrors input, .fieldWithErrors input[type=text], -.fieldWithErrors select, .fieldWithErrors input[type=radio], -.fieldWithErrors input[type=password], -.fieldWithErrors textarea -{ - border: solid 1px #cc0000; - background-color: #ffcccc; -} - /* Site-wide layout */ #header { - font-size: 200%; - font-weight: bold; - border-bottom: solid 2px #4e451b; + border-bottom: solid 1px #4e451b; margin: 0; padding: 5px 0.5em; - background-color: #97E300; - color: #4e451b; - /* 4e451b is another useful green */ + background-color: #a8f400; + color: #000000; + /* 4e451b, a8f400 are useful greens */ +} + +#header h1 { + font-size: 200%; + font-weight: bold; } #beta { color: #6e653b; - background-color: #97E300; + background-color: #a8f400; + font-size: 50%; +} +#tagline { + /* color: #6e653b; */ + + color: #000000; + background-color: #a8f400; + padding-top: -2em; font-size: 50%; font-style: italic; } #header a:link, #header a:visited { - color: #4e451b; - background-color: #97E300; + color: #000000; + background-color: #a8f400; text-decoration: none; } #header a:active, #header a:hover { @@ -113,11 +74,13 @@ label { /* Can't put the margin in #content because of above IE craziness */ #wrapper { margin: 2em; + margin-left: 4em; + margin-right: 4em; } #navigation { position: absolute; - top: 1em; + top: 2em; right: 1em; padding: 0; margin: 0; @@ -135,26 +98,101 @@ label { padding: 0.5em 1em; } #navigation a:link, #navigation a:visited { - color: #4e451b; + color: #000000; } #navigation a:hover, #navigation a:active { background-color: #4e451b; - color: #97E300; + color: #a8f400; } #logged_in_bar { text-align: right; + margin-top: 0.5em; + margin-right: 1em; +} + +/* Forms */ + +form { + margin: 0; + padding: 1em; +} + +.plaque { + background-color: #a8f400; + -moz-border-radius: 1em; + border-radius: 1em; +} + +select, input, textarea { + font-size: 99%; +} + +label { + float: left; + text-align: right; + padding-right: 0.5em; + width: 10em; + margin-bottom: 0.5em; +} +.form_note { + margin-left: 10.5em; +} +.form_button { + margin-left: 10em; } -/* Front page */ +/* Flashes */ -#explanation { +#errorExplanation, #error, #notice { text-align: center; - font-size: 150%; - margin: 0 2em; + font-size: larger; + padding: 0.5em; + margin: 1em; } +#errorExplanation, #error { + color: #cc0000; + background-color: #ffcccc; + border: solid 1px #cc0000; +} +#notice { + color: #00cc00; + background-color: #eeffee; + border: solid 1px #00cc00; +} + +/* Form error highlighting */ + +.fieldWithErrors input, .fieldWithErrors input[type=text], +.fieldWithErrors select, .fieldWithErrors input[type=radio], +.fieldWithErrors input[type=password], +.fieldWithErrors textarea +{ + border: solid 1px #cc0000; + background-color: #ffcccc; +} + +/* / - front page */ -/* Submitting requests */ +#frontpage h1 { + margin-bottom: 1em; +} +#frontpage #make_requests { + text-align: center; + width: 45%; + float: left; +} +#frontpage #public_body_form { +} + +#frontpage #find_information { + text-align: center; + width: 45%; + float: right; +} + + +/* /new - submitting requests */ #writeForm { float: right; @@ -169,6 +207,20 @@ label { float: right; } +/* /list - browsing requests */ +table#list_requests { + border-collapse: collapse; + border: solid 1px #4e451b; + border-width: 1px 0 1px 1px; +} +table#list_requests td, table#list_requests th { + margin: 0; padding: 0.2em; + border: solid 1px #4e451b; +} +table#list_requests .odd { + background-color: #dddddd; +} + /* User accounts */ #accountForm { diff --git a/test/functional/body_controller_test.rb b/test/functional/body_controller_test.rb new file mode 100644 index 000000000..4615d9f37 --- /dev/null +++ b/test/functional/body_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'body_controller' + +# Re-raise errors caught by the controller. +class BodyController; def rescue_action(e) raise e end; end + +class BodyControllerTest < Test::Unit::TestCase + def setup + @controller = BodyController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end @@ -1,19 +1,22 @@ -Try making login just go username/password always -Ghost out password field when radio not selected on signin.rhtml - Use something other than session for post redirect store, so can go via email If you recently made a request, then a login will try to make it again because all the stuff for the post redirect is in the session. Consider again Send confirmation email -Send actually FOIFA request +Send actual FOIFA request -Redirect the front page to the new FOI request page Make it say "dear" as default letter Write some tests (try it their way, at every level) +Make sure index for every controller shows all, and the /controller/:id URls go to a show action + +Escape/simplify short name properly in URLs of public bodies +For public bodies whose short names are renamed, make old URL still work and redirect + +Pagination on /list isn't set up properly - set number to low one to test, it doesn't show links + Tidying ======= |