Commit 586af7d1dbc8438ddb54db28fd7b8111063106f2
1 parent
b810ff60
Exists in
software_as_organization
remove unnecessary community extensions
Showing
9 changed files
with
20 additions
and
96 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/ext/communities_block.rb
| ... | ... | @@ -18,12 +18,6 @@ class CommunitiesBlock |
| 18 | 18 | [:image,:domains,:preferred_domain,:environment] |
| 19 | 19 | ) |
| 20 | 20 | |
| 21 | - delete_communities = [] | |
| 22 | - valid_communities_string = Community.get_valid_communities_string | |
| 23 | - Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} | |
| 24 | - | |
| 25 | - visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) unless delete_communities.empty? | |
| 26 | - | |
| 27 | 21 | if !prioritize_profiles_with_image |
| 28 | 22 | return visible_profiles.all( |
| 29 | 23 | :limit => get_limit, | ... | ... |
src/noosfero-spb/software_communities/lib/ext/community.rb
| 1 | 1 | require_dependency 'community' |
| 2 | 2 | |
| 3 | 3 | class Community |
| 4 | - | |
| 5 | - SEARCHABLE_SOFTWARE_FIELDS = { | |
| 6 | - :name => 1, | |
| 7 | - :identifier => 2, | |
| 8 | - :nickname => 3 | |
| 9 | - } | |
| 10 | - | |
| 11 | 4 | attr_accessible :visible |
| 12 | 5 | |
| 13 | - has_one :software_info, :dependent=>:destroy | |
| 14 | - | |
| 15 | - settings_items :hits, :type => :integer, :default => 0 | |
| 16 | - | |
| 17 | 6 | def self.create_after_moderation(requestor, attributes = {}) |
| 18 | 7 | community = Community.new(attributes) |
| 19 | 8 | |
| ... | ... | @@ -28,22 +17,6 @@ class Community |
| 28 | 17 | community |
| 29 | 18 | end |
| 30 | 19 | |
| 31 | - def self.get_valid_communities_string | |
| 32 | - remove_of_communities_methods = Community.instance_methods.select{|m| m =~ /remove_of_community_search/} | |
| 33 | - valid_communities_string = "!(" | |
| 34 | - remove_of_communities_methods.each do |method| | |
| 35 | - valid_communities_string += "community.send('#{method}') || " | |
| 36 | - end | |
| 37 | - valid_communities_string = valid_communities_string[0..-5] | |
| 38 | - valid_communities_string += ")" | |
| 39 | - | |
| 40 | - valid_communities_string | |
| 41 | - end | |
| 42 | - | |
| 43 | - def software? | |
| 44 | - return !software_info.nil? | |
| 45 | - end | |
| 46 | - | |
| 47 | 20 | def deactivate |
| 48 | 21 | self.visible = false |
| 49 | 22 | self.save! |
| ... | ... | @@ -53,14 +26,4 @@ class Community |
| 53 | 26 | self.visible = true |
| 54 | 27 | self.save! |
| 55 | 28 | end |
| 56 | - | |
| 57 | - def remove_of_community_search_software? | |
| 58 | - return software? | |
| 59 | - end | |
| 60 | - | |
| 61 | - def hit | |
| 62 | - self.hits += 1 | |
| 63 | - self.save! | |
| 64 | - end | |
| 65 | - | |
| 66 | 29 | end | ... | ... |
src/noosfero-spb/software_communities/lib/ext/person.rb
src/noosfero-spb/software_communities/lib/ext/profile_controller.rb
| ... | ... | @@ -14,7 +14,7 @@ class ProfileController |
| 14 | 14 | type = profile.institutions |
| 15 | 15 | else |
| 16 | 16 | profile.communities.select do |community| |
| 17 | - type << community unless community.software? || community.institution? | |
| 17 | + type << community unless community.institution? | |
| 18 | 18 | end |
| 19 | 19 | end |
| 20 | 20 | ... | ... |
src/noosfero-spb/software_communities/lib/ext/profile_editor_controller.rb
| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | -require_dependency 'profile_editor_controller' | |
| 2 | - | |
| 3 | -class ProfileEditorController | |
| 4 | - | |
| 5 | - before_filter :redirect_to_edit_software_community, :only => [:edit] | |
| 6 | - | |
| 7 | - def edit_software_community | |
| 8 | - @profile_data = profile | |
| 9 | - @possible_domains = profile.possible_domains | |
| 10 | - @first_edit = profile.software_info.first_edit? | |
| 11 | - | |
| 12 | - if @first_edit | |
| 13 | - profile.software_info.first_edit = false | |
| 14 | - profile.software_info.save! | |
| 15 | - end | |
| 16 | - | |
| 17 | - edit if request.post? | |
| 18 | - end | |
| 19 | - | |
| 20 | - protected | |
| 21 | - | |
| 22 | - def redirect_to_edit_software_community | |
| 23 | - if profile.class == Community && profile.software? | |
| 24 | - redirect_to :action => 'edit_software_community' | |
| 25 | - end | |
| 26 | - end | |
| 27 | - | |
| 28 | -end |
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
| 1 | 1 | require_dependency 'search_controller' |
| 2 | 2 | |
| 3 | 3 | class SearchController |
| 4 | - | |
| 5 | - def communities | |
| 6 | - delete_communities = [] | |
| 7 | - valid_communities_string = Community.get_valid_communities_string | |
| 8 | - Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} | |
| 9 | - | |
| 10 | - @scope = visible_profiles(Community) | |
| 11 | - @scope = @scope.where(["id NOT IN (?)", delete_communities]) unless delete_communities.empty? | |
| 12 | - | |
| 13 | - full_text_search | |
| 14 | - end | |
| 15 | - | |
| 16 | 4 | def software_infos |
| 17 | 5 | prepare_software_search_page |
| 18 | 6 | results = filter_software_infos_list | ... | ... |
src/noosfero-spb/software_communities/lib/software.rb
| 1 | 1 | class Software < Organization |
| 2 | + SEARCHABLE_SOFTWARE_FIELDS = { | |
| 3 | + :name => 1, | |
| 4 | + :identifier => 2, | |
| 5 | + :nickname => 3 | |
| 6 | + } | |
| 7 | + | |
| 8 | + settings_items :hits, :type => :integer, :default => 0 | |
| 9 | + | |
| 2 | 10 | has_one :software_info |
| 3 | 11 | validates_presence_of :software_info |
| 4 | 12 | attr_accessible :software_info |
| 5 | 13 | after_save { software_info.save! } |
| 14 | + | |
| 15 | + #FIXME This is a performance bottleneck on heavy loads. | |
| 16 | + def hit | |
| 17 | + self.hits += 1 | |
| 18 | + self.save! | |
| 19 | + end | |
| 6 | 20 | end | ... | ... |
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
| ... | ... | @@ -22,13 +22,13 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | 24 | def profile_tabs |
| 25 | - if context.profile.community? && context.profile.software? | |
| 25 | + if context.profile.kind_of?(Software) | |
| 26 | 26 | return profile_tabs_software |
| 27 | 27 | end |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | def control_panel_buttons |
| 31 | - if context.profile.software? | |
| 31 | + if context.profile.kind_of?(Software) | |
| 32 | 32 | return software_info_button |
| 33 | 33 | elsif context.profile.person? |
| 34 | 34 | return create_new_software_button |
| ... | ... | @@ -86,7 +86,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 86 | 86 | end |
| 87 | 87 | |
| 88 | 88 | def organization_ratings_plugin_comments_extra_fields |
| 89 | - if context.profile.software? | |
| 89 | + if context.profile.kind_of?(Software) | |
| 90 | 90 | Proc::new { render :file => 'comments_extra_fields' } |
| 91 | 91 | end |
| 92 | 92 | end |
| ... | ... | @@ -106,7 +106,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 106 | 106 | is_admin = environment.admins.include?(current_user.person) |
| 107 | 107 | is_admin ||= user_rating.organization.admins.include?(current_user.person) |
| 108 | 108 | |
| 109 | - if is_admin and profile.software? | |
| 109 | + if is_admin and profile.kind_of?(Software) | |
| 110 | 110 | render :file => 'organization_ratings_extra_fields_show_data', |
| 111 | 111 | :locals => {:user_rating => user_rating} |
| 112 | 112 | end | ... | ... |
src/noosfero-spb/software_communities/lib/softwares_block.rb
| ... | ... | @@ -52,10 +52,7 @@ class SoftwaresBlock < CommunitiesBlock |
| 52 | 52 | |
| 53 | 53 | def profile_list |
| 54 | 54 | profiles = get_visible_profiles |
| 55 | - | |
| 56 | - software_profiles = profiles.select do |profile| | |
| 57 | - profile.class == Community && profile.software? | |
| 58 | - end | |
| 55 | + software_profiles = profiles.where(:type => 'Software') | |
| 59 | 56 | |
| 60 | 57 | block_softwares = if self.software_type == "Public" |
| 61 | 58 | software_profiles.select { |profile| profile.software_info.public_software? } | ... | ... |