Added documentable feature to legislation processes
This commit is contained in:
@@ -2395,3 +2395,29 @@ table {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.additional-document-link {
|
||||
background: $highlight-soft;
|
||||
border: 1px solid $highlight;
|
||||
display: block;
|
||||
margin: $line-height / 2 0;
|
||||
padding: $line-height / 2;
|
||||
position: relative;
|
||||
|
||||
a {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.icon-document {
|
||||
color: #007bb7;
|
||||
display: inline-block;
|
||||
font-size: rem-calc(24);
|
||||
line-height: $line-height;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.document-divider {
|
||||
background: #fafafa;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,9 @@
|
||||
.proposal-form,
|
||||
.proposal-edit,
|
||||
.polls-form,
|
||||
.poll-question-form {
|
||||
.poll-question-form,
|
||||
.legislation-process-new,
|
||||
.legislation-process-edit {
|
||||
@include direct-uploads;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
:allegations_phase_enabled,
|
||||
:draft_publication_enabled,
|
||||
:result_publication_enabled,
|
||||
:published
|
||||
:published,
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,4 +38,11 @@ module DocumentablesHelper
|
||||
documentable.documents.count >= documentable.class.max_documents_allowed
|
||||
end
|
||||
|
||||
def documentable_humanized_content_type(documentable_class)
|
||||
documentable_class.attachment_content_type.split("/").last.upcase
|
||||
end
|
||||
|
||||
def documentable_humanized_file_size(documentable_class)
|
||||
number_to_human_size(documentable_class.attachment_file_size)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
class Legislation::Process < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
include Documentable
|
||||
documentable max_documents_allowed: 3,
|
||||
max_file_size: 3.megabytes,
|
||||
accepted_content_types: [ "application/pdf" ]
|
||||
|
||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase draft_publication result_publication).freeze
|
||||
|
||||
|
||||
@@ -152,6 +152,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="documents small-12 column">
|
||||
<%= render 'documents/nested_documents', documentable: @process, f: f %>
|
||||
<div class="small-12 column">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :title %>
|
||||
|
||||
22
app/views/documents/_additional_documents.html.erb
Normal file
22
app/views/documents/_additional_documents.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<% if documents.any? %>
|
||||
<div class="document-divider no-margin-top margin-bottom padding">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<div class="additional-document-link">
|
||||
<p>
|
||||
<strong><%= t('proposals.show.title_external_url') %></strong>
|
||||
</p>
|
||||
<% documents.each do |document| %>
|
||||
<p><span class="icon-document"></span>
|
||||
<%= link_to "#{document.title} <small>(#{documentable_humanized_content_type(document)} | \
|
||||
#{documentable_humanized_file_size(document)}</small>)".html_safe,
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
title: t("shared.target_blank_html") %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
<%= render 'legislation/processes/header', process: @process, header: :full %>
|
||||
|
||||
<%= render 'documents/additional_documents', documents: @process.documents %>
|
||||
|
||||
<%= render 'key_dates', process: @process, phase: :debate %>
|
||||
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user