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,12 +18,6 @@ class CommunitiesBlock | ||
18 | [:image,:domains,:preferred_domain,:environment] | 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 | if !prioritize_profiles_with_image | 21 | if !prioritize_profiles_with_image |
28 | return visible_profiles.all( | 22 | return visible_profiles.all( |
29 | :limit => get_limit, | 23 | :limit => get_limit, |
src/noosfero-spb/software_communities/lib/ext/community.rb
1 | require_dependency 'community' | 1 | require_dependency 'community' |
2 | 2 | ||
3 | class Community | 3 | class Community |
4 | - | ||
5 | - SEARCHABLE_SOFTWARE_FIELDS = { | ||
6 | - :name => 1, | ||
7 | - :identifier => 2, | ||
8 | - :nickname => 3 | ||
9 | - } | ||
10 | - | ||
11 | attr_accessible :visible | 4 | attr_accessible :visible |
12 | 5 | ||
13 | - has_one :software_info, :dependent=>:destroy | ||
14 | - | ||
15 | - settings_items :hits, :type => :integer, :default => 0 | ||
16 | - | ||
17 | def self.create_after_moderation(requestor, attributes = {}) | 6 | def self.create_after_moderation(requestor, attributes = {}) |
18 | community = Community.new(attributes) | 7 | community = Community.new(attributes) |
19 | 8 | ||
@@ -28,22 +17,6 @@ class Community | @@ -28,22 +17,6 @@ class Community | ||
28 | community | 17 | community |
29 | end | 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 | def deactivate | 20 | def deactivate |
48 | self.visible = false | 21 | self.visible = false |
49 | self.save! | 22 | self.save! |
@@ -53,14 +26,4 @@ class Community | @@ -53,14 +26,4 @@ class Community | ||
53 | self.visible = true | 26 | self.visible = true |
54 | self.save! | 27 | self.save! |
55 | end | 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 | end | 29 | end |
src/noosfero-spb/software_communities/lib/ext/person.rb
@@ -6,10 +6,6 @@ class Person | @@ -6,10 +6,6 @@ class Person | ||
6 | 6 | ||
7 | delegate :login, :to => :user, :prefix => true | 7 | delegate :login, :to => :user, :prefix => true |
8 | 8 | ||
9 | - def software? | ||
10 | - false | ||
11 | - end | ||
12 | - | ||
13 | #def softwares | 9 | #def softwares |
14 | # softwares = [] | 10 | # softwares = [] |
15 | # self.communities.each do |community| | 11 | # self.communities.each do |community| |
src/noosfero-spb/software_communities/lib/ext/profile_controller.rb
@@ -14,7 +14,7 @@ class ProfileController | @@ -14,7 +14,7 @@ class ProfileController | ||
14 | type = profile.institutions | 14 | type = profile.institutions |
15 | else | 15 | else |
16 | profile.communities.select do |community| | 16 | profile.communities.select do |community| |
17 | - type << community unless community.software? || community.institution? | 17 | + type << community unless community.institution? |
18 | end | 18 | end |
19 | end | 19 | end |
20 | 20 |
src/noosfero-spb/software_communities/lib/ext/profile_editor_controller.rb
@@ -1,28 +0,0 @@ | @@ -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 | require_dependency 'search_controller' | 1 | require_dependency 'search_controller' |
2 | 2 | ||
3 | class SearchController | 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 | def software_infos | 4 | def software_infos |
17 | prepare_software_search_page | 5 | prepare_software_search_page |
18 | results = filter_software_infos_list | 6 | results = filter_software_infos_list |
src/noosfero-spb/software_communities/lib/software.rb
1 | class Software < Organization | 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 | has_one :software_info | 10 | has_one :software_info |
3 | validates_presence_of :software_info | 11 | validates_presence_of :software_info |
4 | attr_accessible :software_info | 12 | attr_accessible :software_info |
5 | after_save { software_info.save! } | 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 | end | 20 | end |
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
@@ -22,13 +22,13 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -22,13 +22,13 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
22 | end | 22 | end |
23 | 23 | ||
24 | def profile_tabs | 24 | def profile_tabs |
25 | - if context.profile.community? && context.profile.software? | 25 | + if context.profile.kind_of?(Software) |
26 | return profile_tabs_software | 26 | return profile_tabs_software |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
30 | def control_panel_buttons | 30 | def control_panel_buttons |
31 | - if context.profile.software? | 31 | + if context.profile.kind_of?(Software) |
32 | return software_info_button | 32 | return software_info_button |
33 | elsif context.profile.person? | 33 | elsif context.profile.person? |
34 | return create_new_software_button | 34 | return create_new_software_button |
@@ -86,7 +86,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -86,7 +86,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
86 | end | 86 | end |
87 | 87 | ||
88 | def organization_ratings_plugin_comments_extra_fields | 88 | def organization_ratings_plugin_comments_extra_fields |
89 | - if context.profile.software? | 89 | + if context.profile.kind_of?(Software) |
90 | Proc::new { render :file => 'comments_extra_fields' } | 90 | Proc::new { render :file => 'comments_extra_fields' } |
91 | end | 91 | end |
92 | end | 92 | end |
@@ -106,7 +106,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -106,7 +106,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
106 | is_admin = environment.admins.include?(current_user.person) | 106 | is_admin = environment.admins.include?(current_user.person) |
107 | is_admin ||= user_rating.organization.admins.include?(current_user.person) | 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 | render :file => 'organization_ratings_extra_fields_show_data', | 110 | render :file => 'organization_ratings_extra_fields_show_data', |
111 | :locals => {:user_rating => user_rating} | 111 | :locals => {:user_rating => user_rating} |
112 | end | 112 | end |
src/noosfero-spb/software_communities/lib/softwares_block.rb
@@ -52,10 +52,7 @@ class SoftwaresBlock < CommunitiesBlock | @@ -52,10 +52,7 @@ class SoftwaresBlock < CommunitiesBlock | ||
52 | 52 | ||
53 | def profile_list | 53 | def profile_list |
54 | profiles = get_visible_profiles | 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 | block_softwares = if self.software_type == "Public" | 57 | block_softwares = if self.software_type == "Public" |
61 | software_profiles.select { |profile| profile.software_info.public_software? } | 58 | software_profiles.select { |profile| profile.software_info.public_software? } |