From 37e58cd780199502ece02ac797404a955fd01785 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Tue, 14 Jan 2014 12:29:17 +0800 Subject: [PATCH] Added function to see if the module is installed or not --- app/controllers/admin/module_store_controller.rb | 5 ++--- app/views/admin/module_store/index.html.erb | 12 +++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/module_store_controller.rb b/app/controllers/admin/module_store_controller.rb index 44fb040a..d5ef07b4 100644 --- a/app/controllers/admin/module_store_controller.rb +++ b/app/controllers/admin/module_store_controller.rb @@ -18,7 +18,8 @@ class Admin::ModuleStoreController < OrbitBackendController module_app_name = downloaded_file_name.split(/(.zip)/).first #check if the directory exists or not - if Dir.exists?("#{Rails.root}/vendor/built_in_modules/#{module_app_name}") + @module_status = Dir.exists?("#{Rails.root}/vendor/built_in_modules/#{module_app_name}") + if @module_status.eql?(true) flash[:notice] = "This module is already installed" else download_extension(download_link, downloaded_file_name,module_app_name) @@ -42,8 +43,6 @@ class Admin::ModuleStoreController < OrbitBackendController puts %x(unzip "#{downloaded_file_name}") puts %x(mv #{module_app_name} "#{Rails.root}/vendor/built_in_modules/") puts %x(rm "#{downloaded_file_name}") - - Rails.logger.info"@@@@@@@@"+Dir.exists?("#{Rails.root}/vendor/built_in_modules/location").inspect site_restart end end \ No newline at end of file diff --git a/app/views/admin/module_store/index.html.erb b/app/views/admin/module_store/index.html.erb index d6be7adb..b7ae9d30 100644 --- a/app/views/admin/module_store/index.html.erb +++ b/app/views/admin/module_store/index.html.erb @@ -45,7 +45,17 @@ <%= extension["description"].html_safe%> <%= link_to 'Read More', admin_module_store_show_path(extension["_slugs"][0]) %> <%= link_to 'Download', admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-mini btn-success" %> + --> + <% download_link = STORE_CONFIG[:store_settings]["url"] + "/"+ extension["extension"]["extension"]["url"] + downloaded_file_name = extension["extension_filename"] + module_app_name = downloaded_file_name.split(/(.zip)/).first + @module_status = Dir.exists?("#{Rails.root}/vendor/built_in_modules/#{module_app_name}") + %> + <% if @module_status.eql?(true)%> + Installed + <% else %> + <%= link_to 'Download', admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-mini btn-success" %> + <% end %> <% end %>