Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documents to milestones #2191

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
Make Budget::Investment::Milestone class Documentable.
Add fields to the milestone form so that the admin can attach 0, 1 or multiple documents.
Add column to milestone list with a link to documents (if there is any).
Make documents accessible from the milestone view for users.
  • Loading branch information
iagirre committed Dec 14, 2017
commit 01a8c559367405e2d5646a051ed82795dacc4278
3 changes: 2 additions & 1 deletion app/assets/stylesheets/participation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@
.draft-panels,
.debate-questions,
.communities-show,
.topic-show {
.topic-show,
.milestone-content {

p {
word-wrap: break-word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def destroy
def milestone_params
params.require(:budget_investment_milestone)
.permit(:title, :description, :budget_investment_id,
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end

def load_budget_investment
Expand Down
4 changes: 4 additions & 0 deletions app/models/budget/investment/milestone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class Budget
class Investment
class Milestone < ActiveRecord::Base
include Imageable
include Documentable
documentable max_documents_allowed: 3,
max_file_size: 3.megabytes,
accepted_content_types: [ "application/pdf" ]

belongs_to :investment

Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/budget_investment_milestones/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<%= f.text_area :description, rows: 5 %>
<%= render 'images/admin_image', imageable: @milestone, f: f %>

<hr>
<div class="documents">
<%= render 'documents/nested_documents', documentable: @milestone, f: f %>
</div>

<%= f.submit nil, class: "button success" %>
<% end %>
11 changes: 11 additions & 0 deletions app/views/admin/budget_investments/_milestones.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<th><%= t("admin.milestones.index.table_title") %></th>
<th><%= t("admin.milestones.index.table_description") %></th>
<th><%= t("admin.milestones.index.image") %></th>
<th><%= t("admin.milestones.index.documents") %></th>
<th><%= t("admin.milestones.index.table_actions") %></th>
</tr>
</thead>
Expand All @@ -24,6 +25,16 @@
<td class="small">
<%= link_to t("admin.milestones.index.show_image"), milestone.image_url(:large), target: :_blank if milestone.image.present? %>
</td>
<td class="small">
<% if milestone.documents.present? %>
<% milestone.documents.each do |document| %>
<%= link_to document.title,
document.attachment.url,
target: "_blank",
rel: "" %><br>
<% end %>
<% end %>
</td>
<td>
<%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
method: :delete,
Expand Down
14 changes: 14 additions & 0 deletions app/views/budgets/investments/_milestones.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
</span>
<%= image_tag(milestone.image_url(:large), {alt: milestone.image.title, class: "margin", id: "image_#{milestone.id}"}) if milestone.image.present? %>
<p><%= milestone.description %></p>
<% if milestone.documents.present? %>
<div class="document-link text-center">
<p>
<span class="icon-document"></span>&nbsp;
<strong><%= t('proposals.show.title_external_url') %></strong>
</p>
<% milestone.documents.each do |document| %>
<%= link_to document.title,
document.attachment.url,
target: "_blank",
rel: "" %><br>
<% end %>
</div>
<% end %>
</div>
</li>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ en:
no_milestones: "Don't have defined milestones"
image: "Image"
show_image: "Show image"
documents: "Documents"
new:
creating: Create milestone
edit:
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ es:
no_milestones: "No hay hitos definidos"
image: "Imagen"
show_image: "Ver imagen"
documents: "Documentos"
new:
creating: Crear hito
edit:
Expand Down