aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/public_body.rb18
-rw-r--r--app/models/user.rb11
2 files changed, 29 insertions, 0 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 2c13d1bf3..de3ac3552 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -412,6 +412,24 @@ class PublicBody < ActiveRecord::Base
self.notes.gsub(/<\/?[^>]*>/, "")
end
+ def json_for_api
+ return {
+ :id => self.id,
+ :url_name => self.url_name,
+ :name => self.name,
+ :short_name => self.short_name,
+ # :request_email # we hide this behind a captcha, to stop people doing bulk requests easily
+ :created_at => self.created_at,
+ :updated_at => self.updated_at,
+ # don't add the history as some edit comments contain sensitive information
+ # :version, :last_edit_editor, :last_edit_comment
+ :home_page => self.calculated_home_page,
+ :notes => self.notes,
+ :publication_scheme => self.publication_scheme,
+ :tags => self.tag_array,
+ }
+ end
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 847959ce7..7f85a2c4f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -326,6 +326,17 @@ class User < ActiveRecord::Base
return text
end
+ def json_for_api
+ return {
+ :id => self.id,
+ :url_name => self.url_name,
+ :name => self.name,
+ :ban_text => self.ban_text,
+ :about_me => self.about_me,
+ # :profile_photo => self.profile_photo # ought to have this, but too hard to get URL out for now
+ # created_at / updated_at we only show the year on the main page for privacy reasons, so don't put here
+ }
+ end
private