Quick correction, to only send orga's mails when a submitter has been filed

This commit is contained in:
echarp 2015-12-27 00:39:29 +01:00
parent 845e0d0983
commit 93dfcbaa8c

View File

@ -18,16 +18,18 @@ class Orga < ActiveRecord::Base
scope :unmoderated, -> { where moderated: false }
before_validation do
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32] if submitter
unless submitter.blank?
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32]
end
self.submission_time ||= Time.zone.now
end
after_create do
send_secret if submitter
send_secret unless submitter.blank?
end
after_update do
if submitter
unless submitter.blank?
send_secret if secret_changed?
if moderated_changed?
@ -39,7 +41,7 @@ class Orga < ActiveRecord::Base
end
before_destroy do
OrgaMailer.destroy(self).deliver_now! if submitter
OrgaMailer.destroy(self).deliver_now! unless submitter.blank?
end
def send_secret