diff options
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index c95b7427e..47ad435cb 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -117,8 +117,12 @@ class InfoRequest < ActiveRecord::Base # Possible reasons that a request could be reported for administrator attention def report_reasons - ["Contains defamatory material", "Not a valid request", "Request for personal information", - "Contains personal information", "Vexatious", "Other"] + [_("Contains defamatory material"), + _("Not a valid request"), + _("Request for personal information"), + _("Contains personal information"), + _("Vexatious"), + _("Other")] end def must_be_valid_state @@ -1253,6 +1257,23 @@ public return [xapian_similar, xapian_similar_more] end + def InfoRequest.request_list(filters, page, per_page, max_results) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], + InfoRequestEvent.make_query_from_params(filters), + :offset => (page - 1) * per_page, + :limit => 25, + :sort_by_prefix => 'created_at', + :sort_by_ascending => true, + :collapse_by_prefix => 'request_collapse' + ) + list_results = xapian_object.results.map { |r| r[:model] } + matches_estimated = xapian_object.matches_estimated + show_no_more_than = [matches_estimated, max_results].min + return { :results => list_results, + :matches_estimated => matches_estimated, + :show_no_more_than => show_no_more_than } + end + def InfoRequest.recent_requests request_events = [] request_events_all_successful = false @@ -1300,6 +1321,12 @@ public return [request_events, request_events_all_successful] end + def InfoRequest.find_in_state(state) + find(:all, :select => '*, ' + last_event_time_clause + ' as last_event_time', + :conditions => ["described_state = ?", state], + :order => "last_event_time") + end + private def set_defaults |