Commit 604eb3f6bb8d6ad9515ea0d596ae29b1d51d87bb
1 parent
3b83c471
Exists in
master
and in
28 other branches
plugins-infra: add infra support to core extensions
The core extensions now should be created inside the folder lib/ext. They will automatically loaded, so no need for the requires on the plugin class definition file. Further information on how to use this feature here: http://noosfero.org/Development/PluginsArchitecture#Extending_core_classes
Showing
31 changed files
with
75 additions
and
104 deletions
Show diff stats
lib/noosfero/plugin.rb
plugins/bsc/lib/bsc_plugin.rb
plugins/comment_group/lib/comment_group_plugin.rb
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
... | ... | @@ -1,21 +0,0 @@ |
1 | -require_dependency 'article' | |
2 | - | |
3 | -class Article | |
4 | - | |
5 | - #FIXME make this test | |
6 | - has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL'] | |
7 | - | |
8 | - #FIXME make this test | |
9 | - validate :not_empty_group_comments_removed | |
10 | - | |
11 | - #FIXME make this test | |
12 | - def not_empty_group_comments_removed | |
13 | - if body | |
14 | - groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq | |
15 | - groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i} | |
16 | - errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty? | |
17 | - end | |
18 | - end | |
19 | - | |
20 | -end | |
21 | - |
plugins/comment_group/lib/comment_group_plugin/ext/comment.rb
... | ... | @@ -0,0 +1,21 @@ |
1 | +require_dependency 'article' | |
2 | + | |
3 | +class Article | |
4 | + | |
5 | + #FIXME make this test | |
6 | + has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL'] | |
7 | + | |
8 | + #FIXME make this test | |
9 | + validate :not_empty_group_comments_removed | |
10 | + | |
11 | + #FIXME make this test | |
12 | + def not_empty_group_comments_removed | |
13 | + if body | |
14 | + groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq | |
15 | + groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i} | |
16 | + errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty? | |
17 | + end | |
18 | + end | |
19 | + | |
20 | +end | |
21 | + | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin.rb
plugins/foo/lib/foo_plugin.rb
plugins/foo/lib/foo_plugin/ext/profile.rb
plugins/google_analytics/lib/google_analytics_plugin.rb
plugins/ldap/lib/ldap_plugin.rb
plugins/pg_search/lib/pg_search_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
plugins/shopping_cart/lib/shopping_cart_plugin.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/person.rb
plugins/solr/lib/solr_plugin.rb
plugins/stoa/lib/stoa_plugin.rb
... | ... | @@ -0,0 +1,13 @@ |
1 | +require_dependency 'organization' | |
2 | +class Organization | |
3 | + settings_items :sub_organizations_plugin_parent_to_be | |
4 | + | |
5 | + after_create do |organization| | |
6 | + if organization.sub_organizations_plugin_parent_to_be.present? | |
7 | + parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) | |
8 | + SubOrganizationsPlugin::Relation.add_children(parent,organization) | |
9 | + end | |
10 | + end | |
11 | + | |
12 | + FIELDS << 'sub_organizations_plugin_parent_to_be' | |
13 | +end | ... | ... |
plugins/sub_organizations/lib/sub_organizations_plugin.rb
plugins/sub_organizations/lib/sub_organizations_plugin/ext/create_enterprise.rb
plugins/sub_organizations/lib/sub_organizations_plugin/ext/organization.rb
... | ... | @@ -1,13 +0,0 @@ |
1 | -require_dependency 'organization' | |
2 | -class Organization | |
3 | - settings_items :sub_organizations_plugin_parent_to_be | |
4 | - | |
5 | - after_create do |organization| | |
6 | - if organization.sub_organizations_plugin_parent_to_be.present? | |
7 | - parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) | |
8 | - SubOrganizationsPlugin::Relation.add_children(parent,organization) | |
9 | - end | |
10 | - end | |
11 | - | |
12 | - FIELDS << 'sub_organizations_plugin_parent_to_be' | |
13 | -end |
plugins/tolerance_time/lib/tolerance_time_plugin.rb
plugins/work_assignment/lib/work_assignment_plugin.rb