Commit e7af48474d154790cd24b6d3ac94c403ae366e9b
1 parent
0e741a07
Exists in
refactor_download_block
Adds action/ajax to fetch uploaded files
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: ArthurJahn <stutrzbecher@gmail.com>
Showing
3 changed files
with
25 additions
and
10 deletions
Show diff stats
src/noosfero-spb/software_communities/controllers/software_communities_plugin_controller.rb
@@ -15,7 +15,10 @@ class SoftwareCommunitiesPluginController < ApplicationController | @@ -15,7 +15,10 @@ class SoftwareCommunitiesPluginController < ApplicationController | ||
15 | end | 15 | end |
16 | 16 | ||
17 | def get_block_template | 17 | def get_block_template |
18 | - render 'box_organizer/_download_list_template', :layout => false | 18 | + # render 'box_organizer/_download_list_template', :layout => false |
19 | + profile = Profile.find_by_identifier(params[:profile]) | ||
20 | + downloads_folder = Folder.where(name: "Downloads", type: "Folder", profile_id: profile.id) | ||
21 | + render 'box_organizer/_download_uploaded_files', :locals=>{ :uploaded_files => get_node(downloads_folder) } | ||
19 | end | 22 | end |
20 | 23 | ||
21 | def get_field_data | 24 | def get_field_data |
@@ -45,4 +48,15 @@ class SoftwareCommunitiesPluginController < ApplicationController | @@ -45,4 +48,15 @@ class SoftwareCommunitiesPluginController < ApplicationController | ||
45 | return DatabaseDescription unless params[:field] == "software_language" | 48 | return DatabaseDescription unless params[:field] == "software_language" |
46 | return ProgrammingLanguage | 49 | return ProgrammingLanguage |
47 | end | 50 | end |
51 | + | ||
52 | + def get_node(articles) | ||
53 | + nodes = [] | ||
54 | + articles.each do |article| | ||
55 | + if article.type == "UploadedFile" | ||
56 | + nodes << article | ||
57 | + end | ||
58 | + nodes += get_node(article.children) | ||
59 | + end | ||
60 | + nodes | ||
61 | + end | ||
48 | end | 62 | end |
src/noosfero-spb/software_communities/public/blocks/software-download.js
@@ -9,16 +9,14 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos | @@ -9,16 +9,14 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos | ||
9 | var $download_html_template; | 9 | var $download_html_template; |
10 | 10 | ||
11 | function getDownloadListTemplate() { | 11 | function getDownloadListTemplate() { |
12 | - var block_template = sessionStorage.getItem('download_list_block_template'); | ||
13 | - | ||
14 | - if(block_template && block_template.length > 0) { | ||
15 | - $download_html_template = block_template; | ||
16 | - } else { | ||
17 | - $.get(AJAX_URL.get_download_template, function(response) { | 12 | + $.get(AJAX_URL.get_download_template, { profile: noosfero.profile }) |
13 | + .done(function(response) { | ||
14 | + console.log("asdasd"); | ||
15 | + console.log(response); | ||
18 | $download_html_template = response; | 16 | $download_html_template = response; |
19 | - sessionStorage.setItem('download_list_block_template', response); | ||
20 | - }); | ||
21 | - } | 17 | + }).fail(function() { |
18 | + alert( "error" ); | ||
19 | + }); | ||
22 | } | 20 | } |
23 | 21 | ||
24 | 22 |
src/noosfero-spb/software_communities/views/box_organizer/_download_uploaded_files.html.erb
0 → 100644