diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 2a81c4bfe..d900fd17d 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -59,6 +59,14 @@ class Mailer < ApplicationMailer end end + def proposal_notification_digest(user) + @notifications = user.notifications.where(notifiable_type: "ProposalNotification") + + with_user(user) do + mail(to: user.email, subject: "Email digest") + end + end + private def with_user(user, &block) diff --git a/app/models/user.rb b/app/models/user.rb index 243781cb3..a3b719859 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -51,6 +51,7 @@ class User < ActiveRecord::Base scope :officials, -> { where("official_level > 0") } scope :for_render, -> { includes(:organization) } scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) } + scope :email_digest, -> { where(email_digest: true) } before_validation :clean_document_number diff --git a/app/views/mailer/proposal_notification_digest.html.erb b/app/views/mailer/proposal_notification_digest.html.erb index 4733d900e..16e96260c 100644 --- a/app/views/mailer/proposal_notification_digest.html.erb +++ b/app/views/mailer/proposal_notification_digest.html.erb @@ -11,41 +11,43 @@ - -
|
- - <%= @notification.title %> - -- <%= @notification.proposal.title %> • <%= @notification.proposal.created_at.to_date %> • <%= @notification.proposal.author.name %> - -- <%= @notification.body %> - + <%= @notifications.each do |notification| %> +
|
+