diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 39 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 11 | ||||
-rw-r--r-- | app/views/admin_public_body/show.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_request/list.rhtml | 25 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 37 | ||||
-rw-r--r-- | app/views/layouts/admin.rhtml | 1 |
6 files changed, 113 insertions, 2 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb new file mode 100644 index 000000000..d480084c4 --- /dev/null +++ b/app/controllers/admin_request_controller.rb @@ -0,0 +1,39 @@ +# app/controllers/admin_request_controller.rb: +# Controller for editing public bodies from the admin interface. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: admin_request_controller.rb,v 1.1 2007-12-17 00:34:55 francis Exp $ + +class AdminRequestController < ApplicationController + layout "admin" + + def index + list + render :action => 'list' + end + + def list + @info_requests = InfoRequest.paginate :order => "created_at desc", :page => params[:page], :per_page => 100 + end + + def show + @info_request = InfoRequest.find(params[:id]) + end + + def resend + @outgoing_message = OutgoingMessage.find(params[:outgoing_message_id]) + @outgoing_message.resend_message + flash[:notice] = "Outgoing message resent" + redirect_to admin_url('request/show/' + @outgoing_message.info_request.id.to_s) + end + +# def destroy +# InfoRequest.find(params[:id]).destroy +# redirect_to admin_url('request/list') +# end + + private + +end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index e6d716b0f..af3ace9e4 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.11 2007-12-11 12:16:29 francis Exp $ +# $Id: outgoing_message.rb,v 1.12 2007-12-17 00:34:55 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -66,7 +66,16 @@ class OutgoingMessage < ActiveRecord::Base else raise "Message id #{self.id} has type '#{self.message_type}' which send_message can't handle" end + end + # An admin function + def resend_message + if self.message_type == 'initial_request' and self.status == 'sent' + self.status = 'ready' + send_message + else + raise "Message id #{self.id} has type '#{self.message_type}' status '#{self.status}' " + end end end diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml index 26b49cf80..e5132528c 100644 --- a/app/views/admin_public_body/show.rhtml +++ b/app/views/admin_public_body/show.rhtml @@ -1,4 +1,4 @@ -<% @title = h(@public_body.name) %> +<% @title = "Public body - " + h(@public_body.name) %> <h1><%=@title%></h1> diff --git a/app/views/admin_request/list.rhtml b/app/views/admin_request/list.rhtml new file mode 100644 index 000000000..9472ac8c1 --- /dev/null +++ b/app/views/admin_request/list.rhtml @@ -0,0 +1,25 @@ +<% @title = 'Listing FOI requests' %> + +<h1><%=@title%></h1> + +<table> + <tr> + <% for column in InfoRequest.content_columns %> + <th><%= column.human_name %></th> + <% end %> + </tr> + +<% for info_request in @info_requests %> + <tr class="<%= cycle('odd', 'even') %>"> + <td><%= link_to h(info_request.title), 'show/' + info_request.id.to_s %></td> + <% for column in InfoRequest.content_columns.map { |c| c.name } - [ "title" ] %> + <td><%=h info_request.send(column) %></td> + <% end %> + </tr> +<% end %> +</table> + +<%= will_paginate(@info_requests) %> + +<br /> + diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml new file mode 100644 index 000000000..e9f5ba59a --- /dev/null +++ b/app/views/admin_request/show.rhtml @@ -0,0 +1,37 @@ +<% @title = "FOI request - " + h(@info_request.title) %> + +<h1><%=@title%></h1> + +<p> +<% for column in InfoRequest.content_columns %> + <b><%= column.human_name %>:</b> <%=h @info_request.send(column.name) %> + <br/> +<% end %> +</p> + +<h2>Outgoing messages</h2> + +<table> + <tr> + <% for column in OutgoingMessage.content_columns %> + <th><%= column.human_name %></th> + <% end %> + <th>Actions</th> + </tr> + +<% for outgoing_message in @info_request.outgoing_messages %> + <tr class="<%= cycle('odd', 'even') %>"> + <% for column in OutgoingMessage.content_columns.map { |c| c.name } %> + <td><%=h outgoing_message.send(column) %></td> + <% end %> + <td> + <% form_tag '../resend' do %> + <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %> + <%= submit_tag "Resend" %> + <% end %> + </td> + </tr> +<% end %> +</table> + + diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index ad30f4924..1dd4dc89f 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -12,6 +12,7 @@ <p><b>FOIFA admin interface:</b> <%= link_to 'Public bodies', admin_url('body/list') %> +| <%= link_to 'Requests', admin_url('request/list') %> </p> <p style="color: green"><%= flash[:notice] %></p> |