diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 35 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 4 | ||||
-rw-r--r-- | app/models/info_request.rb | 7 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 3 | ||||
-rw-r--r-- | app/views/admin_request/edit_outgoing.rhtml | 3 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 5 |
6 files changed, 41 insertions, 16 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 3b69ff8ed..504ce0c23 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.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: admin_request_controller.rb,v 1.5 2008-02-14 07:45:08 francis Exp $ +# $Id: admin_request_controller.rb,v 1.6 2008-02-15 11:18:55 francis Exp $ class AdminRequestController < ApplicationController layout "admin" @@ -29,25 +29,44 @@ class AdminRequestController < ApplicationController redirect_to request_admin_url(@outgoing_message.info_request) end + def edit + @info_request = InfoRequest.find(params[:id]) + end + + def update + @info_request = InfoRequest.find(params[:id]) + + old_title = @info_request.title + old_prominence = @info_request.prominence + + if @info_request.update_attributes(params[:info_request]) + @info_request.log_event("edit", + { :editor => admin_http_auth_user(), + :old_title => old_title, :title => @info_request.title, + :old_prominence => old_prominence, :prominence => @info_request.prominence, + }) + flash[:notice] = 'Request successfully updated.' + redirect_to request_admin_url(@info_request) + else + render :action => 'edit_outgoing' + end + end + def edit_outgoing @outgoing_message = OutgoingMessage.find(params[:id]) - @info_request = @outgoing_message.info_request end def update_outgoing @outgoing_message = OutgoingMessage.find(params[:id]) - @info_request = @outgoing_message.info_request old_body = @outgoing_message.body - old_title = @info_request.title - if @outgoing_message.update_attributes(params[:outgoing_message]) and @info_request.update_attributes(params[:info_request]) + if @outgoing_message.update_attributes(params[:outgoing_message]) @outgoing_message.info_request.log_event("edit_outgoing", { :outgoing_message_id => @outgoing_message.id, :editor => admin_http_auth_user(), - :old_title => old_title, :title => @info_request.title, :old_body => old_body, :body => @outgoing_message.body }) - flash[:notice] = 'Request successfully updated.' - redirect_to request_admin_url(@info_request) + flash[:notice] = 'Outgoing message successfully updated.' + redirect_to request_admin_url(@outgoing_message.info_request) else render :action => 'edit_outgoing' end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e8ca767fa..97bb37c39 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.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: request_controller.rb,v 1.48 2008-02-14 09:57:56 francis Exp $ +# $Id: request_controller.rb,v 1.49 2008-02-15 11:18:55 francis Exp $ class RequestController < ApplicationController @@ -22,7 +22,7 @@ class RequestController < ApplicationController end def list - @info_requests = InfoRequest.paginate :order => "created_at desc", :page => params[:page], :per_page => 25 + @info_requests = InfoRequest.paginate :order => "created_at desc", :page => params[:page], :per_page => 25, :conditions => "prominence = 'normal'" end def frontpage diff --git a/app/models/info_request.rb b/app/models/info_request.rb index cf50bf986..5a352026e 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -19,7 +19,7 @@ # 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.40 2008-02-14 15:31:22 francis Exp $ +# $Id: info_request.rb,v 1.41 2008-02-15 11:18:55 francis Exp $ require 'digest/sha1' @@ -47,6 +47,11 @@ class InfoRequest < ActiveRecord::Base 'partially_successful' ] + validates_inclusion_of :prominence, :in => [ + 'normal', + 'backpage', + ] + def after_initialize if self.described_state.nil? self.described_state = 'waiting_response' diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index ebd03d855..a8c2c7f50 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -16,7 +16,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.14 2008-02-14 15:31:22 francis Exp $ +# $Id: info_request_event.rb,v 1.15 2008-02-15 11:18:55 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -27,6 +27,7 @@ class InfoRequestEvent < ActiveRecord::Base 'sent', 'resent', 'followup_sent', + 'edit', # title etc. edited in admin interface 'edit_outgoing', # outgoing message edited in admin interface 'manual', # you did something in the db by hand 'response' diff --git a/app/views/admin_request/edit_outgoing.rhtml b/app/views/admin_request/edit_outgoing.rhtml index 3f59fad1f..099658e44 100644 --- a/app/views/admin_request/edit_outgoing.rhtml +++ b/app/views/admin_request/edit_outgoing.rhtml @@ -4,9 +4,6 @@ <% form_tag '../update_outgoing/' + @outgoing_message.id.to_s do %> - <p><label for="info_request_title">Title</label><br/> - <%= text_field 'info_request', 'title', :size => 50 %></p> - <p><label for="outgoing_message_body">Body of message</label><br/> <%= text_area 'outgoing_message', 'body', :rows => 10, :cols => 60 %></p> diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 690d85905..940972187 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -13,7 +13,10 @@ <strong>Envelope email address:</strong> <%=h @info_request.envelope_email %> <br> </p> -<p><%= link_to 'Public page', main_url(request_url(@info_request)) %></p> +<p> +<%= link_to 'Public page', main_url(request_url(@info_request)) %> +| <%= link_to "Edit", '../edit/' + @info_request.id.to_s %> +</p> <h2>Outgoing messages</h2> |