Commit bbabe06db427da816cad8f67905038d708ed3779
1 parent
b3d90985
Exists in
master
and in
5 other branches
Remove fields of software search.
-Software search now is only with its name. Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
4 changed files
with
2 additions
and
377 deletions
Show diff stats
lib/mpog_software_plugin.rb
| ... | ... | @@ -128,10 +128,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
| 128 | 128 | community_block = proc do |
| 129 | 129 | results = [] |
| 130 | 130 | if params[:type] == "Software" |
| 131 | - softwares = SoftwareInfo.search(params[:name], params[:database_description][:id], | |
| 132 | - params[:programming_language][:id], params[:operating_system][:id], | |
| 133 | - params[:license_info][:id], params[:e_ping], params[:e_mag], params[:internacionalizable], | |
| 134 | - params[:icp_brasil], params[:e_arq], params[:software_categories]) | |
| 131 | + softwares = SoftwareInfo.search(params[:name]) | |
| 135 | 132 | communities = [] |
| 136 | 133 | softwares.each do |s| |
| 137 | 134 | communities << s.community | ... | ... |
lib/software_info.rb
| ... | ... | @@ -38,62 +38,10 @@ class SoftwareInfo < ActiveRecord::Base |
| 38 | 38 | values << "%#{name}%" << "%#{name}%" |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | - unless database_description_id.blank? | |
| 42 | - like_sql << "software_databases.database_description_id = ? AND " | |
| 43 | - values << "#{database_description_id}" | |
| 44 | - end | |
| 45 | - | |
| 46 | - unless programming_language_id.blank? | |
| 47 | - like_sql << "software_languages.programming_language_id = ? AND " | |
| 48 | - values << "#{programming_language_id}" | |
| 49 | - end | |
| 50 | - | |
| 51 | - unless operating_system_name_id.blank? | |
| 52 | - like_sql << "operating_systems.operating_system_name_id = ? AND " | |
| 53 | - values << "#{operating_system_name_id}" | |
| 54 | - end | |
| 55 | - | |
| 56 | - unless license_info_id.blank? | |
| 57 | - like_sql << "license_info_id = ? AND " | |
| 58 | - values << "#{license_info_id}" | |
| 59 | - end | |
| 60 | - | |
| 61 | - unless internacionalizable.blank? | |
| 62 | - like_sql << "intern = ? AND " | |
| 63 | - values << "#{internacionalizable}" | |
| 64 | - end | |
| 65 | - | |
| 66 | - unless icp_brasil.blank? | |
| 67 | - like_sql << "icp_brasil = ? AND " | |
| 68 | - values << "#{icp_brasil}" | |
| 69 | - end | |
| 70 | - | |
| 71 | - unless e_ping.blank? | |
| 72 | - like_sql << "e_ping = ? AND " | |
| 73 | - values << "#{e_ping}" | |
| 74 | - end | |
| 75 | - | |
| 76 | - unless e_mag.blank? | |
| 77 | - like_sql << "e_mag = ? AND " | |
| 78 | - values << "#{e_mag}" | |
| 79 | - end | |
| 80 | - | |
| 81 | - unless e_arq.blank? | |
| 82 | - like_sql << "e_arq = ? AND " | |
| 83 | - values << "#{e_arq}" | |
| 84 | - end | |
| 85 | - | |
| 86 | - unless software_categories.blank? | |
| 87 | - software_categories = software_categories.gsub(' ', '').underscore | |
| 88 | - like_sql << "software_categories.#{software_categories} = ? AND " | |
| 89 | - values << "true" | |
| 90 | - end | |
| 91 | - | |
| 92 | 41 | like_sql = like_sql[0..like_sql.length-5] |
| 93 | 42 | |
| 94 | 43 | { |
| 95 | - :joins => [:community, :software_databases, :software_languages, | |
| 96 | - :operating_systems, :software_categories], | |
| 44 | + :joins => [:community], | |
| 97 | 45 | :conditions=>[like_sql, *values] |
| 98 | 46 | } |
| 99 | 47 | } | ... | ... |
test/functional/search_controller_test.rb
| ... | ... | @@ -105,190 +105,6 @@ class SearchControllerTest < ActionController::TestCase |
| 105 | 105 | assert_includes assigns(:searches)[:communities][:results], software.community |
| 106 | 106 | end |
| 107 | 107 | |
| 108 | - should "search for software by database" do | |
| 109 | - fields = software_fields | |
| 110 | - software = create_software fields | |
| 111 | - software.software_databases.clear() | |
| 112 | - software.software_databases << SoftwareDatabase.last | |
| 113 | - software.save! | |
| 114 | - | |
| 115 | - params = {"type"=>"Software", "query"=>"", "name"=>"", | |
| 116 | - "database_description"=>{"id"=>SoftwareDatabase.last.database_description.id}, | |
| 117 | - "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "software_categories"=>"", | |
| 118 | - "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 119 | - "commit"=>"Search"} | |
| 120 | - get :communities, params | |
| 121 | - | |
| 122 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 123 | - end | |
| 124 | - | |
| 125 | - should "search for software by programming language" do | |
| 126 | - fields = software_fields | |
| 127 | - software = create_software fields | |
| 128 | - software.software_languages.clear() | |
| 129 | - software.software_languages << SoftwareLanguage.last | |
| 130 | - software.save! | |
| 131 | - | |
| 132 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 133 | - "programming_language"=>{"id"=>SoftwareLanguage.last.programming_language.id}, | |
| 134 | - "operating_system"=>{"id"=>""}, "software_categories"=>"", | |
| 135 | - "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 136 | - "commit"=>"Search"} | |
| 137 | - get :communities, params | |
| 138 | - | |
| 139 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 140 | - end | |
| 141 | - | |
| 142 | - should "search for software by operating system" do | |
| 143 | - fields = software_fields | |
| 144 | - software = create_software fields | |
| 145 | - software.save! | |
| 146 | - software.operating_systems.clear() | |
| 147 | - software.operating_systems << OperatingSystem.last | |
| 148 | - software.save! | |
| 149 | - | |
| 150 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 151 | - "programming_language"=>{"id"=>""}, | |
| 152 | - "operating_system"=>{"id"=>OperatingSystemName.last.id}, | |
| 153 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 154 | - "commit"=>"Search"} | |
| 155 | - get :communities, params | |
| 156 | - | |
| 157 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 158 | - end | |
| 159 | - | |
| 160 | - should "search for software by software categories" do | |
| 161 | - fields = software_fields | |
| 162 | - software = create_software fields | |
| 163 | - software.software_categories.habitation = true | |
| 164 | - software.software_categories.save! | |
| 165 | - software.save | |
| 166 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 167 | - "programming_language"=>{"id"=>""}, | |
| 168 | - "operating_system"=>{"id"=>""}, | |
| 169 | - "software_categories"=>"habitation", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 170 | - "commit"=>"Search"} | |
| 171 | - get :communities, params | |
| 172 | - | |
| 173 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 174 | - end | |
| 175 | - | |
| 176 | - should "search for software by license info" do | |
| 177 | - fields = software_fields | |
| 178 | - software = create_software fields | |
| 179 | - software.license_info = LicenseInfo.last | |
| 180 | - software.save! | |
| 181 | - | |
| 182 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 183 | - "programming_language"=>{"id"=>""}, | |
| 184 | - "operating_system"=>{"id"=>""}, | |
| 185 | - "software_categories"=>"", "license_info"=>{"id"=>LicenseInfo.last.id}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 186 | - "commit"=>"Search"} | |
| 187 | - get :communities, params | |
| 188 | - | |
| 189 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 190 | - end | |
| 191 | - | |
| 192 | - | |
| 193 | - should "search for software by e_mag" do | |
| 194 | - fields = software_fields | |
| 195 | - software = create_software fields | |
| 196 | - software.e_mag = true | |
| 197 | - software.save! | |
| 198 | - | |
| 199 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 200 | - "programming_language"=>{"id"=>""}, | |
| 201 | - "operating_system"=>{"id"=>""}, | |
| 202 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"true", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 203 | - "commit"=>"Search"} | |
| 204 | - get :communities, params | |
| 205 | - | |
| 206 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 207 | - end | |
| 208 | - | |
| 209 | - | |
| 210 | - should "search for software by e_ping" do | |
| 211 | - fields = software_fields | |
| 212 | - software = create_software fields | |
| 213 | - software.e_ping = true | |
| 214 | - software.save! | |
| 215 | - | |
| 216 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 217 | - "programming_language"=>{"id"=>""}, | |
| 218 | - "operating_system"=>{"id"=>""}, | |
| 219 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
| 220 | - "commit"=>"Search"} | |
| 221 | - get :communities, params | |
| 222 | - | |
| 223 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 224 | - end | |
| 225 | - | |
| 226 | - | |
| 227 | - should "search for software by icp_brasil" do | |
| 228 | - fields = software_fields | |
| 229 | - software = create_software fields | |
| 230 | - software.icp_brasil = true | |
| 231 | - software.save! | |
| 232 | - | |
| 233 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 234 | - "programming_language"=>{"id"=>""}, | |
| 235 | - "operating_system"=>{"id"=>""}, | |
| 236 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"true", "e_arq"=>"", "internacionalizable"=>"", | |
| 237 | - "commit"=>"Search"} | |
| 238 | - get :communities, params | |
| 239 | - | |
| 240 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 241 | - end | |
| 242 | - | |
| 243 | - should "search for software by e_arq" do | |
| 244 | - fields = software_fields | |
| 245 | - software = create_software fields | |
| 246 | - software.e_arq = true | |
| 247 | - software.save! | |
| 248 | - | |
| 249 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 250 | - "programming_language"=>{"id"=>""}, | |
| 251 | - "operating_system"=>{"id"=>""}, | |
| 252 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | |
| 253 | - "commit"=>"Search"} | |
| 254 | - get :communities, params | |
| 255 | - | |
| 256 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 257 | - end | |
| 258 | - | |
| 259 | - should "search for software by internacionalizable" do | |
| 260 | - fields = software_fields | |
| 261 | - software = create_software fields | |
| 262 | - software.intern = true | |
| 263 | - software.save! | |
| 264 | - | |
| 265 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 266 | - "programming_language"=>{"id"=>""}, | |
| 267 | - "operating_system"=>{"id"=>""}, | |
| 268 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"true", | |
| 269 | - "commit"=>"Search"} | |
| 270 | - get :communities, params | |
| 271 | - | |
| 272 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 273 | - end | |
| 274 | - | |
| 275 | - should "search by e_arq and e_ping" do | |
| 276 | - fields = software_fields | |
| 277 | - software = create_software fields | |
| 278 | - software.e_arq = true | |
| 279 | - software.e_ping = true | |
| 280 | - software.save! | |
| 281 | - | |
| 282 | - params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
| 283 | - "programming_language"=>{"id"=>""}, | |
| 284 | - "operating_system"=>{"id"=>""}, | |
| 285 | - "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | |
| 286 | - "commit"=>"Search"} | |
| 287 | - get :communities, params | |
| 288 | - | |
| 289 | - assert_includes assigns(:searches)[:communities][:results], software.community | |
| 290 | - end | |
| 291 | - | |
| 292 | 108 | protected |
| 293 | 109 | |
| 294 | 110 | def create_user name, state, city, email | ... | ... |
views/search/search_forms/_software_fields.html.erb
| 1 | 1 | <table class="mpog_search_form_table"> |
| 2 | 2 | <tr> |
| 3 | - <td> <%= label_tag("name", _("Name"))%> </td> | |
| 4 | 3 | <td> <%= text_field_tag(:name) %> </td> |
| 5 | 4 | </tr> |
| 6 | - | |
| 7 | - <tr> | |
| 8 | - <td> <%= _("Database") %> </td> | |
| 9 | - <td> | |
| 10 | - <%= collection_select(:database_description, :id, DatabaseDescription.all, :id, :name, :prompt=>_("Any")) %> | |
| 11 | - </td> | |
| 12 | - </tr> | |
| 13 | - | |
| 14 | - <tr> | |
| 15 | - <td> <%= _("Programming Language") %> </td> | |
| 16 | - <td> | |
| 17 | - <%= collection_select(:programming_language, :id, ProgrammingLanguage.all, :id, :name, :prompt=>_("Any")) %> | |
| 18 | - </td> | |
| 19 | - </tr> | |
| 20 | - | |
| 21 | - <tr> | |
| 22 | - <td> <%= _("Operating System") %> </td> | |
| 23 | - <td> | |
| 24 | - <%= collection_select(:operating_system, :id, OperatingSystemName.all, :id, :name, :prompt=>_("Any")) %> | |
| 25 | - </td> | |
| 26 | - </tr> | |
| 27 | - | |
| 28 | - <tr> | |
| 29 | - <td> <%= _("Software Categories") %> </td> | |
| 30 | - <td> | |
| 31 | - <%= select_tag("software_categories", (SoftwareCategoriesHelper.get_categories_as_options)) %> | |
| 32 | - </td> | |
| 33 | - </tr> | |
| 34 | - | |
| 35 | - <tr> | |
| 36 | - <td> <%= _("License Used") %> </td> | |
| 37 | - <td> | |
| 38 | - <%= collection_select(:license_info, :id, LicenseInfo.all, :id, :version, :prompt=>_("Any")) %> | |
| 39 | - </td> | |
| 40 | - </tr> | |
| 41 | - | |
| 42 | - <tr> | |
| 43 | - <td> <%= _("Adherent to e-PING ?") %> </td> | |
| 44 | - <td> | |
| 45 | - <label> | |
| 46 | - <%= radio_button_tag(:e_ping, "", true) %> | |
| 47 | - <%= _("Any") %> | |
| 48 | - </label> | |
| 49 | - | |
| 50 | - <label> | |
| 51 | - <%= radio_button_tag(:e_ping, true) %> | |
| 52 | - <%= _("Yes") %> | |
| 53 | - </label> | |
| 54 | - | |
| 55 | - <label> | |
| 56 | - <%= radio_button_tag(:e_ping, false) %> | |
| 57 | - <%= _("No") %> | |
| 58 | - </label> | |
| 59 | - </td> | |
| 60 | - </tr> | |
| 61 | - | |
| 62 | - <tr> | |
| 63 | - <td> <%= _("Adherent to e-MAG ?") %> </td> | |
| 64 | - <td> | |
| 65 | - <label> | |
| 66 | - <%= radio_button_tag(:e_mag, "", true) %> | |
| 67 | - <%= _("Any") %> | |
| 68 | - </label> | |
| 69 | - | |
| 70 | - <label> | |
| 71 | - <%= radio_button_tag(:e_mag, true) %> | |
| 72 | - <%= _("Yes") %> | |
| 73 | - </label> | |
| 74 | - | |
| 75 | - <label> | |
| 76 | - <%= radio_button_tag(:e_mag, false) %> | |
| 77 | - <%= _("No") %> | |
| 78 | - </label> | |
| 79 | - </td> | |
| 80 | - </tr> | |
| 81 | - | |
| 82 | - <tr> | |
| 83 | - <td> <%= _("Adherent to ICP-Brasil ?") %> </td> | |
| 84 | - <td> | |
| 85 | - <label> | |
| 86 | - <%= radio_button_tag(:icp_brasil, "", true) %> | |
| 87 | - <%= _("Any") %> | |
| 88 | - </label> | |
| 89 | - | |
| 90 | - <label> | |
| 91 | - <%= radio_button_tag(:icp_brasil, true) %> | |
| 92 | - <%= _("Yes") %> | |
| 93 | - </label> | |
| 94 | - | |
| 95 | - <label> | |
| 96 | - <%= radio_button_tag(:icp_brasil, false) %> | |
| 97 | - <%= _("No") %> | |
| 98 | - </label> | |
| 99 | - </td> | |
| 100 | - </tr> | |
| 101 | - | |
| 102 | - <tr> | |
| 103 | - <td> <%= _("Adherent to e-ARQ ?") %> </td> | |
| 104 | - <td> | |
| 105 | - <label> | |
| 106 | - <%= radio_button_tag(:e_arq, "", true) %> | |
| 107 | - <%= _("Any") %> | |
| 108 | - </label> | |
| 109 | - | |
| 110 | - <label> | |
| 111 | - <%= radio_button_tag(:e_arq, true) %> | |
| 112 | - <%= _("Yes") %> | |
| 113 | - </label> | |
| 114 | - | |
| 115 | - <label> | |
| 116 | - <%= radio_button_tag(:e_arq, false) %> | |
| 117 | - <%= _("No") %> | |
| 118 | - </label> | |
| 119 | - </td> | |
| 120 | - </tr> | |
| 121 | - | |
| 122 | - <tr> | |
| 123 | - <td> <%= _("Internacionalizable ?") %> </td> | |
| 124 | - <td> | |
| 125 | - <label> | |
| 126 | - <%= radio_button_tag(:internacionalizable, "", true) %> | |
| 127 | - <%= _("Any") %> | |
| 128 | - </label> | |
| 129 | - | |
| 130 | - <label> | |
| 131 | - <%= radio_button_tag(:internacionalizable, true) %> | |
| 132 | - <%= _("Yes") %> | |
| 133 | - </label> | |
| 134 | - | |
| 135 | - <label> | |
| 136 | - <%= radio_button_tag(:internacionalizable, false) %> | |
| 137 | - <%= _("No") %> | |
| 138 | - </label> | |
| 139 | - </td> | |
| 140 | - </tr> | |
| 141 | 5 | </table> |
| 142 | 6 | \ No newline at end of file | ... | ... |