aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/public_body.rb')
-rw-r--r--app/models/public_body.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 0e21037ef..267b5d60c 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 95
+# Schema version: 114
#
# Table name: public_bodies
#
@@ -189,6 +189,25 @@ class PublicBody < ActiveRecord::Base
text = text.gsub(/\n/, '<br>')
return text
end
+
+ def compare(previous = nil)
+ if previous.nil?
+ yield([])
+ else
+ v = self
+ changes = self.class.content_columns.inject([]) {|memo, c|
+ unless %w(version last_edit_editor last_edit_comment updated_at).include?(c.name)
+ from = previous.send(c.name)
+ to = self.send(c.name)
+ memo << { :name => c.human_name, :from => from, :to => to } if from != to
+ end
+ memo
+ }
+ changes.each do |change|
+ yield(change)
+ end
+ end
+ end
end
acts_as_xapian :texts => [ :name, :short_name, :notes ],
@@ -552,6 +571,12 @@ class PublicBody < ActiveRecord::Base
self.info_requests.each {|x| x.purge_in_cache}
end
+ def for_admin_column
+ self.class.content_columns.map{|c| c unless %w(name last_edit_comment).include?(c.name)}.compact.each do |column|
+ yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
+ end
+ end
+
end