aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin_controller.rb7
-rw-r--r--app/models/info_request.rb8
-rw-r--r--app/models/user.rb12
3 files changed, 21 insertions, 6 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 7ff75064c..9091cb008 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: admin_controller.rb,v 1.20 2008-09-08 01:49:57 francis Exp $
+# $Id: admin_controller.rb,v 1.21 2008-09-11 10:37:37 francis Exp $
class AdminController < ApplicationController
layout "admin"
@@ -19,10 +19,9 @@ class AdminController < ApplicationController
@comment_count = Comment.count
# Tasks to do
- last_event_time_clause = '(select created_at from info_request_events where info_request_events.info_request_id = info_requests.id order by created_at desc limit 1)'
- @requires_admin_requests = InfoRequest.find(:all, :select => '*, ' + last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'requires_admin'"], :order => "last_event_time")
+ @requires_admin_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'requires_admin'"], :order => "last_event_time")
@blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], :order => "updated_at")
- @ten_days_old_unclassified = InfoRequest.find(:all, :select => '*, ' + last_event_time_clause + ' as last_event_time', :conditions => [ "awaiting_description = ? and " + last_event_time_clause + " < ? and prominence != 'backpage'", true, Time.now() - 10.days ], :order => "last_event_time")
+ @ten_days_old_unclassified = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => [ "awaiting_description = ? and " + InfoRequest.last_event_time_clause + " < ? and prominence != 'backpage'", true, Time.now() - 10.days ], :order => "last_event_time")
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 28d82e989..b98eb1f64 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -23,7 +23,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.136 2008-09-02 17:59:40 francis Exp $
+# $Id: info_request.rb,v 1.137 2008-09-11 10:37:37 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -678,6 +678,12 @@ public
end
end
+ # Used to find when event last changed
+ def InfoRequest.last_event_time_clause
+ '(select created_at from info_request_events where info_request_events.info_request_id = info_requests.id order by created_at desc limit 1)'
+ end
+
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index f0416506e..579ab7265 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -22,7 +22,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.66 2008-08-31 14:08:55 francis Exp $
+# $Id: user.rb,v 1.67 2008-09-11 10:37:37 francis Exp $
require 'digest/sha1'
@@ -164,6 +164,16 @@ class User < ActiveRecord::Base
return u
end
+ # Returns list of requests which the user hasn't described.
+ def get_undescribed_requests
+ self.info_requests.find(
+ :all,
+ :conditions => [ 'awaiting_description = ? and ' + InfoRequest.last_event_time_clause + ' < ?',
+ true, Time.now() - 1.day
+ ]
+ )
+ end
+
# Does the user magically gain powers as if they owned every request?
# e.g. Can classify it
def owns_every_request?