From a30a0489ba01ec7ed0cdec52357ab2bcf6f80c9b Mon Sep 17 00:00:00 2001 From: David Carlos Date: Thu, 16 Apr 2015 19:28:03 +0000 Subject: [PATCH] Retrive version logic. --- controllers/software_communities_plugin_controller.rb | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+), 0 deletions(-) diff --git a/controllers/software_communities_plugin_controller.rb b/controllers/software_communities_plugin_controller.rb index b275a72..e3a3902 100644 --- a/controllers/software_communities_plugin_controller.rb +++ b/controllers/software_communities_plugin_controller.rb @@ -6,6 +6,61 @@ class SoftwareCommunitiesPluginController < ApplicationController return render :json=>{} if !request.xhr? || params[:query].nil? data = if params[:query].empty? + LicenseInfo.all + else + LicenseInfo.where("version ILIKE ?", "%#{params[:query]}%").select("id, version") + end + render :json=> data.collect { |license| + {:id=>license.id, :label=>license.version} + } + + end + + def download_file + download_block = Block.find(params[:block_id]) + + file_link = DownloadFileHelper.get_file_link(download_block, params[:link_index].to_i) + file = DownloadFileHelper.get_file(file_link) + + owner = download_block.owner + download_software = owner.software_info + download_software.download_counter += 1 + + if not file.nil? + file_body = send_file file.full_filename + + self.response.body = Enumerator::new do |enum| + file_body.each {|file_data| enum << file_data} + + # Only save when the download is finished + download_software.save! + end + else + download_software.save! + + # If it is not in noosfero(like a external link), + # just send the user to this location + redirect_to file_link + end + end + + def hide_registration_incomplete_percentage + response = false + + if request.xhr? && params[:hide] + session[:hide_incomplete_percentage] = true + response = session[:hide_incomplete_percentage] + end + + render :json=>response.to_json + end + + def create_institution + @show_sisp_field = environment.admins.include?(current_user.person) + @state_list = get_state_list() +>>>>>>> e8d6ff3... Retrive version logic. + + data = if params[:query].empty? LicenseInfo.all else LicenseInfo.where("version ILIKE ?", "%#{params[:query]}%").select("id, version") -- libgit2 0.21.2