Do not display send notification button when proposal is from another author.

This commit is contained in:
taitus
2017-07-13 18:39:17 +02:00
committed by Senén Rodero Rodríguez
parent 556e2598c3
commit b0c571e658
3 changed files with 5 additions and 10 deletions

View File

@@ -4,7 +4,6 @@ class UsersController < ApplicationController
load_and_authorize_resource
helper_method :author?
helper_method :valid_interests_access?
helper_method :author_or_admin?
def show
load_filtered_activity if valid_access?
@@ -81,12 +80,8 @@ class UsersController < ApplicationController
@user.public_interests || authorized_current_user?
end
def author?
@author ||= current_user && (current_user == @user)
end
def author_or_admin?
@author_or_admin ||= current_user && (author? || current_user.administrator?)
def author?(proposal)
proposal.author_id == current_user.id
end
def authorized_current_user?

View File

@@ -50,7 +50,7 @@ module Abilities
can :create, Budget::Investment, budget: { phase: "accepting" }
can :suggest, Budget::Investment, budget: { phase: "accepting" }
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
can :vote, Budget::Investment, budget: { phase: "selecting" }
can :vote, Budget::Investment, budget: { phase: "selecting" }
can [:show, :create], Budget::Ballot, budget: { phase: "balloting" }
can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" }

View File

@@ -5,7 +5,7 @@
<%= proposal.summary %>
</td>
<% if can? :retire_form, proposal %>
<% if author?(proposal) %>
<td class="text-center">
<%= link_to t("users.proposals.send_notification"),
new_proposal_notification_path(proposal_id: proposal.id),
@@ -13,7 +13,7 @@
</td>
<% end %>
<% if can? :new, ProposalNotification, author_id: proposal.author_id %>
<% if author?(proposal) || proposal.retired? %>
<td class="text-center">
<% if proposal.retired? %>
<span class="label alert"><%= t('users.proposals.retired') %></span>