diff --git a/app/controllers/proposal_notifications_controller.rb b/app/controllers/proposal_notifications_controller.rb index 2ab2f811e..dfad56945 100644 --- a/app/controllers/proposal_notifications_controller.rb +++ b/app/controllers/proposal_notifications_controller.rb @@ -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 diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 054c00c4a..21335c5a5 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -171,6 +171,10 @@ class Proposal < ActiveRecord::Base proposal_notifications end + def users_to_notify + (voters + followers).uniq + end + protected def set_responsible_name diff --git a/app/views/proposal_notifications/new.html.erb b/app/views/proposal_notifications/new.html.erb index d75447c79..55341eb58 100644 --- a/app/views/proposal_notifications/new.html.erb +++ b/app/views/proposal_notifications/new.html.erb @@ -7,7 +7,7 @@

<%= 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 %>