diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-01-29 16:10:52 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-01-29 16:10:52 +0000 |
commit | 184ffeccb7f4579b481db9b7744aa9baed70562f (patch) | |
tree | 67c023b029a699a1e727ef6becdc0832e82ea1c5 /app/models/user.rb | |
parent | e44c8b875fd4ad46b954ef9c31bdb6f0366dcb9e (diff) | |
parent | 79b2f672aeae394a2c195d89b70bda27bb3201a4 (diff) |
Merge branch 'feature/batch-requests' into rails-3-develop
Conflicts:
config/general.yml-example
spec/factories.rb
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 2c4f87944..e63ce8129 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,5 @@ # == Schema Information +# Schema version: 20131024114346 # # Table name: users # @@ -20,6 +21,7 @@ # email_bounce_message :text default(""), not null # no_limit :boolean default(FALSE), not null # receive_email_alerts :boolean default(TRUE), not null +# can_make_batch_requests :boolean default(FALSE), not null # require 'digest/sha1' @@ -40,6 +42,7 @@ class User < ActiveRecord::Base has_many :comments, :order => 'created_at desc' has_one :profile_photo has_many :censor_rules, :order => 'created_at desc' + has_many :info_request_batches, :order => 'created_at desc' attr_accessor :password_confirmation, :no_xapian_reindex validates_confirmation_of :password, :message => _("Please enter the same password twice") @@ -269,6 +272,9 @@ class User < ActiveRecord::Base # Some users have no limit return false if self.no_limit + # Batch request users don't have a limit + return false if self.can_make_batch_requests? + # Has the user issued as many as MAX_REQUESTS_PER_USER_PER_DAY requests in the past 24 hours? return false if AlaveteliConfiguration::max_requests_per_user_per_day.blank? recent_requests = InfoRequest.count(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id]) |