Commit ca88bc8c337bb19ce085b68c88043bf1f5a82e66
Exists in
master
and in
51 other branches
Merge branch 'software_rating_on_catalog' into 'master'
Software rating on catalog See merge request !86
Showing
12 changed files
with
103 additions
and
14 deletions
Show diff stats
src/noosfero-spb/noosfero-spb-theme/css/software-catalog-page.css
| ... | ... | @@ -53,7 +53,7 @@ |
| 53 | 53 | margin: 0 0 0 15px; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - It's TEMPORARY | |
| 56 | + It's TEMPORARY | |
| 57 | 57 | .action-search-software_infos #content .search-form .doubts-catalog-software { |
| 58 | 58 | display: none; |
| 59 | 59 | }*/ |
| ... | ... | @@ -65,7 +65,7 @@ |
| 65 | 65 | line-height: 20px; |
| 66 | 66 | position:absolute; |
| 67 | 67 | } |
| 68 | -.action-search-software_infos .search-form label, | |
| 68 | +.action-search-software_infos .search-form label, | |
| 69 | 69 | .action-search-software_infos .search-form label{ |
| 70 | 70 | margin:0px 3px 4px 32px; |
| 71 | 71 | line-height: 22px; |
| ... | ... | @@ -310,9 +310,9 @@ |
| 310 | 310 | |
| 311 | 311 | /* Column left */ |
| 312 | 312 | |
| 313 | -.action-search-software_infos #search-results .search-software-item-column-left{ | |
| 314 | - width: 130px; | |
| 315 | - height: 130px; | |
| 313 | +.action-search-software_infos #search-results .search-software-item-column-left { | |
| 314 | + width: 140px; | |
| 315 | + height: 140px; | |
| 316 | 316 | float: left; |
| 317 | 317 | border-right: 1px dotted #ccc; |
| 318 | 318 | } |
| ... | ... | @@ -359,7 +359,7 @@ |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | .action-search-software_infos #search-results .search-software-item-column-left .extra_info { |
| 362 | - width: 130px; | |
| 362 | + width: 140px; | |
| 363 | 363 | padding-right: 20px; |
| 364 | 364 | top: 0px; |
| 365 | 365 | position: absolute; |
| ... | ... | @@ -370,18 +370,32 @@ |
| 370 | 370 | opacity: inherit; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | -.action-search-software_infos #search-results .search-software-item-column-left .extra_info::before{ | |
| 373 | +.action-search-software_infos #search-results .search-software-item-column-left .software-date { | |
| 374 | + margin-top: 20px; | |
| 375 | + width: 130px; | |
| 376 | +} | |
| 377 | + | |
| 378 | +.action-search-software_infos #search-results .search-software-item-column-left .software-date::before{ | |
| 374 | 379 | content: url("../images/ic-calendar.png"); |
| 375 | - margin: 6px 10px 20px 0; | |
| 380 | + margin: 0px 7px 20px 0; | |
| 376 | 381 | float: left; |
| 377 | 382 | } |
| 378 | 383 | |
| 384 | +.action-search-software_infos #search-results .search-software-item-column-left .star-container.catalog_rating_block { | |
| 385 | + width: 140px; | |
| 386 | + margin-left: 0px; | |
| 387 | +} | |
| 388 | + | |
| 389 | +.action-search-software_infos #search-results .search-software-item-column-left .software-date-value { | |
| 390 | + margin-left: 23px; | |
| 391 | +} | |
| 392 | + | |
| 379 | 393 | /* Column Right */ |
| 380 | 394 | |
| 381 | 395 | .action-search-software_infos #search-results .search-software-item-column-right { |
| 382 | - width: 70%; | |
| 396 | + width: 65%; | |
| 383 | 397 | float: left; |
| 384 | - margin-left: 130px; | |
| 398 | + margin-left: 140px; | |
| 385 | 399 | padding: 0 0 0 8px; |
| 386 | 400 | font-size: 15px; |
| 387 | 401 | font-family: Arial; |
| ... | ... | @@ -439,3 +453,5 @@ |
| 439 | 453 | font-size: 13px; |
| 440 | 454 | text-decoration: underline; |
| 441 | 455 | } |
| 456 | + | |
| 457 | + | ... | ... |
268 Bytes
src/noosfero-spb/software_communities/features/software_catalog.feature
| ... | ... | @@ -80,3 +80,33 @@ Feature: Search software |
| 80 | 80 | Then I should see "Software One" |
| 81 | 81 | And I should see "Software Two" |
| 82 | 82 | And I should see "Software Three" |
| 83 | + | |
| 84 | + @selenium | |
| 85 | + Scenario: See software rating on catalog | |
| 86 | + Given plugin "OrganizationRatings" is enabled on environment | |
| 87 | + And I am logged in as mpog_admin | |
| 88 | + And I go to /admin/plugins | |
| 89 | + And I check "Organization Ratings" | |
| 90 | + And I press "Save changes" | |
| 91 | + And I go to /admin/admin_panel/site_info | |
| 92 | + And I select "Software Público" from "environment_theme" | |
| 93 | + And I press "Save" | |
| 94 | + And I go to /account/logout | |
| 95 | + Given the following user | |
| 96 | + | login | name | | |
| 97 | + | joaosilva | Joao Silva | | |
| 98 | + And the following blocks | |
| 99 | + | owner | type | | |
| 100 | + | software-two | AverageRatingBlock | | |
| 101 | + | software-two | OrganizationRatingsBlock | | |
| 102 | + And the environment domain is "localhost" | |
| 103 | + And I am logged in as "joaosilva" | |
| 104 | + And I go to /profile/software-two/plugin/organization_ratings/new_rating | |
| 105 | + And I press "Enviar" | |
| 106 | + And I go to /search/software_infos | |
| 107 | + When I select "Favorites" from "sort" | |
| 108 | + And I sleep for 3 seconds | |
| 109 | + Then I should see "Software Two" before "Software One" | |
| 110 | + And there should be 1 div with class "small-star-positive" | |
| 111 | + And there should be 4 divs with class "small-star-negative" | |
| 112 | + | ... | ... |
src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb
| ... | ... | @@ -200,3 +200,7 @@ Given /^I keyup on selector "([^"]*)"$/ do |selector| |
| 200 | 200 | selector_founded = evaluate_script("jQuery('#{selector}').trigger('keyup').length != 0") |
| 201 | 201 | selector_founded.should be_true |
| 202 | 202 | end |
| 203 | + | |
| 204 | +Then /^there should be (\d+) divs? with class "([^"]*)"$/ do |count, klass| | |
| 205 | + should have_selector("div.#{klass}", :count => count) | |
| 206 | +end | ... | ... |
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
| ... | ... | @@ -105,6 +105,8 @@ class SearchController |
| 105 | 105 | communities_list.reverse! |
| 106 | 106 | elsif params[:sort] && params[:sort] == "relevance" |
| 107 | 107 | communities_list = sort_by_relevance(communities_list, params[:query]){ |community| [community.software_info.finality, community.name] } |
| 108 | + elsif params[:sort] && params[:sort] == "rating" | |
| 109 | + communities_list = sort_by_average_rating(communities_list) | |
| 108 | 110 | end |
| 109 | 111 | communities_list |
| 110 | 112 | end | ... | ... |
src/noosfero-spb/software_communities/lib/ext/search_helper.rb
| ... | ... | @@ -30,4 +30,16 @@ module SearchHelper |
| 30 | 30 | list |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | + def sort_by_average_rating list | |
| 34 | + list.sort! do |a, b| | |
| 35 | + rating_a = OrganizationRating.average_rating(a.id) | |
| 36 | + rating_a = 0 if rating_a.nil? | |
| 37 | + rating_b = OrganizationRating.average_rating(b.id) | |
| 38 | + rating_b = 0 if rating_b.nil? | |
| 39 | + rating_a - rating_b | |
| 40 | + end | |
| 41 | + | |
| 42 | + list.reverse! | |
| 43 | + end | |
| 44 | + | |
| 33 | 45 | end | ... | ... |
src/noosfero-spb/software_communities/lib/software_info.rb
| ... | ... | @@ -91,12 +91,12 @@ class SoftwareInfo < ActiveRecord::Base |
| 91 | 91 | settings_items :another_license_version, :another_license_link |
| 92 | 92 | |
| 93 | 93 | # used on find_by_contents |
| 94 | - scope :like_search, lambda{ |name| | |
| 94 | + def self.like_search name | |
| 95 | 95 | joins(:community).where( |
| 96 | 96 | "name ILIKE ? OR acronym ILIKE ? OR finality ILIKE ?", |
| 97 | 97 | "%#{name}%", "%#{name}%", "%#{name}%" |
| 98 | 98 | ) |
| 99 | - } | |
| 99 | + end | |
| 100 | 100 | |
| 101 | 101 | scope :search, lambda { |name="", database_description_id = "", |
| 102 | 102 | programming_language_id = "", operating_system_name_id = "", | ... | ... |
src/noosfero-spb/software_communities/public/style.css
src/noosfero-spb/software_communities/views/search/_full_community.html.erb
| 1 | 1 | <% software = community.software_info %> |
| 2 | 2 | <li class="search-software-item"> |
| 3 | + <% organization_average_rating = '' %> | |
| 4 | + <% unless community.organization_ratings.empty?%> | |
| 5 | + <% organization_average_rating = render :partial => 'shared/organization_average_rating_block', :locals => {:community => community}%> | |
| 6 | + <% end %> | |
| 7 | + | |
| 8 | + <% software_publish_date = render :partial => 'shared/software_publish_date', :locals => {:community => community, :order => @order} %> | |
| 9 | + | |
| 3 | 10 | <div class="search-software-item-column-left"> |
| 4 | - <%= profile_image_link community, :portrait, 'div', community.send(@order + '_label') + show_date(community.created_at) %> | |
| 11 | + <%= profile_image_link community, :portrait, 'div', organization_average_rating + software_publish_date %> | |
| 5 | 12 | </div> |
| 6 | 13 | |
| 7 | 14 | <div class="search-software-item-column-right"> | ... | ... |
src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb
src/noosfero-spb/software_communities/views/shared/_organization_average_rating_block.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | +<div class="star-container catalog_rating_block"> | |
| 2 | + <% (1..5).each do |rate_number| %> | |
| 3 | + <% if rate_number <= OrganizationRating.average_rating(community.id) %> | |
| 4 | + <div class="medium-star-positive"></div> | |
| 5 | + <% else %> | |
| 6 | + <div class="medium-star-negative"></div> | |
| 7 | + <% end %> | |
| 8 | + <% end %> | |
| 9 | +</div> | ... | ... |
src/noosfero-spb/software_communities/views/shared/_software_publish_date.html.erb
0 → 100644