Merge pull request #2585 from consul/document_upload_setting

Document upload setting
This commit is contained in:
Alberto Calderón Queimadelos
2018-04-10 13:59:32 +02:00
committed by GitHub
12 changed files with 68 additions and 15 deletions

View File

@@ -23,9 +23,11 @@
</div> </div>
<% end %> <% end %>
<% if feature?(:allow_attached_documents) %>
<div class="documents small-12 column"> <div class="documents small-12 column">
<%= render 'documents/nested_documents', documentable: @investment, f: f %> <%= render 'documents/nested_documents', documentable: @investment, f: f %>
</div> </div>
<% end %>
<% if feature?(:map) %> <% if feature?(:map) %>
<div class="small-12 column"> <div class="small-12 column">

View File

@@ -51,9 +51,11 @@
</p> </p>
<% end %> <% end %>
<% if feature?(:allow_attached_documents) %>
<%= render 'documents/documents', <%= render 'documents/documents',
documents: investment.documents, documents: investment.documents,
max_documents_allowed: Budget::Investment.max_documents_allowed %> max_documents_allowed: Budget::Investment.max_documents_allowed %>
<% end %>
<%= render 'shared/tags', taggable: investment %> <%= render 'shared/tags', taggable: investment %>

View File

@@ -80,9 +80,11 @@
<h4><%= @proposal.question %></h4> <h4><%= @proposal.question %></h4>
<% if feature?(:allow_attached_documents) %>
<%= render 'documents/documents', <%= render 'documents/documents',
documents: @proposal.documents, documents: @proposal.documents,
max_documents_allowed: Proposal.max_documents_allowed %> max_documents_allowed: Proposal.max_documents_allowed %>
<% end %>
<%= render 'shared/tags', taggable: @proposal %> <%= render 'shared/tags', taggable: @proposal %>

View File

@@ -52,9 +52,11 @@
</div> </div>
<% end %> <% end %>
<% if feature?(:allow_attached_documents) %>
<div class="documents small-12 column"> <div class="documents small-12 column">
<%= render 'documents/nested_documents', documentable: @proposal, f: f %> <%= render 'documents/nested_documents', documentable: @proposal, f: f %>
</div> </div>
<% end %>
<div class="small-12 medium-6 column"> <div class="small-12 medium-6 column">
<%= f.label :geozone_id, t("proposals.form.geozone") %> <%= f.label :geozone_id, t("proposals.form.geozone") %>

View File

@@ -106,9 +106,11 @@
</div> </div>
<% end %> <% end %>
<% if feature?(:allow_attached_documents) %>
<%= render 'documents/documents', <%= render 'documents/documents',
documents: @proposal.documents, documents: @proposal.documents,
max_documents_allowed: Proposal.max_documents_allowed %> max_documents_allowed: Proposal.max_documents_allowed %>
<% end %>
<%= render 'shared/tags', taggable: @proposal %> <%= render 'shared/tags', taggable: @proposal %>

View File

@@ -45,6 +45,7 @@ en:
community: Community on proposals and investments community: Community on proposals and investments
map: Proposals and budget investments geolocation map: Proposals and budget investments geolocation
allow_images: Allow upload and show images allow_images: Allow upload and show images
allow_attached_documents: Allow upload and show of attached documents
map_latitude: Latitude map_latitude: Latitude
map_longitude: Longitude map_longitude: Longitude
map_zoom: Zoom map_zoom: Zoom

View File

@@ -45,6 +45,7 @@ es:
community: Comunidad en propuestas y proyectos de gasto community: Comunidad en propuestas y proyectos de gasto
map: Geolocalización de propuestas y proyectos de gasto map: Geolocalización de propuestas y proyectos de gasto
allow_images: Permitir subir y mostrar imágenes allow_images: Permitir subir y mostrar imágenes
allow_attached_documents: Permitir creación de documentos adjuntos
map_latitude: Latitud map_latitude: Latitud
map_longitude: Longitud map_longitude: Longitud
map_zoom: Zoom map_zoom: Zoom

View File

@@ -43,6 +43,7 @@ section "Creating Settings" do
Setting.create(key: 'feature.community', value: "true") Setting.create(key: 'feature.community', value: "true")
Setting.create(key: 'feature.map', value: "true") Setting.create(key: 'feature.map', value: "true")
Setting.create(key: 'feature.allow_images', value: "true") Setting.create(key: 'feature.allow_images', value: "true")
Setting.create(key: 'feature.allow_attached_documents', value: "true")
Setting.create(key: 'feature.public_stats', value: "true") Setting.create(key: 'feature.public_stats', value: "true")
Setting.create(key: 'feature.guides', value: nil) Setting.create(key: 'feature.guides', value: nil)

View File

@@ -85,6 +85,7 @@ Setting['feature.user.recommendations'] = true
Setting['feature.community'] = true Setting['feature.community'] = true
Setting['feature.map'] = nil Setting['feature.map'] = nil
Setting['feature.allow_images'] = true Setting['feature.allow_images'] = true
Setting['feature.allow_attached_documents'] = true
Setting['feature.guides'] = nil Setting['feature.guides'] = nil
# Spending proposals feature flags # Spending proposals feature flags

View File

@@ -8,4 +8,9 @@ namespace :settings do
per_page_code_setting.destroy if per_page_code_setting.present? per_page_code_setting.destroy if per_page_code_setting.present?
end end
desc "Create new Attached Documents feature setting"
task create_attached_documents_setting: :environment do
Setting['feature.allow_attached_documents'] = true
end
end end

View File

@@ -68,6 +68,23 @@ shared_examples "documentable" do |documentable_factory_name,
end end
describe "When allow attached documents setting is disabled" do
before do
Setting['feature.allow_attached_documents'] = false
end
after do
Setting['feature.allow_attached_documents'] = true
end
scenario "Documents list should not be available" do
login_as(create(:user))
visit send(documentable_path, arguments)
expect(page).not_to have_css("#documents")
end
end
end end
context "Destroy" do context "Destroy" do

View File

@@ -285,6 +285,23 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
end end
describe "When allow attached documents setting is disabled" do
before do
Setting['feature.allow_attached_documents'] = false
end
after do
Setting['feature.allow_attached_documents'] = true
end
scenario "Add new document button should not be available" do
login_as user_to_login
visit send(path, arguments)
expect(page).not_to have_content("Add new document")
end
end
end end
end end