avoids use class variables on helper

This commit is contained in:
decabeza
2017-09-18 17:52:36 +02:00
parent 1c6a873b6d
commit 4ce06fac4e
2 changed files with 10 additions and 10 deletions

View File

@@ -32,16 +32,16 @@ module ProposalsHelper
Proposal::RETIRE_OPTIONS.collect { |option| [ t("proposals.retire_options.#{option}"), option ] }
end
def can_create_document?
can?(:create, @document) && @proposal.documents.size < Proposal.max_documents_allowed
def can_create_document?(document, proposal)
can?(:create, document) && proposal.documents.size < Proposal.max_documents_allowed
end
def author_of_proposal?
author_of?(@proposal, current_user)
def author_of_proposal?(proposal)
author_of?(proposal, current_user)
end
def current_editable?
current_user && @proposal.editable_by?(current_user)
def current_editable?(proposal)
current_user && proposal.editable_by?(current_user)
end
end

View File

@@ -104,11 +104,11 @@
</div>
<aside class="small-12 medium-3 column">
<% if can_create_document? || author_of_proposal? || current_editable? %>
<% if can_create_document?(@document, @proposal) || author_of_proposal?(@proposal) || current_editable?(@proposal) %>
<div class="sidebar-divider"></div>
<h2><%= t("proposals.show.author") %></h2>
<div class="show-actions-menu">
<% if can_create_document? %>
<% if can_create_document?(@document, @proposal) %>
<%= link_to new_document_path(documentable_id: @proposal, documentable_type: @proposal.class.name, from: request.url),
class: 'button hollow expanded' do %>
<span class="icon-document"></span>
@@ -116,7 +116,7 @@
<% end %>
<% end %>
<% if author_of_proposal? %>
<% if author_of_proposal?(@proposal) %>
<%= link_to new_proposal_notification_path(proposal_id: @proposal.id),
class: 'button hollow expanded' do %>
<span class="icon-no-notification"></span>
@@ -124,7 +124,7 @@
<% end %>
<% end %>
<% if current_editable? %>
<% if current_editable?(@proposal) %>
<%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow expanded' do %>
<span class="icon-edit"></span>
<%= t("proposals.show.edit_proposal_link") %>