New proposal method to get users_to_notify.
This commit is contained in:
committed by
Senén Rodero Rodríguez
parent
0c2be6a0d4
commit
5fe894aa6b
@@ -11,7 +11,7 @@ class ProposalNotificationsController < ApplicationController
|
||||
@notification = ProposalNotification.new(proposal_notification_params)
|
||||
@proposal = Proposal.find(proposal_notification_params[:proposal_id])
|
||||
if @notification.save
|
||||
notification_users.each do |user|
|
||||
@proposal.users_to_notify.each do |user|
|
||||
Notification.add(user.id, @notification)
|
||||
end
|
||||
redirect_to @notification, notice: I18n.t("flash.actions.create.proposal_notification")
|
||||
@@ -30,8 +30,4 @@ class ProposalNotificationsController < ApplicationController
|
||||
params.require(:proposal_notification).permit(:title, :body, :proposal_id)
|
||||
end
|
||||
|
||||
def notification_users
|
||||
(@proposal.voters + @proposal.followers).uniq
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -171,6 +171,10 @@ class Proposal < ActiveRecord::Base
|
||||
proposal_notifications
|
||||
end
|
||||
|
||||
def users_to_notify
|
||||
(voters + followers).uniq
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_responsible_name
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="callout primary">
|
||||
<p>
|
||||
<%= t("proposal_notifications.new.info_about_receivers_html",
|
||||
count: (@proposal.voters + @proposal.followers).uniq.count,
|
||||
count: @proposal.users_to_notify.count,
|
||||
proposal_page: link_to(t("proposal_notifications.new.proposal_page"),
|
||||
proposal_path(@proposal, anchor: "comments"))).html_safe %>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user