diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-06-06 15:37:15 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-06-06 19:35:13 +0100 |
commit | ba0811b35d41a18a01977ba53147da522541b151 (patch) | |
tree | 6d1e1b9abccad4b19420d1054d1d2409680904db | |
parent | c89e6efac2fb10ddf3c1a111f188c64743c3714e (diff) |
Fix indexing of info_request_events
Even external requests need to be indexed, for which we need a
slug representing the user.
-rw-r--r-- | app/models/info_request.rb | 13 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 8d9d92b0d..99cbe476a 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -128,6 +128,19 @@ class InfoRequest < ActiveRecord::Base def user_name is_external? ? external_user_name : user.name end + + def user_name_slug + if is_external? + if external_user_name.nil? + fake_slug = "anonymous" + else + fake_slug = external_user_name.parameterize + end + public_body.url_name + "_"+fake_slug + else + user.url_name + end + end @@custom_states_loaded = false begin diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 9a4f6d9fe..a827d19a4 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -118,7 +118,7 @@ class InfoRequestEvent < ActiveRecord::Base :eager_load => [ :outgoing_message, :comment, { :info_request => [ :user, :public_body, :censor_rules ] } ] def requested_by - self.info_request.user.url_name + self.info_request.user_name_slug end def requested_from # acts_as_xapian will detect translated fields via Globalize and add all the |