Commit 1b8ca019f41431e2e4439a2f0b3e5796b95bc16b

Authored by Luciano Prestes
1 parent eacb4d70

Change class community to class software

Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
src/noosfero-spb/software_communities/lib/ext/community.rb
... ... @@ -1,66 +0,0 @@
1   -require_dependency 'community'
2   -
3   -class Community
4   -
5   - SEARCHABLE_SOFTWARE_FIELDS = {
6   - :name => 1,
7   - :identifier => 2,
8   - :nickname => 3
9   - }
10   -
11   - attr_accessible :visible
12   -
13   - has_one :software_info, :dependent=>:destroy, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo"
14   -
15   - settings_items :hits, :type => :integer, :default => 0
16   -
17   - def self.create_after_moderation(requestor, attributes = {})
18   - community = Community.new(attributes)
19   -
20   - if community.environment.enabled?('admin_must_approve_new_communities') &&
21   - !community.is_admin?(requestor)
22   -
23   - cc = CreateCommunity.create(attributes.merge(:requestor => requestor))
24   - else
25   - community = Community.create(attributes)
26   - community.add_admin(requestor)
27   - end
28   - community
29   - end
30   -
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
48   - self.visible = false
49   - self.save!
50   - end
51   -
52   - def activate
53   - self.visible = true
54   - self.save!
55   - 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
src/noosfero-spb/software_communities/lib/software_communities_plugin/software.rb 0 → 100644
... ... @@ -0,0 +1,64 @@
  1 +class SoftwareCommunitiesPlugin::Software < Organization
  2 +
  3 + SEARCHABLE_SOFTWARE_FIELDS = {
  4 + :name => 1,
  5 + :identifier => 2,
  6 + :nickname => 3
  7 + }
  8 +
  9 + attr_accessible :visible
  10 +
  11 + has_one :software_info, :dependent=>:destroy, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo"
  12 +
  13 + settings_items :hits, :type => :integer, :default => 0
  14 +
  15 + def self.create_after_moderation(requestor, attributes = {})
  16 + community = SoftwareCommunitiesPlugin::Software.new(attributes)
  17 +
  18 + if community.environment.enabled?('admin_must_approve_new_communities') &&
  19 + !community.is_admin?(requestor)
  20 +
  21 + cc = SoftwareCommunitiesPlugin::CreateSoftware.create(attributes.merge(:requestor => requestor))
  22 + else
  23 + community = SoftwareCommunitiesPlugin::Software.create(attributes)
  24 + community.add_admin(requestor)
  25 + end
  26 + community
  27 + end
  28 +
  29 + def self.get_valid_communities_string
  30 + remove_of_communities_methods = SoftwareCommunitiesPlugin::Software.instance_methods.select{|m| m =~ /remove_of_community_search/}
  31 + valid_communities_string = "!("
  32 + remove_of_communities_methods.each do |method|
  33 + valid_communities_string += "community.send('#{method}') || "
  34 + end
  35 + valid_communities_string = valid_communities_string[0..-5]
  36 + valid_communities_string += ")"
  37 +
  38 + valid_communities_string
  39 + end
  40 +
  41 + def software?
  42 + return !software_info.nil?
  43 + end
  44 +
  45 + def deactivate
  46 + self.visible = false
  47 + self.save!
  48 + end
  49 +
  50 + def activate
  51 + self.visible = true
  52 + self.save!
  53 + end
  54 +
  55 + def remove_of_community_search_software?
  56 + return software?
  57 + end
  58 +
  59 + def hit
  60 + self.hits += 1
  61 + self.save!
  62 + end
  63 +
  64 +end
... ...