New proposal method to get users_to_notify.

This commit is contained in:
taitus
2017-07-05 14:04:07 +02:00
committed by Senén Rodero Rodríguez
parent 0c2be6a0d4
commit 5fe894aa6b
3 changed files with 6 additions and 6 deletions

View File

@@ -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

View File

@@ -171,6 +171,10 @@ class Proposal < ActiveRecord::Base
proposal_notifications
end
def users_to_notify
(voters + followers).uniq
end
protected
def set_responsible_name

View File

@@ -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>