diff options
-rw-r--r-- | app/models/info_request_event.rb | 38 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 2 | ||||
-rw-r--r-- | public/stylesheets/admin.css | 4 |
3 files changed, 42 insertions, 2 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index c2f515b6b..d0dbaf597 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -21,7 +21,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.86 2009-07-21 12:09:30 francis Exp $ +# $Id: info_request_event.rb,v 1.87 2009-09-08 00:02:34 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -195,7 +195,43 @@ class InfoRequestEvent < ActiveRecord::Base def params YAML.load(self.params_yaml) end + def params_yaml_as_html + ret = '' + # split out parameters into old/new diffs, and other ones + old_params = {} + new_params = {} + other_params = {} + for key, value in self.params + key = key.to_s + old_key = ("old_" + key).to_sym + if key.match(/^old_(.*)$/) + old_params[$1] = value + elsif self.params.include?(("old_" + key).to_sym) + new_params[key] = value + else + other_params[key] = value + end + end + # loop through + for key, value in new_params + old_value = old_params[key].to_s + new_value = new_params[key].to_s + if old_value != new_value: + ret = ret + "<em>" + CGI.escapeHTML(key) + ":</em> " + ret = ret + CGI.escapeHTML(old_value) + " => " + CGI.escapeHTML(new_value) + ret = ret + "<br>" + end + end + for key, value in other_params + ret = ret + "<em>" + CGI.escapeHTML(key.to_s) + ":</em> " + ret = ret + CGI.escapeHTML(value.to_s) + ret = ret + "<br>" + end + # ret = ret + CGI.escapeHTML(a.to_s) + ":" + CGI.escapeHTML(b.to_s) + "<br>" + return ret + end + def is_incoming_message?() not self.incoming_message.nil? end def is_outgoing_message?() not self.outgoing_message.nil? end def is_comment?() not self.comment.nil? end diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 82e71e643..2ef000742 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -36,7 +36,7 @@ <% for column in InfoRequestEvent.content_columns %> <td> <% if column.name == 'params_yaml' %> - <pre><%=h info_request_event.params_yaml.gsub(/-/,' ').strip %></pre> + <%= info_request_event.params_yaml_as_html %> <% elsif column.text? %> <%=h (info_request_event.send(column.name) || '').gsub(/_/,' ') %> <% else %> diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index e13f5ccf6..8ff4ec981 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -16,6 +16,10 @@ td, th { td { vertical-align: top } +td { + max-width: 30em; + overflow: auto; +} tr.odd { background-color: #bbbbbb; |