Commit af119b179323bb2daaba064b23880f59229c87b3
Committed by
Leandro Santos
1 parent
1217394d
Exists in
staging
Add download button for images in gallery
Signed-off-by: Fagner Rodrigues <fagner128@gmail.com> Signed-off-by: Gustavo Cavalcante <gustavo.cavalcante.oliveira@live.com> Signed-off-by: Iago Rodrigues <iago006@hotmailcom> Signed-off-by: Karine Valença <valenca.karine@gmail.com> Signed-off-by: Murilo Duarte <muriloduartegoncalves@hotmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
6 changed files
with
40 additions
and
2 deletions
Show diff stats
app/helpers/article_helper.rb
... | ... | @@ -60,7 +60,9 @@ module ArticleHelper |
60 | 60 | 'div', |
61 | 61 | check_box(:article, :display_versions) + |
62 | 62 | content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions') |
63 | - ) : '') | |
63 | + ) : '') + | |
64 | + | |
65 | + (self.respond_to?(:extra_options) ? self.extra_options : "") | |
64 | 66 | ) |
65 | 67 | end |
66 | 68 | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +module GalleryHelper | |
2 | + | |
3 | + include ArticleHelper | |
4 | + | |
5 | + def extra_options | |
6 | + content_tag( | |
7 | + 'div', | |
8 | + check_box(:article, :allow_download) + | |
9 | + content_tag('label', _('Allow images from this gallery to be downloaded'), :for => 'article_allow_download') | |
10 | + ) | |
11 | + end | |
12 | + | |
13 | +end | ... | ... |
app/models/gallery.rb
app/views/file_presenter/_image.html.erb
... | ... | @@ -30,7 +30,10 @@ |
30 | 30 | |
31 | 31 | <img src="<%= [Noosfero.root, image.public_filename(:display)].join %>" class="<%=image.css_class_name%>"> |
32 | 32 | |
33 | +<% if image.parent.is_a?(Gallery) && image.parent.allow_download %> | |
34 | + <%= link_to _('Download image'), [Noosfero.root, image.public_filename(:display)].join, download: image.filename, id: 'download-image-id', class: "button with-text icon-save" %> | |
35 | +<% end %> | |
36 | + | |
33 | 37 | <div class="uploaded-file-description <%= 'empty' if image.abstract.blank? %>"> |
34 | 38 | <%= image.abstract %> |
35 | 39 | </div> |
36 | - | ... | ... |
public/stylesheets/zoomable-image.scss
test/functional/content_viewer_controller_test.rb
... | ... | @@ -604,6 +604,22 @@ class ContentViewerControllerTest < ActionController::TestCase |
604 | 604 | assert_template 'view_page' |
605 | 605 | end |
606 | 606 | |
607 | + should 'display download button to images in galleries that allow downloads' do | |
608 | + login_as(profile.identifier) | |
609 | + gallery = Gallery.create!(:name => 'gallery1', :profile => profile, :allow_download => true) | |
610 | + image = UploadedFile.create!(:profile => profile, :parent => gallery, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) | |
611 | + get :view_page, :profile => profile.identifier, :page => image.path, :view => true | |
612 | + assert_tag :tag => 'a', :content => 'Download image', :attributes => { :id => 'download-image-id' } | |
613 | + end | |
614 | + | |
615 | + should 'not display download button to images in galleries that do not allow downloads' do | |
616 | + login_as(profile.identifier) | |
617 | + gallery = Gallery.create!(:name => 'gallery1', :profile => profile, :allow_download => false) | |
618 | + image = UploadedFile.create!(:profile => profile, :parent => gallery, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) | |
619 | + get :view_page, :profile => profile.identifier, :page => image.path, :view => true | |
620 | + assert_no_tag :tag => 'a', :content => 'Download image', :attributes => { :id => 'download-image-id' } | |
621 | + end | |
622 | + | |
607 | 623 | should "display 'Upload files' when create children of image gallery" do |
608 | 624 | login_as(profile.identifier) |
609 | 625 | f = Gallery.create!(:name => 'gallery', :profile => profile) | ... | ... |