From 586776efd80791635f214d539f343c80e1c76d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 21 Jul 2017 14:00:09 +0200 Subject: [PATCH] Add documentable to proposal model. --- app/controllers/proposals_controller.rb | 1 + app/models/proposal.rb | 1 + app/views/budgets/investments/_filter_subnav.html.erb | 1 - app/views/proposals/_filter_subnav.html.erb | 8 ++++++++ app/views/proposals/show.html.erb | 10 ++++++++++ spec/features/proposals_spec.rb | 1 + 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 8b75a10cf..a3d722e92 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -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 diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 21335c5a5..26adc5e65 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -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 diff --git a/app/views/budgets/investments/_filter_subnav.html.erb b/app/views/budgets/investments/_filter_subnav.html.erb index 8faa221ff..01fef4657 100644 --- a/app/views/budgets/investments/_filter_subnav.html.erb +++ b/app/views/budgets/investments/_filter_subnav.html.erb @@ -25,7 +25,6 @@ <% end %> - diff --git a/app/views/proposals/_filter_subnav.html.erb b/app/views/proposals/_filter_subnav.html.erb index 6347d56b0..fece62a17 100644 --- a/app/views/proposals/_filter_subnav.html.erb +++ b/app/views/proposals/_filter_subnav.html.erb @@ -17,6 +17,14 @@ <% end %> +
  • + <%= link_to "#tab-documents" do %> +

    + <%= t("documents.tab") %> + (<%= @proposal.documents.count %>) +

    + <% end %> +
  • diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index cf22ad315..3fad9a9f7 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -16,6 +16,12 @@
    <%= 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 @@
    <%= render "proposals/comments" %>
    + +
    + <%= render 'documents/documents', documents: @proposal.documents %> +
    diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 1cb39a579..c1b5b1a37 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1227,6 +1227,7 @@ feature 'Proposals' do end it_behaves_like "followable", "proposal", "proposal_path", { "id": "id" } + it_behaves_like "documentable", "proposal", "proposal_path", { "id": "id" } scenario 'Erased author' do user = create(:user)