aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_public_body_controller.rb51
-rw-r--r--app/helpers/admin_public_body_helper.rb2
-rw-r--r--app/models/public_body.rb4
-rw-r--r--app/views/admin_public_body/_form.rhtml15
-rw-r--r--app/views/admin_public_body/edit.rhtml9
-rw-r--r--app/views/admin_public_body/list.rhtml27
-rw-r--r--app/views/admin_public_body/new.rhtml8
-rw-r--r--app/views/admin_public_body/show.rhtml8
-rw-r--r--app/views/file_request/index.rhtml13
-rw-r--r--app/views/layouts/admin_public_body.rhtml17
10 files changed, 146 insertions, 8 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
new file mode 100644
index 000000000..a982857c0
--- /dev/null
+++ b/app/controllers/admin_public_body_controller.rb
@@ -0,0 +1,51 @@
+class AdminPublicBodyController < ApplicationController
+ def index
+ list
+ render :action => 'list'
+ end
+
+ # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
+ verify :method => :post, :only => [ :destroy, :create, :update ],
+ :redirect_to => { :action => :list }
+
+ def list
+ @public_body_pages, @public_bodies = paginate :public_bodies, :per_page => 10
+ end
+
+ def show
+ @public_body = PublicBody.find(params[:id])
+ end
+
+ def new
+ @public_body = PublicBody.new
+ end
+
+ def create
+ @public_body = PublicBody.new(params[:public_body])
+ if @public_body.save
+ flash[:notice] = 'PublicBody was successfully created.'
+ redirect_to :action => 'list'
+ else
+ render :action => 'new'
+ end
+ end
+
+ def edit
+ @public_body = PublicBody.find(params[:id])
+ end
+
+ def update
+ @public_body = PublicBody.find(params[:id])
+ if @public_body.update_attributes(params[:public_body])
+ flash[:notice] = 'PublicBody was successfully updated.'
+ redirect_to :action => 'show', :id => @public_body
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def destroy
+ PublicBody.find(params[:id]).destroy
+ redirect_to :action => 'list'
+ end
+end
diff --git a/app/helpers/admin_public_body_helper.rb b/app/helpers/admin_public_body_helper.rb
new file mode 100644
index 000000000..e00fe3e0f
--- /dev/null
+++ b/app/helpers/admin_public_body_helper.rb
@@ -0,0 +1,2 @@
+module AdminPublicBodyHelper
+end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
new file mode 100644
index 000000000..332468fee
--- /dev/null
+++ b/app/models/public_body.rb
@@ -0,0 +1,4 @@
+class PublicBody < ActiveRecord::Base
+ validates_presence_of :request_email
+
+end
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
new file mode 100644
index 000000000..e088ef5c2
--- /dev/null
+++ b/app/views/admin_public_body/_form.rhtml
@@ -0,0 +1,15 @@
+<%= error_messages_for 'public_body' %>
+
+<!--[form:public_body]-->
+<p><label for="public_body_name">Name</label><br/>
+<%= text_field 'public_body', 'name', :size => 60 %></p>
+<p><label for="public_body_short_name">Short name</label><br/>
+<%= text_field 'public_body', 'short_name', :size => 60 %></p>
+
+<p><label for="public_body_request_email">Request email</label><br/>
+<%= text_field 'public_body', 'request_email', :size => 40 %></p>
+
+<p><label for="public_body_complaint_email">Complaint email</label><br/>
+<%= text_field 'public_body', 'complaint_email', :size => 40 %></p>
+<!--[eoform:public_body]-->
+
diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml
new file mode 100644
index 000000000..f5c469757
--- /dev/null
+++ b/app/views/admin_public_body/edit.rhtml
@@ -0,0 +1,9 @@
+<h1>Editing public body</h1>
+
+<% form_tag :action => 'update', :id => @public_body do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag 'Edit' %>
+<% end %>
+
+<%= link_to 'Show', :action => 'show', :id => @public_body %> |
+<%= link_to 'Back', :action => 'list' %>
diff --git a/app/views/admin_public_body/list.rhtml b/app/views/admin_public_body/list.rhtml
new file mode 100644
index 000000000..ec1c5c431
--- /dev/null
+++ b/app/views/admin_public_body/list.rhtml
@@ -0,0 +1,27 @@
+<h1>Listing public_bodies</h1>
+
+<table>
+ <tr>
+ <% for column in PublicBody.content_columns %>
+ <th><%= column.human_name %></th>
+ <% end %>
+ </tr>
+
+<% for public_body in @public_bodies %>
+ <tr>
+ <% for column in PublicBody.content_columns %>
+ <td><%=h public_body.send(column.name) %></td>
+ <% end %>
+ <td><%= link_to 'Show', :action => 'show', :id => public_body %></td>
+ <td><%= link_to 'Edit', :action => 'edit', :id => public_body %></td>
+ <td><%= link_to 'Destroy', { :action => 'destroy', :id => public_body }, :confirm => 'Are you sure?', :method => :post %></td>
+ </tr>
+<% end %>
+</table>
+
+<%= link_to 'Previous page', { :page => @public_body_pages.current.previous } if @public_body_pages.current.previous %>
+<%= link_to 'Next page', { :page => @public_body_pages.current.next } if @public_body_pages.current.next %>
+
+<br />
+
+<%= link_to 'New public_body', :action => 'new' %>
diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml
new file mode 100644
index 000000000..ee6ce8d81
--- /dev/null
+++ b/app/views/admin_public_body/new.rhtml
@@ -0,0 +1,8 @@
+<h1>New public body</h1>
+
+<% form_tag :action => 'create' do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag "Create" %>
+<% end %>
+
+<%= link_to 'Back', :action => 'list' %>
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml
new file mode 100644
index 000000000..4e1aa2ad3
--- /dev/null
+++ b/app/views/admin_public_body/show.rhtml
@@ -0,0 +1,8 @@
+<% for column in PublicBody.content_columns %>
+<p>
+ <b><%= column.human_name %>:</b> <%=h @public_body.send(column.name) %>
+</p>
+<% end %>
+
+<%= link_to 'Edit', :action => 'edit', :id => @public_body %> |
+<%= link_to 'Back', :action => 'list' %>
diff --git a/app/views/file_request/index.rhtml b/app/views/file_request/index.rhtml
index c1f686bd7..dec0103fc 100644
--- a/app/views/file_request/index.rhtml
+++ b/app/views/file_request/index.rhtml
@@ -35,14 +35,11 @@ displayed publically on this website.</p>
<!-- (a one line summary of the information you are requesting, e.g. 'Crime statistics by ward level for Wales') -->
</p>
-<%
-=begin %>
- <p>
- <%= f.text_area :body %>
- </p>
-<%
-=end
-%>
+ <% fields_for :outgoing_message do |o| %>
+ <p>
+ <%= o.text_area :body %>
+ </p>
+ <% end %>
<p>
<%= submit_tag "Create" %>
diff --git a/app/views/layouts/admin_public_body.rhtml b/app/views/layouts/admin_public_body.rhtml
new file mode 100644
index 000000000..18d3caa61
--- /dev/null
+++ b/app/views/layouts/admin_public_body.rhtml
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>AdminPublicBody: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>