From 282cebc96cb9548e5af3f2ee7c635c39da4bdbce Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 24 Sep 2013 18:14:35 +0100 Subject: 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. --- app/models/info_request.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/models/info_request.rb') 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, -- cgit v1.2.3