Send proposals notifications to followers.

This commit is contained in:
taitus
2017-07-04 13:36:31 +02:00
committed by Senén Rodero Rodríguez
parent 35f7f11177
commit b29bf62f56
6 changed files with 135 additions and 7 deletions

View File

@@ -11,8 +11,8 @@ class ProposalNotificationsController < ApplicationController
@notification = ProposalNotification.new(proposal_notification_params)
@proposal = Proposal.find(proposal_notification_params[:proposal_id])
if @notification.save
@proposal.voters.each do |voter|
Notification.add(voter.id, @notification)
notification_users.each do |user|
Notification.add(user.id, @notification)
end
redirect_to @notification, notice: I18n.t("flash.actions.create.proposal_notification")
else
@@ -30,4 +30,8 @@ class ProposalNotificationsController < ApplicationController
params.require(:proposal_notification).permit(:title, :body, :proposal_id)
end
end
def notification_users
(@proposal.voters + @proposal.followers).uniq
end
end