aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application.rb23
-rw-r--r--app/controllers/file_request_controller.rb25
-rw-r--r--app/controllers/frontpage_controller.rb4
-rw-r--r--app/helpers/file_request_helper.rb2
-rw-r--r--app/models/info_request.rb13
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/file_request/index.rhtml33
-rw-r--r--app/views/frontpage/index.rhtml2
-rw-r--r--app/views/layouts/default.rhtml2
-rw-r--r--config/routes.rb13
-rw-r--r--db/migrate/004_create_info_requests.rb12
-rw-r--r--db/schema.rb7
-rw-r--r--doc/README_FOR_APP2
-rw-r--r--public/stylesheets/main.css35
-rw-r--r--test/fixtures/info_requests.yml5
-rw-r--r--test/functional/file_request_controller_test.rb18
-rw-r--r--test/unit/info_request_test.rb10
17 files changed, 172 insertions, 38 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 4365de88d..ddd6e86b4 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,21 +6,16 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.3 2007-08-01 17:06:04 francis Exp $
+# $Id: application.rb,v 1.4 2007-08-04 11:10:25 francis Exp $
class ApplicationController < ActionController::Base
+ # Standard hearders, footers and navigation for whole site
+ layout "default"
+
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_foi_session_id'
- def check_authentication
- unless session[:user]
- session[:intended_action] = action_name
- session[:intended_controller] = controller_name
- redirect_to :action => "signin"
- end
- end
-
def signin
if request.post?
user = User.authenticate(params[:email], params[:password])
@@ -39,4 +34,14 @@ class ApplicationController < ActionController::Base
redirect_to frontpage
end
+ private
+
+ def check_authentication
+ unless session[:user]
+ session[:intended_action] = action_name
+ session[:intended_controller] = controller_name
+ redirect_to :action => "signin"
+ end
+ end
+
end
diff --git a/app/controllers/file_request_controller.rb b/app/controllers/file_request_controller.rb
new file mode 100644
index 000000000..9b0f7c403
--- /dev/null
+++ b/app/controllers/file_request_controller.rb
@@ -0,0 +1,25 @@
+# app/controllers/file_request_controller.rb:
+# Interface for building a new FOI request.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: file_request_controller.rb,v 1.1 2007-08-04 11:10:25 francis Exp $
+
+class FileRequestController < ApplicationController
+ def index
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ def create
+ respond_to do |format|
+ format.html
+ end
+ end
+
+
+end
+
+
diff --git a/app/controllers/frontpage_controller.rb b/app/controllers/frontpage_controller.rb
index 16aaaf4c3..36d31d2f5 100644
--- a/app/controllers/frontpage_controller.rb
+++ b/app/controllers/frontpage_controller.rb
@@ -4,11 +4,9 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: frontpage_controller.rb,v 1.3 2007-08-03 16:14:58 francis Exp $
+# $Id: frontpage_controller.rb,v 1.4 2007-08-04 11:10:25 francis Exp $
class FrontpageController < ApplicationController
- layout "default"
-
def index
respond_to do |format|
format.html
diff --git a/app/helpers/file_request_helper.rb b/app/helpers/file_request_helper.rb
new file mode 100644
index 000000000..fc398dab7
--- /dev/null
+++ b/app/helpers/file_request_helper.rb
@@ -0,0 +1,2 @@
+module FileRequestHelper
+end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
new file mode 100644
index 000000000..9c84263bf
--- /dev/null
+++ b/app/models/info_request.rb
@@ -0,0 +1,13 @@
+# models/info_request.rb:
+# A Freedom of Information request.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: info_request.rb,v 1.1 2007-08-04 11:10:26 francis Exp $
+
+class InfoRequest < ActiveRecord::Base
+ belongs_to :user
+
+end
+
diff --git a/app/models/user.rb b/app/models/user.rb
index 2a6b7a31d..a333e5721 100644
--- a/app/models/user.rb
+++ b/app/models/user.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: user.rb,v 1.1 2007-08-01 16:41:33 francis Exp $
+# $Id: user.rb,v 1.2 2007-08-04 11:10:26 francis Exp $
require 'digest/sha1'
@@ -14,6 +14,8 @@ class User < ActiveRecord::Base
validates_presence_of :email
validates_uniqueness_of :email, :case_sensitive => false
+ has_many :user
+
attr_accessor :password_confirmation
validates_confirmation_of :password
diff --git a/app/views/file_request/index.rhtml b/app/views/file_request/index.rhtml
new file mode 100644
index 000000000..3b03b987f
--- /dev/null
+++ b/app/views/file_request/index.rhtml
@@ -0,0 +1,33 @@
+<h1>New request</h1>
+
+<% form_for(:foi_request, @foi_request, :url => { :action => :create }, :html => { :id => 'writeForm' } ) do |f| %>
+ <%= error_messages_for :foi_request %>
+
+ <% fields_for :user do |u| %>
+ <p>
+ <b>Your name</b> (will be displayed on this site with your request and any response)<br />
+ <%= u.text_field :name %>
+ </p>
+
+ <p>
+ <b>Your email</b> (we'll only use it to keep you up to date about your request, and this site)<br />
+ <%= u.text_field :email %>
+ </p>
+ <% end %>
+
+ <p>
+ <b>Request title</b><br />
+ <%= f.text_field :title, "size" => 30 %>
+ </p>
+
+ <p>
+ <b>Letter</b><br />
+ <%= f.text_area :body %>
+ </p>
+
+ <p>
+ <%= submit_tag "Create" %>
+ </p>
+<% end %>
+
+
diff --git a/app/views/frontpage/index.rhtml b/app/views/frontpage/index.rhtml
index f5cf1fcbb..8b5611d41 100644
--- a/app/views/frontpage/index.rhtml
+++ b/app/views/frontpage/index.rhtml
@@ -1,3 +1,3 @@
-<p>Make requests for information from the UK Government.
+<p id="explanation">Make requests for information from the UK Government
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 662c9a5aa..7eb81f3ec 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -7,7 +7,7 @@
<!-- <link rel="alternate" type="application/rss+xml" title="" href=""> -->
</head>
<body>
- <h1 id="header">Freedom <span id="my">of Information</span> Archive <span id="beta">Beta</span></h1>
+ <h1 id="header">Freedom of Information Filer and Archive <span id="beta">Beta</span></h1>
<ul id="navigation">
<li>Home</li>
</ul>
diff --git a/config/routes.rb b/config/routes.rb
index bd1f9cf5d..d0f5cc971 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,9 +1,19 @@
+# config/routes.rb:
+# Mapping URLs to controllers for FOIFA.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: routes.rb,v 1.4 2007-08-04 11:10:26 francis Exp $
+
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# 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 => 'file_request', :action => 'index'
+ map.connect "/:action/:id", :controller => 'frontpage'
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
@@ -21,8 +31,5 @@ ActionController::Routing::Routes.draw do |map|
# FAI: Turned off for now, as to be honest I don't trust it from a security point of view.
#map.connect ':controller/:action/:id.:format'
#map.connect ':controller/:action/:id'
-
- map.connect "/:action/:id", :controller => 'frontpage'
-
end
diff --git a/db/migrate/004_create_info_requests.rb b/db/migrate/004_create_info_requests.rb
new file mode 100644
index 000000000..29a3a9f22
--- /dev/null
+++ b/db/migrate/004_create_info_requests.rb
@@ -0,0 +1,12 @@
+class CreateInfoRequests < ActiveRecord::Migration
+ def self.up
+ create_table :info_requests do |t|
+ t.column :title, :text
+ t.column :user_id, :integer
+ end
+ end
+
+ def self.down
+ drop_table :info_requests
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ab31f97d6..de6ac6216 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,7 +2,12 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 2) do
+ActiveRecord::Schema.define(:version => 4) do
+
+ create_table "info_requests", :force => true do |t|
+ t.column "title", :text
+ t.column "user_id", :integer
+ end
create_table "sessions", :force => true do |t|
t.column "session_id", :string
diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP
new file mode 100644
index 000000000..ac6c14912
--- /dev/null
+++ b/doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake appdoc" to generate API documentation for your models and controllers. \ No newline at end of file
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index d4fc5ef0b..994bf1284 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -85,27 +85,24 @@ dt {
#header {
font-size: 200%;
font-weight: bold;
- border-bottom: solid 2px #006f2c;
+ border-bottom: solid 2px #4e451b;
margin: 0;
padding: 5px 0.5em;
- background-color: #00bd4b;
- color: #006f2c;
-}
-
-#my {
+ background-color: #97E300;
color: #4e451b;
- background-color: #00bd4b;
+ /* 4e451b is another useful green */
}
+
#beta {
color: #6e653b;
- background-color: #00bd4b;
+ background-color: #97E300;
font-size: 50%;
font-style: italic;
}
#header a:link, #header a:visited {
- color: #006f2c;
- background-color: #00bd4b;
+ color: #4e451b;
+ background-color: #97E300;
text-decoration: none;
}
#header a:active, #header a:hover {
@@ -144,18 +141,18 @@ dt {
padding: 0.5em 1em;
}
#navigation a:link, #navigation a:visited {
- color: #006f2c;
+ color: #4e451b;
}
#navigation a:hover, #navigation a:active {
- background-color: #006f2c;
- color: #00bd4b;
+ background-color: #4e451b;
+ color: #97E300;
}
#footer {
clear: both;
text-align: right;
font-size: 83%;
- border-top: solid 1px #006f2c;
+ border-top: solid 1px #4e451b;
display: table;
margin: 2em 0 1em auto;
padding: 2px 4px;
@@ -163,30 +160,30 @@ dt {
/* Front page */
-#expl {
+#explanation {
text-align: center;
font-size: 150%;
margin: 0 2em;
}
-#postcodeForm {
+#writeForm {
display: table;
_width: 31em;
text-align: center;
font-size: 150%;
margin: 1em auto;
padding: 1em;
- background-color: #00bd4b;
+ background-color: #97E300;
-moz-border-radius: 1em;
border-radius: 1em;
}
-#postcodeForm label {
+#writeForm label {
float: none;
padding-right: 0;
}
-#postcodeForm #submit {
+#writeForm #submit {
font-size: 83%;
}
diff --git a/test/fixtures/info_requests.yml b/test/fixtures/info_requests.yml
new file mode 100644
index 000000000..b49c4eb4e
--- /dev/null
+++ b/test/fixtures/info_requests.yml
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+two:
+ id: 2
diff --git a/test/functional/file_request_controller_test.rb b/test/functional/file_request_controller_test.rb
new file mode 100644
index 000000000..05d17d5e5
--- /dev/null
+++ b/test/functional/file_request_controller_test.rb
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'file_request_controller'
+
+# Re-raise errors caught by the controller.
+class FileRequestController; def rescue_action(e) raise e end; end
+
+class FileRequestControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = FileRequestController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff --git a/test/unit/info_request_test.rb b/test/unit/info_request_test.rb
new file mode 100644
index 000000000..838a32263
--- /dev/null
+++ b/test/unit/info_request_test.rb
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class InfoRequestTest < Test::Unit::TestCase
+ fixtures :info_requests
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end