aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request.rb17
-rw-r--r--app/models/public_body.rb17
-rw-r--r--app/models/user.rb1
3 files changed, 15 insertions, 20 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 245de1e15..57a8fd7e0 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -901,21 +901,24 @@ public
# Completely delete this request and all objects depending on it
def fully_destroy
- self.track_things.each do |track_thing|
+ track_things.each do |track_thing|
track_thing.track_things_sent_emails.each { |a| a.destroy }
track_thing.destroy
end
- self.user_info_request_sent_alerts.each { |a| a.destroy }
- self.info_request_events.each do |info_request_event|
+ user_info_request_sent_alerts.each { |a| a.destroy }
+ info_request_events.each do |info_request_event|
info_request_event.track_things_sent_emails.each { |a| a.destroy }
info_request_event.destroy
end
- self.mail_server_logs.each do |mail_server_log|
+ mail_server_logs.each do |mail_server_log|
mail_server_log.destroy
end
- self.outgoing_messages.each { |a| a.destroy }
- self.incoming_messages.each { |a| a.destroy }
- self.destroy
+ outgoing_messages.each { |a| a.destroy }
+ incoming_messages.each { |a| a.destroy }
+ comments.each { |comment| comment.destroy }
+ censor_rules.each{ |censor_rule| censor_rule.destroy }
+
+ destroy
end
# Called by incoming_email - and used to be called to generate separate
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 232c0ffa1..5bce8ecc7 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -577,17 +577,11 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
- # Returns nil if configuration variable not set
- def override_request_email
- e = AlaveteliConfiguration::override_all_public_body_request_emails
- e if e != ""
- end
-
def request_email
- if override_request_email
- override_request_email
- else
+ if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank?
read_attribute(:request_email)
+ else
+ AlaveteliConfiguration::override_all_public_body_request_emails
end
end
@@ -774,10 +768,7 @@ class PublicBody < ActiveRecord::Base
end
def empty_translation_in_params?(attributes)
- attrs_with_values = attributes.select do |key, value|
- value != '' and key.to_s != 'locale'
- end
- attrs_with_values.empty?
+ attributes.select { |k, v| !v.blank? && k.to_s != 'locale' }.empty?
end
def request_email_if_requestable
diff --git a/app/models/user.rb b/app/models/user.rb
index 920c0da46..1fb5d9139 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -38,6 +38,7 @@ class User < ActiveRecord::Base
has_one :profile_photo
has_many :censor_rules, :order => 'created_at desc'
has_many :info_request_batches, :order => 'created_at desc'
+ has_many :request_classifications
validates_presence_of :email, :message => _("Please enter your email address")
validates_presence_of :name, :message => _("Please enter your name")