Permalink
Browse files

Skeletal model for an FOI request.

Rubbishy display of first form.
  • Loading branch information...
1 parent 4201bb9 commit 4016d8188af7b85347a032f073cf62a39995a8f8 francis committed Aug 4, 2007
@@ -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 @@ def signout
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
@@ -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
+
+
@@ -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
@@ -0,0 +1,2 @@
+module FileRequestHelper
+end
View
@@ -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
+
View
@@ -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
@@ -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 %>
+
+
@@ -1,3 +1,3 @@
-<p>Make requests for information from the UK Government.
+<p id="explanation">Make requests for information from the UK Government
@@ -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>
View
@@ -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 @@
# 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
@@ -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
View
@@ -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
View
@@ -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.
@@ -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,49 +141,49 @@ 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;
}
/* 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%;
}
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+two:
+ id: 2
@@ -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
@@ -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

0 comments on commit 4016d81

Please sign in to comment.