[#123] Port the send_notification feature to aaj
This commit is contained in:
parent
216619d376
commit
23ef9fedef
|
@ -16,10 +16,13 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class JournalObserver < ActiveRecord::Observer
|
class JournalObserver < ActiveRecord::Observer
|
||||||
|
attr_accessor :send_notification
|
||||||
|
|
||||||
def after_create(journal)
|
def after_create(journal)
|
||||||
if journal.type == "IssueJournal" and journal.version > 1
|
if journal.type == "IssueJournal" and journal.version > 1 and self.send_notification
|
||||||
after_create_issue_journal(journal)
|
after_create_issue_journal(journal)
|
||||||
end
|
end
|
||||||
|
clear_notification
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create_issue_journal(journal)
|
def after_create_issue_journal(journal)
|
||||||
|
@ -30,4 +33,18 @@ class JournalObserver < ActiveRecord::Observer
|
||||||
Mailer.deliver_issue_edit(journal)
|
Mailer.deliver_issue_edit(journal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Wrap send_notification so it defaults to true, when it's nil
|
||||||
|
def send_notification
|
||||||
|
return true if @send_notification.nil?
|
||||||
|
return @send_notification
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Need to clear the notification setting after each usage otherwise it might be cached
|
||||||
|
def clear_notification
|
||||||
|
@send_notification = true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue