aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-24 18:14:35 +0100
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:40 +0000
commit282cebc96cb9548e5af3f2ee7c635c39da4bdbce (patch)
treeaa8d1ed3cb2682bb172d21d7b00cfe1d55adf568 /app/models/info_request.rb
parentad8772fde14c57f05e2585c8c02034e053a86319 (diff)
Add a batch_request_template flag
A virtual attribute to use to customise some info request behaviours when we are using one request as a template for creating multiple requests.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 0a073dc79..aaed99d81 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -40,7 +40,7 @@ class InfoRequest < ActiveRecord::Base
validate :must_be_internal_or_external
belongs_to :public_body, :counter_cache => true
- validates_presence_of :public_body_id
+ validates_presence_of :public_body_id, :unless => Proc.new { |info_request| info_request.is_batch_request_template? }
has_many :outgoing_messages, :order => 'created_at'
has_many :incoming_messages, :order => 'created_at'
@@ -50,6 +50,7 @@ class InfoRequest < ActiveRecord::Base
has_many :comments, :order => 'created_at'
has_many :censor_rules, :order => 'created_at desc'
has_many :mail_server_logs, :order => 'mail_server_log_done_id'
+ attr_accessor :is_batch_request_template
has_tag_string
@@ -122,6 +123,10 @@ class InfoRequest < ActiveRecord::Base
!InfoRequest.enumerate_states.include? described_state
end
+ def is_batch_request_template?
+ is_batch_request_template == true
+ end
+
# The request must either be internal, in which case it has
# a foreign key reference to a User object and no external_url or external_user_name,
# or else be external in which case it has no user_id but does have an external_url,