Merge Request #14
Refactor software info
-
Comunidade de Software sem Opção de Privacidade Secreta Issue no repositório softwarepublico/noosfero: https://softwarepublico.gov.br/gitlab/softwarepublico/noosfero/issues/389 Issue no repositório softwarepublico/softwarepublico: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/issues/237 See merge request !13
-
Ordenar categorias de catalogo de software Issue no repositório softwarepublico/noosfero: https://softwarepublico.gov.br/gitlab/softwarepublico/noosfero/issues/383 Issue no repositório softwarepublico/softwarepublico: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/issues/251 See merge request !12
-
Remove disabled communities from catalog See merge request !15
-
- This commit does not add the po file translations since the translations are now made on branch stable, which solves problems on po files. Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com> Signed-off-by: Simiao Carvalho <simiaosimis@gmail.com>
-
This reverts commit 8f80f666d6a0b008deb79d9477fcaeddba96d48a.
- 8 of 24 commits displayed. Click here to show all
| ... | ... | @@ -16,10 +16,15 @@ class CategoriesSoftwareBlock < Block |
| 16 | 16 | def content(args={}) |
| 17 | 17 | block = self |
| 18 | 18 | s = show_name |
| 19 | + | |
| 20 | + software_category = Category.find_by_name("Software") | |
| 21 | + categories = [] | |
| 22 | + categories = software_category.children.sort if software_category | |
| 23 | + | |
| 19 | 24 | lambda do |object| |
| 20 | 25 | render( |
| 21 | 26 | :file => 'blocks/categories_software', |
| 22 | - :locals => { :block => block, :show_name => s } | |
| 27 | + :locals => { :block => block, :show_name => s, :categories => categories } | |
| 23 | 28 | ) |
| 24 | 29 | end |
| 25 | 30 | end | ... | ... |
| ... | ... | @@ -22,7 +22,7 @@ class CommunitiesBlock |
| 22 | 22 | valid_communities_string = Community.get_valid_communities_string |
| 23 | 23 | Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} |
| 24 | 24 | |
| 25 | - visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) | |
| 25 | + visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) unless delete_communities.empty? | |
| 26 | 26 | |
| 27 | 27 | if !prioritize_profiles_with_image |
| 28 | 28 | return visible_profiles.all( | ... | ... |
| ... | ... | @@ -25,17 +25,10 @@ class ProfileController |
| 25 | 25 | |
| 26 | 26 | def members |
| 27 | 27 | if is_cache_expired?(profile.members_cache_key(params)) |
| 28 | - all_members = if params[:sort] and params[:sort] == "desc" | |
| 29 | - profile.members.order("name desc") | |
| 30 | - else | |
| 31 | - profile.members.order("name asc") | |
| 32 | - end | |
| 33 | - @profile_admins = profile.admins | |
| 34 | - @profile_members = all_members - @profile_admins | |
| 35 | - @profile_members = @profile_members.paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @profile_members.size) | |
| 36 | - @profile_admins = @profile_admins.paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @profile_admins.size) | |
| 37 | - @total_members = all_members.size | |
| 38 | - @profile_members_url = url_for(:controller => "profile", :action => "members") | |
| 28 | + sort = (params[:sort] == 'desc') ? params[:sort] : 'asc' | |
| 29 | + @profile_admins = profile.admins.includes(relations_to_include).order("name #{sort}").paginate(:per_page => members_per_page, :page => params[:npage]) | |
| 30 | + @profile_members = profile.members.order("name #{sort}").paginate(:per_page => members_per_page, :page => params[:npage]) | |
| 31 | + @profile_members_url = url_for(:controller => 'profile', :action => 'members') | |
| 39 | 32 | end |
| 40 | 33 | end |
| 41 | 34 | ... | ... |
| ... | ... | @@ -61,6 +61,7 @@ class SearchController |
| 61 | 61 | |
| 62 | 62 | def get_filtered_software_list |
| 63 | 63 | params[:query] ||= "" |
| 64 | + visible_communities = visible_profiles(Community) | |
| 64 | 65 | |
| 65 | 66 | filtered_software_list = SoftwareInfo.search_by_query(params[:query]) |
| 66 | 67 | |
| ... | ... | @@ -70,6 +71,7 @@ class SearchController |
| 70 | 71 | @public_software_selected = false |
| 71 | 72 | end |
| 72 | 73 | |
| 74 | + filtered_software_list.select!{ |software| visible_communities.include?(software.community) } | |
| 73 | 75 | category_ids = get_filter_category_ids |
| 74 | 76 | |
| 75 | 77 | unless category_ids.empty? |
| ... | ... | @@ -89,7 +91,7 @@ class SearchController |
| 89 | 91 | def get_communities_list software_list |
| 90 | 92 | filtered_community_list = [] |
| 91 | 93 | software_list.each do |software| |
| 92 | - if @all_selected || software.public_software? | |
| 94 | + if !@public_software_selected || software.public_software? | |
| 93 | 95 | filtered_community_list << software.community unless software.community.nil? |
| 94 | 96 | end |
| 95 | 97 | end | ... | ... |
| ... | ... | @@ -13,15 +13,15 @@ class SoftwareInfo < ActiveRecord::Base |
| 13 | 13 | DatabaseDescription |
| 14 | 14 | ] |
| 15 | 15 | |
| 16 | - scope :search_by_query, lambda {|query = ""| | |
| 16 | + scope :search_by_query, lambda { |query = ""| | |
| 17 | 17 | filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|') |
| 18 | 18 | search_fields = SoftwareInfo.pg_search_plugin_fields |
| 19 | 19 | |
| 20 | 20 | if query.empty? |
| 21 | - SoftwareInfo.all | |
| 21 | + SoftwareInfo.joins(:community).where("profiles.visible = ?", true) | |
| 22 | 22 | else |
| 23 | 23 | searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES) |
| 24 | - includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')") | |
| 24 | + includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ?", true) | |
| 25 | 25 | end |
| 26 | 26 | } |
| 27 | 27 | ... | ... |
| ... | ... | @@ -179,7 +179,7 @@ msgstr " campo finalidade em branco." |
| 179 | 179 | |
| 180 | 180 | #: plugins/software_communities/lib/create_software.rb:48 |
| 181 | 181 | msgid " this finality:<p><em>%{finality}</em></p>" |
| 182 | -msgstr "esta finalidade:<p><em>%{finality}</em></p>" | |
| 182 | +msgstr " esta finalidade:<p><em>%{finality}</em></p>" | |
| 183 | 183 | |
| 184 | 184 | #: plugins/software_communities/lib/create_software.rb:68 |
| 185 | 185 | msgid "%{requestor} wants to create software %{subject}" | ... | ... |
| ... | ... | @@ -214,6 +214,48 @@ class SearchControllerTest < ActionController::TestCase |
| 214 | 214 | assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community |
| 215 | 215 | end |
| 216 | 216 | |
| 217 | + should "software_infos search return only enabled softwares" do | |
| 218 | + s1 = SoftwareInfo.first | |
| 219 | + s2 = SoftwareInfo.last | |
| 220 | + | |
| 221 | + # First get them all normally | |
| 222 | + get( | |
| 223 | + :software_infos, | |
| 224 | + :query => "software" | |
| 225 | + ) | |
| 226 | + | |
| 227 | + assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
| 228 | + assert_includes assigns(:searches)[:software_infos][:results], s2.community | |
| 229 | + | |
| 230 | + s2.community.disable | |
| 231 | + | |
| 232 | + # Now it should not contain the disabled community | |
| 233 | + get( | |
| 234 | + :software_infos, | |
| 235 | + :query => "software" | |
| 236 | + ) | |
| 237 | + | |
| 238 | + assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
| 239 | + assert_not_includes assigns(:searches)[:software_infos][:results], s2.community | |
| 240 | + end | |
| 241 | + | |
| 242 | + should "software_infos search not return software with secret community" do | |
| 243 | + software_one = create_software_info("Software ABC", :acronym => "SFO", :finality => "Help") | |
| 244 | + software_two = create_software_info("Python", :acronym => "SFT", :finality => "Task") | |
| 245 | + software_three = create_software_info("Software DEF", :acronym => "SFW", :finality => "Java") | |
| 246 | + | |
| 247 | + software_one.community.secret = true | |
| 248 | + software_one.community.save! | |
| 249 | + | |
| 250 | + get( | |
| 251 | + :software_infos, | |
| 252 | + ) | |
| 253 | + | |
| 254 | + assert_includes assigns(:searches)[:software_infos][:results], software_two.community | |
| 255 | + assert_includes assigns(:searches)[:software_infos][:results], software_three.community | |
| 256 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | |
| 257 | + end | |
| 258 | + | |
| 217 | 259 | private |
| 218 | 260 | |
| 219 | 261 | def create_software_categories | ... | ... |
| ... | ... | @@ -8,12 +8,9 @@ |
| 8 | 8 | <p><%= _("Categories:") %></p> |
| 9 | 9 | <ul class="categories-mais-software"> |
| 10 | 10 | |
| 11 | - <% categories = Category.where(:name => "Software") %> | |
| 12 | - <% unless categories.blank? %> | |
| 13 | - <% categories.first.children.each do |category| %> | |
| 14 | - <% unless category.software_infos.count < 1 %> | |
| 15 | - <li><%= link_to _("#{category.name}") + " (#{category.software_infos.count})", {:controller => :search, :action => :software_infos, :selected_categories_id => [category.id]} %></li> | |
| 16 | - <% end %> | |
| 11 | + <% categories.each do |category| %> | |
| 12 | + <% unless category.software_infos.count < 1 %> | |
| 13 | + <li><%= link_to _("#{category.name}") + " (#{category.software_infos.count})", {:controller => :search, :action => :software_infos, :selected_categories_id => [category.id]} %></li> | |
| 17 | 14 | <% end %> |
| 18 | 15 | <% end %> |
| 19 | 16 | </ul> | ... | ... |
| ... | ... | @@ -2,13 +2,19 @@ |
| 2 | 2 | |
| 3 | 3 | <!-- popover html structure --> |
| 4 | 4 | <!-- <a> link to fire popover --> |
| 5 | -<a class="toggle-popover">mais informaçõs</a> | |
| 5 | +<a class="toggle-popover">mais informações</a> | |
| 6 | 6 | <!-- <span> to handle popover options --> |
| 7 | 7 | <span class="popover-span" data-toggle="popover" data-placement="top" data-class="highlights-popover">?</span> |
| 8 | 8 | <!-- <div> with html content of popover |
| 9 | 9 | MUST APPEAR AFTER THE SPAN --> |
| 10 | 10 | <div class="popover-content" style="display: none"> |
| 11 | + <div class="inner-content"> | |
| 11 | 12 | <p>Este software foi desenvolvido com recursos públicos, gerenciado por uma instituição |
| 12 | - governamental. Sua inclusão neste portal atende aos requisitos do <span>art. 14 da IN 01/2011</span>.</p> | |
| 13 | + governamental. Sua inclusão neste portal atende aos requisitos do | |
| 14 | + <a href="https://softwarepublico.gov.br/social/articles/0000/3365/in_spb_01.pdf">art. 14 da IN 01/2011</a>. | |
| 15 | + </p> | |
| 16 | + </div> | |
| 17 | + <div class="see-all"> | |
| 13 | 18 | <%= link_to _('See all'), {:controller => :search, :action => :software_infos, :only_softwares => softwares} %> |
| 19 | + </div> | |
| 14 | 20 | </div> | ... | ... |
| 1 | 1 | <div class="software-metrics-block"> |
| 2 | 2 | <ul class="metrics-list"> |
| 3 | - <li><span class="arrow-globe-icon"></span><a href="#"><%= pluralize(profile.hits, 'visita', 'visitas') %></a></li> | |
| 4 | - <li><span class="downloads-icon"></span><a href="#"><%= pluralize(total_downloads, 'download', 'downloads') %></a></li> | |
| 5 | - <li><span class="face-icon"></span><a href="#"><%= block.benefited_people.to_s + _(' benefited people*') %></a></li> | |
| 6 | - <li><span class="pig-safe-icon"></span><a href="#"><strong class="saved-money"><%= number_to_currency(block.saved_resources, unit: 'R$ ', separator: ',', delimiter: '.') %></strong> <%= _(' saved resources*') %></a></li> | |
| 3 | + <li> | |
| 4 | + <span class="arrow-globe-icon"></span> | |
| 5 | + <span id="visit-count"> | |
| 6 | + <%= pluralize(profile.hits, 'visita', 'visitas') %> | |
| 7 | + </span> | |
| 8 | + </li> | |
| 9 | + <li> | |
| 10 | + <span class="downloads-icon"></span> | |
| 11 | + <span id="downloads-count"> | |
| 12 | + <%= pluralize(total_downloads, 'download', 'downloads') %> | |
| 13 | + </span> | |
| 14 | + </li> | |
| 15 | + <li> | |
| 16 | + <span class="face-icon"></span> | |
| 17 | + <span id="benefited-people"> | |
| 18 | + <%= block.benefited_people.to_s + _(' benefited people*') %> | |
| 19 | + </span> | |
| 20 | + </li> | |
| 21 | + <li> | |
| 22 | + <span class="pig-safe-icon"></span> | |
| 23 | + <span id="saved-resources"> | |
| 24 | + <strong class="saved-money"> | |
| 25 | + <%= number_to_currency(block.saved_resources, unit: 'R$ ', | |
| 26 | + separator: ',', delimiter: '.') %> | |
| 27 | + </strong> | |
| 28 | + <%= _(' saved resources*') %> | |
| 29 | + </span> | |
| 30 | + </li> | |
| 7 | 31 | </ul> |
| 8 | 32 | |
| 9 | - | |
| 10 | - <div class="admin-estimation">* <%= _("Data estimated by the software administrator.") %></div> | |
| 33 | + <div class="admin-estimation"> | |
| 34 | + * <%= _("Data estimated by the software administrator.") %> | |
| 35 | + </div> | |
| 11 | 36 | </div> | ... | ... |
| 1 | 1 | <div class="aditional-informations"> |
| 2 | 2 | <div class="comments-people-benefited"> |
| 3 | - <span>People benefited :</span> <%= user_rating.people_benefited unless user_rating.nil? %> | |
| 3 | + <span><%=_("Benefited People")%> :</span> <%= user_rating.people_benefited unless user_rating.nil? %> | |
| 4 | 4 | </div> |
| 5 | 5 | |
| 6 | 6 | <div class="comments-saved-value"> |
| 7 | - <span>Saved Value :</span> <%= user_rating.saved_value unless user_rating.nil? %> | |
| 7 | + <span><%=_("Saved Resources")%> :</span> <%= user_rating.saved_value unless user_rating.nil? %> | |
| 8 | 8 | </div> |
| 9 | 9 | </div> |
| 10 | 10 | ... | ... |
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | <% end %> |
| 12 | 12 | |
| 13 | 13 | <div class="page-profile-header"> |
| 14 | - <%= render "blocks/profile_info_actions/join_leave_community" %> | |
| 14 | + <%= render "blocks/profile_info_actions/join_leave_community" if profile.class == "Community" %> | |
| 15 | 15 | <% if !user.nil? && user.has_permission?('edit_profile', profile) %> |
| 16 | 16 | <div class="control-panel-button"> |
| 17 | 17 | <%= button :control_panel, _('Control Panel'), profile.admin_url %> | ... | ... |
| 1 | +<div class="common-profile-list-block"> | |
| 1 | 2 | |
| 2 | -<div class="page-members-header"> | |
| 3 | - <h1><%= _("Members") + " (#{@total_members})" %></h1> | |
| 4 | - <h3 class="community-name"><%= _("%s") % profile.name %></h3> | |
| 5 | - <%= render "blocks/profile_info_actions/community" %> | |
| 6 | -</div> | |
| 3 | + <div class="page-members-header"> | |
| 4 | + <h1><%= _("Members (%d)") % @profile_members.total_entries %></h1> | |
| 5 | + <h3 class="community-name"><%= profile.name %></h3> | |
| 6 | + <%= render "blocks/profile_info_actions/community" %> | |
| 7 | + </div> | |
| 7 | 8 | |
| 8 | 9 | <% cache_timeout(profile.members_cache_key(params), 4.hours) do %> |
| 9 | -<div class="profile-members-tabs-container"> | |
| 10 | + <div class="profile-members-tabs-container"> | |
| 10 | 11 | <% tabs = [] %> |
| 11 | 12 | |
| 12 | - <% div_members = content_tag :div, :class => "profile-members" do | |
| 13 | + <% div_members = content_tag :div, :class => "profile-members" do | |
| 13 | 14 | render :partial => 'profile_members_list', |
| 14 | 15 | :locals => { |
| 15 | 16 | :users => @profile_members, |
| 16 | 17 | :role => "members" |
| 17 | 18 | } |
| 19 | + end %> | |
| 18 | 20 | |
| 19 | - end %> | |
| 20 | - | |
| 21 | - <% members_pagination = content_tag :div, :class => "pagination-profile-members" do | |
| 22 | - pagination_links @profile_members, :param_name => 'npage' | |
| 23 | - end %> | |
| 24 | - | |
| 25 | - | |
| 26 | - <% tabs << {:title => "#{@profile_members.size} "+_("Members"), | |
| 21 | + <% tabs << {:title => _("%d Members") % @profile_members.total_entries, | |
| 27 | 22 | :id => "members-tab", |
| 28 | - :content => (div_members + members_pagination) | |
| 23 | + :content => div_members | |
| 29 | 24 | } %> |
| 30 | 25 | |
| 31 | 26 | <% div_admins = content_tag :div, :class => "profile-admins" do |
| ... | ... | @@ -34,24 +29,16 @@ |
| 34 | 29 | :users => @profile_admins, |
| 35 | 30 | :role => "admins" |
| 36 | 31 | } |
| 37 | - end %> | |
| 38 | - | |
| 39 | - <% admins_pagination = content_tag :div, :class => "pagination-profile-admins" do | |
| 40 | - pagination_links @profile_admins, :param_name => 'npage' | |
| 41 | - end %> | |
| 42 | - | |
| 43 | - <% tabs << {:title => "#{@profile_admins.size} "+_("Administrators"), | |
| 44 | - :id => "admins-tab", | |
| 45 | - :content => (div_admins+admins_pagination) | |
| 46 | - } %> | |
| 47 | - | |
| 48 | - | |
| 32 | + end %> | |
| 49 | 33 | |
| 34 | + <% tabs << {:title => _("%d Administrators") % @profile_admins.total_entries, | |
| 35 | + :id => "admins-tab", | |
| 36 | + :content => div_admins | |
| 37 | + } %> | |
| 50 | 38 | |
| 51 | 39 | <%= render_tabs(tabs) %> |
| 52 | - <% end %> | |
| 53 | -</div> | |
| 54 | - | |
| 40 | + </div><!-- end of class="profile-members-tabs-container" --> | |
| 41 | +<% end %> | |
| 55 | 42 | |
| 56 | 43 | <% button_bar do %> |
| 57 | 44 | <%= button :back, _('Go back'), { :controller => 'profile' } %> |
| ... | ... | @@ -66,7 +53,6 @@ |
| 66 | 53 | <% end %> |
| 67 | 54 | |
| 68 | 55 | <%= hidden_field_tag "profile_url", @profile_members_url %> |
| 69 | -<%= hidden_field_tag "sort", "asc" %> | |
| 70 | -</div><!-- fim class="common-profile-list-block" --> | |
| 56 | +</div><!-- end of class="common-profile-list-block" --> | |
| 71 | 57 | |
| 72 | 58 | <%= javascript_include_tag "members_page.js" %> | ... | ... |
| ... | ... | @@ -32,6 +32,9 @@ |
| 32 | 32 | </div> |
| 33 | 33 | <% else %> |
| 34 | 34 | <div> |
| 35 | + <%= labelled_check_box _("Secret — hide the community and all its contents for non members and other people can't join this community unless they are invited to."), 'profile_data[secret]', true, profile.secret, :class => "profile-secret-box" %> | |
| 36 | + </div> | |
| 37 | + <div> | |
| 35 | 38 | <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> |
| 36 | 39 | </div> |
| 37 | 40 | <div> |
| ... | ... | @@ -84,4 +87,4 @@ |
| 84 | 87 | <% end %> |
| 85 | 88 | <% end %> |
| 86 | 89 | <% end %> |
| 87 | -<% end %> | |
| 88 | 90 | \ No newline at end of file |
| 91 | +<% end %> | ... | ... |
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | <% if multiple_search?(@searches) %> |
| 10 | 10 | <h3><%= @names[name] %></h3> |
| 11 | 11 | <% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %> |
| 12 | - <%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %> | |
| 12 | + <%= link_to(_("see all (%d)") % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %> | |
| 13 | 13 | <% end %> |
| 14 | 14 | <% end %> |
| 15 | 15 | ... | ... |
-
@simiaosimis @thiago por questões de conflito eu desfiz esse commit e refiz sem a parte das traduções e já está na master e na stable... porém eu não consegui identificar quais traduções vocês fazem, se é apenas essas do beneficiarios e recursos economizados, se for está OK, se não for tem que regerar a tradução na stable e traduzir o que foi feito nesse commit. me pinguem plx pra resolver isso
-
mentioned in commit e89047ef388db6174b8afcda6c6a95fc68d6874a
-
@tallysmartins Eram só esse dois lugares mesmo (Benefited People, Saved Resources), então tudo certo.
-
em relação ao %d em ver todos é problema de traduçao, logo quando gerar as traduções certas deve resolver.
-
@lucianopc faz um rebase com a master
-
Status changed to closed
-
Status changed to reopened