Commit 3b8b5180b6efeb06cf4ca2391c640256d403d9b4

Authored by Luciano Prestes
1 parent 8d4c86ea

software-communities: refactoring namespaces

- Controllers

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
src/noosfero-spb/software_communities/controllers/software_communities_plugin_controller.rb
@@ -5,8 +5,8 @@ class SoftwareCommunitiesPluginController &lt; ApplicationController @@ -5,8 +5,8 @@ class SoftwareCommunitiesPluginController &lt; ApplicationController
5 def get_license_data 5 def get_license_data
6 return render :json=>{} if !request.xhr? || params[:query].nil? 6 return render :json=>{} if !request.xhr? || params[:query].nil?
7 7
8 - data = LicenseHelper.find_licenses(params[:query]) if params[:query]  
9 - data ||= LicenseInfo.all 8 + data = SoftwareCommunitiesPlugin::LicenseHelper.find_licenses(params[:query]) if params[:query]
  9 + data ||= SoftwareCommunitiesPlugin::LicenseInfo.all
10 10
11 render :json=> data.collect { |license| 11 render :json=> data.collect { |license|
12 {:id=>license.id, :label=>license.version} 12 {:id=>license.id, :label=>license.version}
@@ -42,7 +42,7 @@ class SoftwareCommunitiesPluginController &lt; ApplicationController @@ -42,7 +42,7 @@ class SoftwareCommunitiesPluginController &lt; ApplicationController
42 protected 42 protected
43 43
44 def get_model_by_params_field 44 def get_model_by_params_field
45 - return DatabaseDescription unless params[:field] == "software_language"  
46 - return ProgrammingLanguage 45 + return SoftwareCommunitiesPlugin::DatabaseDescription unless params[:field] == "software_language"
  46 + return SoftwareCommunitiesPlugin::ProgrammingLanguage
47 end 47 end
48 end 48 end
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
@@ -10,10 +10,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -10,10 +10,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
10 @community = Community.new(params[:community]) 10 @community = Community.new(params[:community])
11 @community.environment = environment 11 @community.environment = environment
12 12
13 - @license_info = LicenseInfo.find_by_id(params[:license][:license_infos_id]) if params[:license]  
14 - @license_info ||= LicenseInfo.new 13 + @license_info = SoftwareCommunitiesPlugin::LicenseInfo.find_by_id(params[:license][:license_infos_id]) if params[:license]
  14 + @license_info ||= SoftwareCommunitiesPlugin::LicenseInfo.new
15 15
16 - @software_info = SoftwareInfo.new(params[:software_info]) 16 + @software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new(params[:software_info])
17 @software_info.community = @community 17 @software_info.community = @community
18 @software_info.license_info = @license_info 18 @software_info.license_info = @license_info
19 19
@@ -90,7 +90,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -90,7 +90,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
90 def create_software 90 def create_software
91 @software_info = @profile.software_info 91 @software_info = @profile.software_info
92 params[:software][:public_software] ||= false unless @software_info.public_software? 92 params[:software][:public_software] ||= false unless @software_info.public_software?
93 - @license = LicenseInfo.find(params[:license][:license_infos_id]) 93 + @license = SoftwareCommunitiesPlugin::LicenseInfo.find(params[:license][:license_infos_id])
94 @software_info.license_info = @license 94 @software_info.license_info = @license
95 @software_info.update_attributes(params[:software]) 95 @software_info.update_attributes(params[:software])
96 96
@@ -109,10 +109,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -109,10 +109,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
109 end 109 end
110 110
111 def create_list_model_helpers 111 def create_list_model_helpers
112 - @list_libraries = LibraryHelper.list_library(params[:library])  
113 - @list_languages = SoftwareLanguageHelper.list_language(params[:language])  
114 - @list_databases = DatabaseHelper.list_database(params[:database])  
115 - @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) 112 + @list_libraries = SoftwareCommunitiesPlugin::LibraryHelper.list_library(params[:library])
  113 + @list_languages = SoftwareCommunitiesPlugin::SoftwareLanguageHelper.list_language(params[:language])
  114 + @list_databases = SoftwareCommunitiesPlugin::DatabaseHelper.list_database(params[:database])
  115 + @list_operating_systems = SoftwareCommunitiesPlugin::OperatingSystemHelper.list_operating_system(params[:operating_system])
116 end 116 end
117 117
118 def send_software_to_moderation 118 def send_software_to_moderation
@@ -122,7 +122,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -122,7 +122,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
122 another_license_version = params[:license][:version] 122 another_license_version = params[:license][:version]
123 another_license_link = params[:license][:link] 123 another_license_link = params[:license][:link]
124 end 124 end
125 - @software_info = SoftwareInfo.create_after_moderation(user, 125 + @software_info = SoftwareCommunitiesPlugin::SoftwareInfo.create_after_moderation(user,
126 params[:software_info].merge({ 126 params[:software_info].merge({
127 :environment => environment, 127 :environment => environment,
128 :name => params[:community][:name], 128 :name => params[:community][:name],
@@ -158,7 +158,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -158,7 +158,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
158 @another_license_version = "" 158 @another_license_version = ""
159 @another_license_link = "" 159 @another_license_link = ""
160 160
161 - license_another = LicenseInfo.find_by_version("Another") 161 + license_another = SoftwareCommunitiesPlugin::LicenseInfo.find_by_version("Another")
162 if license_another && @software_info.license_info_id == license_another.id 162 if license_another && @software_info.license_info_id == license_another.id
163 @license_version = "Another" 163 @license_version = "Another"
164 @another_license_version = @software_info.license_info.version 164 @another_license_version = @software_info.license_info.version
@@ -167,7 +167,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -167,7 +167,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
167 end 167 end
168 168
169 def set_software_as_template 169 def set_software_as_template
170 - software_template = SoftwareHelper.software_template 170 + software_template = SoftwareCommunitiesPlugin::SoftwareHelper.software_template
171 software_valid = !software_template.blank? && !params['community'].blank? 171 software_valid = !software_template.blank? && !params['community'].blank?
172 if software_valid 172 if software_valid
173 params['community']['template_id'] = software_template.id if software_valid 173 params['community']['template_id'] = software_template.id if software_valid
src/noosfero-spb/software_communities/controllers/software_communities_plugin_profile_controller.rb
@@ -9,11 +9,11 @@ class SoftwareCommunitiesPluginProfileController &lt; ProfileController @@ -9,11 +9,11 @@ class SoftwareCommunitiesPluginProfileController &lt; ProfileController
9 } 9 }
10 10
11 def download_file 11 def download_file
12 - download_block = DownloadBlock.find_by_id params[:block] 12 + download_block = SoftwareCommunitiesPlugin::DownloadBlock.find_by_id params[:block]
13 index = params[:download_index].to_i 13 index = params[:download_index].to_i
14 14
15 if download_block and (index < download_block.downloads.size) 15 if download_block and (index < download_block.downloads.size)
16 - download = Download.new(download_block.downloads[index]) 16 + download = SoftwareCommunitiesPlugin::Download.new(download_block.downloads[index])
17 17
18 download.total_downloads += 1 18 download.total_downloads += 1
19 download_block.downloads[index] = download.to_hash 19 download_block.downloads[index] = download.to_hash