Add documentable to proposal model.

This commit is contained in:
Senén Rodero Rodríguez
2017-07-21 14:00:09 +02:00
parent a2130689ed
commit 586776efd8
6 changed files with 21 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ class ProposalsController < ApplicationController
def show
super
@notifications = @proposal.notifications
@document = Document.new(documentable: @proposal)
redirect_to proposal_path(@proposal), status: :moved_permanently if request.path != proposal_path(@proposal)
end

View File

@@ -9,6 +9,7 @@ class Proposal < ActiveRecord::Base
include HasPublicAuthor
include Graphqlable
include Followable
include Documentable
acts_as_votable
acts_as_paranoid column: :hidden_at

View File

@@ -25,7 +25,6 @@
</h3>
<% end %>
</li>
</ul>
</div>
</div>

View File

@@ -17,6 +17,14 @@
</h3>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-documents" do %>
<h3>
<%= t("documents.tab") %>
(<%= @proposal.documents.count %>)
</h3>
<% end %>
</li>
</ul>
</div>
</div>

View File

@@ -16,6 +16,12 @@
<div class="small-12 medium-9 column">
<%= back_link_to %>
<% if can? :create, @document %>
<%= link_to t("documents.upload_document"),
new_document_path(documentable_id: @proposal, documentable_type: @proposal.class.name, from: request.url),
class: 'button hollow float-right' %>
<% end %>
<% if author_of?(@proposal, current_user) %>
<%= link_to t("proposals.show.send_notification"), new_proposal_notification_path(proposal_id: @proposal.id),
class: 'button hollow float-right' %>
@@ -156,4 +162,8 @@
<div class="tabs-panel is-active" id="tab-comments">
<%= render "proposals/comments" %>
</div>
<div class="tabs-panel" id="tab-documents">
<%= render 'documents/documents', documents: @proposal.documents %>
</div>
</div>