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)
|
@notification = ProposalNotification.new(proposal_notification_params)
|
||||||
@proposal = Proposal.find(proposal_notification_params[:proposal_id])
|
@proposal = Proposal.find(proposal_notification_params[:proposal_id])
|
||||||
if @notification.save
|
if @notification.save
|
||||||
notification_users.each do |user|
|
@proposal.users_to_notify.each do |user|
|
||||||
Notification.add(user.id, @notification)
|
Notification.add(user.id, @notification)
|
||||||
end
|
end
|
||||||
redirect_to @notification, notice: I18n.t("flash.actions.create.proposal_notification")
|
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)
|
params.require(:proposal_notification).permit(:title, :body, :proposal_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notification_users
|
|
||||||
(@proposal.voters + @proposal.followers).uniq
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ class Proposal < ActiveRecord::Base
|
|||||||
proposal_notifications
|
proposal_notifications
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def users_to_notify
|
||||||
|
(voters + followers).uniq
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_responsible_name
|
def set_responsible_name
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="callout primary">
|
<div class="callout primary">
|
||||||
<p>
|
<p>
|
||||||
<%= t("proposal_notifications.new.info_about_receivers_html",
|
<%= 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_page: link_to(t("proposal_notifications.new.proposal_page"),
|
||||||
proposal_path(@proposal, anchor: "comments"))).html_safe %>
|
proposal_path(@proposal, anchor: "comments"))).html_safe %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user