Commit f7be1cc6b29aa75dbc43f7a6209293b642512534
1 parent
e0f36662
Exists in
master
and in
29 other branches
rails3: fix sub_organizations plugin
Showing
23 changed files
with
214 additions
and
209 deletions
Show diff stats
plugins/sub_organizations/controllers/sub_organizations_plugin_myprofile_controller.rb
@@ -5,12 +5,12 @@ class SubOrganizationsPluginMyprofileController < MyProfileController | @@ -5,12 +5,12 @@ class SubOrganizationsPluginMyprofileController < MyProfileController | ||
5 | protect 'edit_profile', :profile | 5 | protect 'edit_profile', :profile |
6 | 6 | ||
7 | def index | 7 | def index |
8 | - @children = SubOrganizationsPlugin::Relation.children(profile) | 8 | + @children = Organization.children(profile) |
9 | @tokenized_children = prepare_to_token_input(@children) | 9 | @tokenized_children = prepare_to_token_input(@children) |
10 | - @pending_children = SubOrganizationsPlugin::ApprovePaternityRelation.pending_children(profile) | 10 | + @pending_children = Organization.pending_children(profile) |
11 | if request.post? | 11 | if request.post? |
12 | begin | 12 | begin |
13 | - original = SubOrganizationsPlugin::Relation.children(profile) | 13 | + original = Organization.children(profile) |
14 | requested = Organization.find(params[:q].split(',')) | 14 | requested = Organization.find(params[:q].split(',')) |
15 | added = requested - original | 15 | added = requested - original |
16 | removed = original - requested | 16 | removed = original - requested |
@@ -37,8 +37,8 @@ class SubOrganizationsPluginMyprofileController < MyProfileController | @@ -37,8 +37,8 @@ class SubOrganizationsPluginMyprofileController < MyProfileController | ||
37 | AND (identifier NOT LIKE ?) AND (id != ?)", | 37 | AND (identifier NOT LIKE ?) AND (id != ?)", |
38 | "%#{params[:q]}%", "%#{params[:q]}%", "%_template", profile.id]). | 38 | "%#{params[:q]}%", "%#{params[:q]}%", "%_template", profile.id]). |
39 | select { |organization| | 39 | select { |organization| |
40 | - SubOrganizationsPlugin::Relation.children(organization).blank? && | ||
41 | - !SubOrganizationsPlugin::ApprovePaternityRelation.pending_children(profile).include?(organization) | 40 | + Organization.children(organization).blank? && |
41 | + !Organization.pending_children(profile).include?(organization) | ||
42 | }).to_json | 42 | }).to_json |
43 | end | 43 | end |
44 | 44 |
plugins/sub_organizations/controllers/sub_organizations_plugin_profile_controller.rb
@@ -4,13 +4,13 @@ class SubOrganizationsPluginProfileController < ProfileController | @@ -4,13 +4,13 @@ class SubOrganizationsPluginProfileController < ProfileController | ||
4 | before_filter :organizations_only | 4 | before_filter :organizations_only |
5 | 5 | ||
6 | def children | 6 | def children |
7 | - children = SubOrganizationsPlugin::Relation.children(profile) | 7 | + children = Organization.children(profile) |
8 | family_relation(children) | 8 | family_relation(children) |
9 | render 'related_organizations' | 9 | render 'related_organizations' |
10 | end | 10 | end |
11 | 11 | ||
12 | def parents | 12 | def parents |
13 | - parents = SubOrganizationsPlugin::Relation.parents(profile) | 13 | + parents = Organization.parents(profile) |
14 | family_relation(parents) | 14 | family_relation(parents) |
15 | render 'related_organizations' | 15 | render 'related_organizations' |
16 | end | 16 | end |
plugins/sub_organizations/lib/ext/organization.rb
@@ -2,6 +2,8 @@ require_dependency 'organization' | @@ -2,6 +2,8 @@ require_dependency 'organization' | ||
2 | class Organization | 2 | class Organization |
3 | settings_items :sub_organizations_plugin_parent_to_be | 3 | settings_items :sub_organizations_plugin_parent_to_be |
4 | 4 | ||
5 | + attr_accessible :sub_organizations_plugin_parent_to_be | ||
6 | + | ||
5 | after_create do |organization| | 7 | after_create do |organization| |
6 | if organization.sub_organizations_plugin_parent_to_be.present? | 8 | if organization.sub_organizations_plugin_parent_to_be.present? |
7 | parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) | 9 | parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) |
@@ -10,4 +12,27 @@ class Organization | @@ -10,4 +12,27 @@ class Organization | ||
10 | end | 12 | end |
11 | 13 | ||
12 | FIELDS << 'sub_organizations_plugin_parent_to_be' | 14 | FIELDS << 'sub_organizations_plugin_parent_to_be' |
15 | + | ||
16 | + scope :children, lambda { |parent| | ||
17 | + options = { | ||
18 | + :joins => "inner join sub_organizations_plugin_relations as relations on profiles.id=relations.child_id", | ||
19 | + :conditions => ["relations.parent_id = ?", parent.id] | ||
20 | + } | ||
21 | + } | ||
22 | + | ||
23 | + scope :parents, lambda { |*children| | ||
24 | + options = { | ||
25 | + :joins => "inner join sub_organizations_plugin_relations as relations on profiles.id=relations.parent_id", | ||
26 | + :conditions => ["relations.child_id in (?)", children.map(&:id)] | ||
27 | + } | ||
28 | + } | ||
29 | + | ||
30 | + scope :pending_children, lambda { |parent| | ||
31 | + options = { | ||
32 | + :select => "distinct profiles.*", | ||
33 | + :joins => "inner join sub_organizations_plugin_approve_paternity_relations as relations on profiles.id=relations.child_id inner join tasks on relations.task_id=tasks.id", | ||
34 | + :conditions => ["relations.parent_id = ? AND tasks.status = 1", parent.id] | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
13 | end | 38 | end |
plugins/sub_organizations/lib/related_organizations_block.rb
@@ -2,25 +2,29 @@ class RelatedOrganizationsBlock < ProfileListBlock | @@ -2,25 +2,29 @@ class RelatedOrganizationsBlock < ProfileListBlock | ||
2 | 2 | ||
3 | settings_items :organization_type, :type => :string, :default => 'both' | 3 | settings_items :organization_type, :type => :string, :default => 'both' |
4 | 4 | ||
5 | - @display_type = {:title => 'related', :action => 'children' } | 5 | + attr_accessible :organization_type |
6 | 6 | ||
7 | def self.description | 7 | def self.description |
8 | - __("#{@display_type[:title].capitalize} Organizations") | 8 | + _("Related Organizations") |
9 | + end | ||
10 | + | ||
11 | + def display_type | ||
12 | + @display_type ||= {:title => 'related', :action => 'children' } | ||
9 | end | 13 | end |
10 | 14 | ||
11 | def default_title | 15 | def default_title |
12 | case organization_type | 16 | case organization_type |
13 | when 'enterprise' | 17 | when 'enterprise' |
14 | - n__("{#} #{@display_type[:title]} enterprise", "{#} #{@display_type[:title]} enterprises", profile_count) | 18 | + n_("{#} #{display_type[:title]} enterprise", "{#} #{display_type[:title]} enterprises", profile_count) |
15 | when 'community' | 19 | when 'community' |
16 | - n__("{#} #{@display_type[:title]} community", "{#} #{@display_type[:title]} communities", profile_count) | 20 | + n_("{#} #{display_type[:title]} community", "{#} #{display_type[:title]} communities", profile_count) |
17 | else | 21 | else |
18 | - n__("{#} #{@display_type[:title]} organization", "{#} #{@display_type[:title]} organizations", profile_count) | 22 | + n_("{#} #{display_type[:title]} organization", "{#} #{display_type[:title]} organizations", profile_count) |
19 | end | 23 | end |
20 | end | 24 | end |
21 | 25 | ||
22 | def help | 26 | def help |
23 | - _("This block displays #{@display_type[:title]} organizations of this organization") | 27 | + _("This block displays #{display_type[:title]} organizations of this organization") |
24 | end | 28 | end |
25 | 29 | ||
26 | def profiles | 30 | def profiles |
@@ -38,20 +42,20 @@ class RelatedOrganizationsBlock < ProfileListBlock | @@ -38,20 +42,20 @@ class RelatedOrganizationsBlock < ProfileListBlock | ||
38 | def footer | 42 | def footer |
39 | profile = self.owner | 43 | profile = self.owner |
40 | type = self.organization_type | 44 | type = self.organization_type |
41 | - params = {:profile => profile.identifier, :controller => 'sub_organizations_plugin_profile', :action => @display_type[:action]} | 45 | + params = {:profile => profile.identifier, :controller => 'sub_organizations_plugin_profile', :action => display_type[:action]} |
42 | params[:type] = type if type == 'enterprise' || type == 'community' | 46 | params[:type] = type if type == 'enterprise' || type == 'community' |
43 | - lambda do | 47 | + proc do |
44 | link_to _('View all'), params.merge(params) | 48 | link_to _('View all'), params.merge(params) |
45 | end | 49 | end |
46 | end | 50 | end |
47 | 51 | ||
48 | def related_organizations | 52 | def related_organizations |
49 | profile = self.owner | 53 | profile = self.owner |
50 | - organizations = SubOrganizationsPlugin::Relation.parents(profile) | 54 | + organizations = Organization.parents(profile) |
51 | 55 | ||
52 | if organizations.blank? | 56 | if organizations.blank? |
53 | @display_type = {:title => 'sub', :action => 'children'} | 57 | @display_type = {:title => 'sub', :action => 'children'} |
54 | - organizations = SubOrganizationsPlugin::Relation.children(profile) | 58 | + organizations = Organization.children(profile) |
55 | else | 59 | else |
56 | @display_type = {:title => 'parent', :action => 'parents' } | 60 | @display_type = {:title => 'parent', :action => 'parents' } |
57 | organizations | 61 | organizations |
plugins/sub_organizations/lib/sub_organizations_plugin.rb
@@ -19,7 +19,7 @@ class SubOrganizationsPlugin < Noosfero::Plugin | @@ -19,7 +19,7 @@ class SubOrganizationsPlugin < Noosfero::Plugin | ||
19 | end | 19 | end |
20 | 20 | ||
21 | def control_panel_buttons | 21 | def control_panel_buttons |
22 | - if context.profile.organization? && SubOrganizationsPlugin::Relation.parents(context.profile).blank? | 22 | + if context.profile.organization? && Organization.parents(context.profile).blank? |
23 | { :title => _('Manage sub-groups'), :icon => 'groups', :url => {:controller => 'sub_organizations_plugin_myprofile'} } | 23 | { :title => _('Manage sub-groups'), :icon => 'groups', :url => {:controller => 'sub_organizations_plugin_myprofile'} } |
24 | end | 24 | end |
25 | end | 25 | end |
@@ -29,17 +29,17 @@ class SubOrganizationsPlugin < Noosfero::Plugin | @@ -29,17 +29,17 @@ class SubOrganizationsPlugin < Noosfero::Plugin | ||
29 | end | 29 | end |
30 | 30 | ||
31 | def organization_members(organization) | 31 | def organization_members(organization) |
32 | - children = SubOrganizationsPlugin::Relation.children(organization) | ||
33 | - Person.members_of(children) if children.present? | 32 | + children = Organization.children(organization) |
33 | + Person.members_of(children.all) if children.present? | ||
34 | end | 34 | end |
35 | 35 | ||
36 | def person_memberships(person) | 36 | def person_memberships(person) |
37 | - SubOrganizationsPlugin::Relation.parents(*Profile.memberships_of(person)) | 37 | + Organization.parents(*Profile.memberships_of(person)) |
38 | end | 38 | end |
39 | 39 | ||
40 | def has_permission?(person, permission, target) | 40 | def has_permission?(person, permission, target) |
41 | if !target.kind_of?(Environment) && target.organization? | 41 | if !target.kind_of?(Environment) && target.organization? |
42 | - SubOrganizationsPlugin::Relation.parents(target).map do |parent| | 42 | + Organization.parents(target).map do |parent| |
43 | person.has_permission_without_plugins?(permission, parent) | 43 | person.has_permission_without_plugins?(permission, parent) |
44 | end.include?(true) | 44 | end.include?(true) |
45 | end | 45 | end |
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity.rb
@@ -13,7 +13,7 @@ class SubOrganizationsPlugin::ApprovePaternity < Task | @@ -13,7 +13,7 @@ class SubOrganizationsPlugin::ApprovePaternity < Task | ||
13 | end | 13 | end |
14 | 14 | ||
15 | def parent | 15 | def parent |
16 | - SubOrganizationsPlugin::ApprovePaternityRelation.parent(self) | 16 | + SubOrganizationsPlugin::ApprovePaternityRelation.parent_approval(self) |
17 | end | 17 | end |
18 | 18 | ||
19 | def title | 19 | def title |
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
@@ -5,19 +5,12 @@ class SubOrganizationsPlugin::ApprovePaternityRelation < Noosfero::Plugin::Activ | @@ -5,19 +5,12 @@ class SubOrganizationsPlugin::ApprovePaternityRelation < Noosfero::Plugin::Activ | ||
5 | 5 | ||
6 | validates_presence_of :task, :parent, :child | 6 | validates_presence_of :task, :parent, :child |
7 | 7 | ||
8 | + attr_accessible :task, :parent, :child | ||
9 | + | ||
8 | class << self | 10 | class << self |
9 | - def parent(task) | 11 | + def parent_approval(task) |
10 | find_by_task_id(task.id).parent | 12 | find_by_task_id(task.id).parent |
11 | end | 13 | end |
12 | - | ||
13 | - def pending_children(parent) | ||
14 | - options = { | ||
15 | - :select => "distinct profiles.*", | ||
16 | - :joins => "inner join sub_organizations_plugin_approve_paternity_relations as relations on profiles.id=relations.child_id inner join tasks on relations.task_id=tasks.id", | ||
17 | - :conditions => ["relations.parent_id = ? AND tasks.status = 1", parent.id] | ||
18 | - } | ||
19 | - ActiveRecord::NamedScope::Scope.new(Organization, options) | ||
20 | - end | ||
21 | end | 14 | end |
22 | 15 | ||
23 | end | 16 | end |
plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
@@ -7,41 +7,25 @@ class SubOrganizationsPlugin::Relation < Noosfero::Plugin::ActiveRecord | @@ -7,41 +7,25 @@ class SubOrganizationsPlugin::Relation < Noosfero::Plugin::ActiveRecord | ||
7 | validate :no_cyclical_reference, :if => 'parent.present? && child.present?' | 7 | validate :no_cyclical_reference, :if => 'parent.present? && child.present?' |
8 | validate :no_multi_level, :if => 'parent.present? && child.present?' | 8 | validate :no_multi_level, :if => 'parent.present? && child.present?' |
9 | 9 | ||
10 | + attr_accessible :parent, :child | ||
11 | + | ||
10 | def no_self_reference | 12 | def no_self_reference |
11 | errors.add(:child, _('self-reference is not allowed.')) if parent == child | 13 | errors.add(:child, _('self-reference is not allowed.')) if parent == child |
12 | end | 14 | end |
13 | 15 | ||
14 | def no_cyclical_reference | 16 | def no_cyclical_reference |
15 | - if self.class.children(child).include?(parent) | 17 | + if Organization.children(child).include?(parent) |
16 | errors.add(:child, _('cyclical reference is not allowed.')) | 18 | errors.add(:child, _('cyclical reference is not allowed.')) |
17 | end | 19 | end |
18 | end | 20 | end |
19 | 21 | ||
20 | def no_multi_level | 22 | def no_multi_level |
21 | - if self.class.parents(parent).present? || self.class.children(child).present? | 23 | + if Organization.parents(parent).present? || Organization.children(child).present? |
22 | errors.add(:child, _('multi-level paternity is not allowed.')) | 24 | errors.add(:child, _('multi-level paternity is not allowed.')) |
23 | end | 25 | end |
24 | end | 26 | end |
25 | 27 | ||
26 | class << self | 28 | class << self |
27 | - def children(parent) | ||
28 | - options = { | ||
29 | - :select => "profiles.*", | ||
30 | - :joins => "inner join sub_organizations_plugin_relations as relations on profiles.id=relations.child_id", | ||
31 | - :conditions => ["relations.parent_id = ?", parent.id] | ||
32 | - } | ||
33 | - ActiveRecord::NamedScope::Scope.new(Organization, options) | ||
34 | - end | ||
35 | - | ||
36 | - def parents(*children) | ||
37 | - options = { | ||
38 | - :select => "profiles.*", | ||
39 | - :joins => "inner join sub_organizations_plugin_relations as relations on profiles.id=relations.parent_id", | ||
40 | - :conditions => ["relations.child_id in (?)", children.map(&:id)] | ||
41 | - } | ||
42 | - ActiveRecord::NamedScope::Scope.new(Organization, options) | ||
43 | - end | ||
44 | - | ||
45 | def add_children(parent, *children) | 29 | def add_children(parent, *children) |
46 | children.each {|child| create!(:parent => parent, :child => child)} | 30 | children.each {|child| create!(:parent => parent, :child => child)} |
47 | end | 31 | end |
plugins/sub_organizations/test/functional/sub_organizations_plugin_myprofile_controller_test.rb
@@ -60,7 +60,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | @@ -60,7 +60,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | ||
60 | 60 | ||
61 | post :index, :profile => organization.identifier, :q => [org2,org3,org4].map(&:id).join(',') | 61 | post :index, :profile => organization.identifier, :q => [org2,org3,org4].map(&:id).join(',') |
62 | 62 | ||
63 | - children = SubOrganizationsPlugin::Relation.children(organization) | 63 | + children = Organization.children(organization) |
64 | assert_not_includes children, org1 | 64 | assert_not_includes children, org1 |
65 | assert_includes children, org2 | 65 | assert_includes children, org2 |
66 | assert_not_includes children, org3 | 66 | assert_not_includes children, org3 |
@@ -68,7 +68,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | @@ -68,7 +68,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | ||
68 | 68 | ||
69 | SubOrganizationsPlugin::ApprovePaternity.all.map(&:finish) | 69 | SubOrganizationsPlugin::ApprovePaternity.all.map(&:finish) |
70 | 70 | ||
71 | - children = SubOrganizationsPlugin::Relation.children(organization) | 71 | + children = Organization.children(organization) |
72 | assert_not_includes children, org1 | 72 | assert_not_includes children, org1 |
73 | assert_includes children, org2 | 73 | assert_includes children, org2 |
74 | assert_includes children, org3 | 74 | assert_includes children, org3 |
@@ -80,10 +80,10 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | @@ -80,10 +80,10 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | ||
80 | org2 = fast_create(Organization) | 80 | org2 = fast_create(Organization) |
81 | org2.add_admin(person) | 81 | org2.add_admin(person) |
82 | 82 | ||
83 | - assert_difference SubOrganizationsPlugin::ApprovePaternity, :count, 1 do | 83 | + assert_difference 'SubOrganizationsPlugin::ApprovePaternity.count', 1 do |
84 | post :index, :profile => organization.identifier, :q => [org1,org2].map(&:id).join(',') | 84 | post :index, :profile => organization.identifier, :q => [org1,org2].map(&:id).join(',') |
85 | end | 85 | end |
86 | - assert_includes SubOrganizationsPlugin::Relation.children(organization), org2 | 86 | + assert_includes Organization.children(organization), org2 |
87 | end | 87 | end |
88 | 88 | ||
89 | should 'not access index if dont have permission' do | 89 | should 'not access index if dont have permission' do |
@@ -94,7 +94,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | @@ -94,7 +94,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | ||
94 | get :index, :profile => organization.identifier | 94 | get :index, :profile => organization.identifier |
95 | 95 | ||
96 | assert_response 403 | 96 | assert_response 403 |
97 | - assert_template 'access_denied.rhtml' | 97 | + assert_template 'access_denied' |
98 | end | 98 | end |
99 | 99 | ||
100 | should 'not search organizations if dont have permission' do | 100 | should 'not search organizations if dont have permission' do |
@@ -107,7 +107,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | @@ -107,7 +107,7 @@ class SubOrganizationsPluginMyprofileControllerTest < ActionController::TestCase | ||
107 | get :search_organization, :profile => organization.identifier, :q => 'sampl' | 107 | get :search_organization, :profile => organization.identifier, :q => 'sampl' |
108 | 108 | ||
109 | assert_response 403 | 109 | assert_response 403 |
110 | - assert_template 'access_denied.rhtml' | 110 | + assert_template 'access_denied' |
111 | end | 111 | end |
112 | 112 | ||
113 | end | 113 | end |
plugins/sub_organizations/test/unit/sub_organizations_plugin/approve_paternity_relation_test.rb
@@ -13,7 +13,7 @@ class SubOrganizationsPlugin::ApprovePaternityRelationTest < ActiveSupport::Test | @@ -13,7 +13,7 @@ class SubOrganizationsPlugin::ApprovePaternityRelationTest < ActiveSupport::Test | ||
13 | org2 = fast_create(Organization) | 13 | org2 = fast_create(Organization) |
14 | task = SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org2, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name) | 14 | task = SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org2, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name) |
15 | 15 | ||
16 | - assert_equal SubOrganizationsPlugin::ApprovePaternityRelation.parent(task), org1 | 16 | + assert_equal SubOrganizationsPlugin::ApprovePaternityRelation.parent_approval(task), org1 |
17 | end | 17 | end |
18 | 18 | ||
19 | should 'list pending children' do | 19 | should 'list pending children' do |
@@ -25,8 +25,8 @@ class SubOrganizationsPlugin::ApprovePaternityRelationTest < ActiveSupport::Test | @@ -25,8 +25,8 @@ class SubOrganizationsPlugin::ApprovePaternityRelationTest < ActiveSupport::Test | ||
25 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org1, :temp_parent_id => organization.id, :temp_parent_type => organization.class.name) | 25 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org1, :temp_parent_id => organization.id, :temp_parent_type => organization.class.name) |
26 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org2, :temp_parent_id => organization.id, :temp_parent_type => organization.class.name) | 26 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :target => org2, :temp_parent_id => organization.id, :temp_parent_type => organization.class.name) |
27 | 27 | ||
28 | - assert_includes SubOrganizationsPlugin::ApprovePaternityRelation.pending_children(organization), org1 | ||
29 | - assert_includes SubOrganizationsPlugin::ApprovePaternityRelation.pending_children(organization), org2 | ||
30 | - assert_not_includes SubOrganizationsPlugin::ApprovePaternityRelation.pending_children(organization), org3 | 28 | + assert_includes Organization.pending_children(organization), org1 |
29 | + assert_includes Organization.pending_children(organization), org2 | ||
30 | + assert_not_includes Organization.pending_children(organization), org3 | ||
31 | end | 31 | end |
32 | end | 32 | end |
plugins/sub_organizations/test/unit/sub_organizations_plugin/approve_paternity_test.rb
@@ -11,7 +11,7 @@ class SubOrganizationsPlugin::ApprovePaternityTest < ActiveSupport::TestCase | @@ -11,7 +11,7 @@ class SubOrganizationsPlugin::ApprovePaternityTest < ActiveSupport::TestCase | ||
11 | should 'create relation after creation' do | 11 | should 'create relation after creation' do |
12 | org1 = fast_create(Organization) | 12 | org1 = fast_create(Organization) |
13 | org2 = fast_create(Organization) | 13 | org2 = fast_create(Organization) |
14 | - assert_difference SubOrganizationsPlugin::ApprovePaternityRelation, :count, 1 do | 14 | + assert_difference 'SubOrganizationsPlugin::ApprovePaternityRelation.count', 1 do |
15 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name, :target => org2) | 15 | SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name, :target => org2) |
16 | end | 16 | end |
17 | end | 17 | end |
@@ -21,9 +21,9 @@ class SubOrganizationsPlugin::ApprovePaternityTest < ActiveSupport::TestCase | @@ -21,9 +21,9 @@ class SubOrganizationsPlugin::ApprovePaternityTest < ActiveSupport::TestCase | ||
21 | org2 = fast_create(Organization) | 21 | org2 = fast_create(Organization) |
22 | 22 | ||
23 | task = SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name, :target => org2) | 23 | task = SubOrganizationsPlugin::ApprovePaternity.create!(:requestor => requestor, :temp_parent_id => org1.id, :temp_parent_type => org1.class.name, :target => org2) |
24 | - assert_not_includes SubOrganizationsPlugin::Relation.children(org1), org2 | 24 | + assert_not_includes Organization.children(org1), org2 |
25 | 25 | ||
26 | task.finish | 26 | task.finish |
27 | - assert_includes SubOrganizationsPlugin::Relation.children(org1), org2 | 27 | + assert_includes Organization.children(org1), org2 |
28 | end | 28 | end |
29 | end | 29 | end |
plugins/sub_organizations/test/unit/sub_organizations_plugin/ext/organization.rb
@@ -13,11 +13,11 @@ class OrganizationTest < ActiveSupport::TestCase | @@ -13,11 +13,11 @@ class OrganizationTest < ActiveSupport::TestCase | ||
13 | 13 | ||
14 | should 'relate organization with parent if the attribute is set' do | 14 | should 'relate organization with parent if the attribute is set' do |
15 | parent = fast_create(Organization) | 15 | parent = fast_create(Organization) |
16 | - organization = Organization.new(:identifier => 'some-org',:name => 'Some Org', :sub_organizations_plugin_parent_to_be => parent.id) | ||
17 | - assert_not_includes SubOrganizationsPlugin::Relation.children(parent), organization | 16 | + organization = build(Organization, :identifier => 'some-org',:name => 'Some Org', :sub_organizations_plugin_parent_to_be => parent.id) |
17 | + assert_not_includes Organization.children(parent), organization | ||
18 | 18 | ||
19 | organization.save! | 19 | organization.save! |
20 | - assert_includes SubOrganizationsPlugin::Relation.children(parent), organization | 20 | + assert_includes Organization.children(parent), organization |
21 | end | 21 | end |
22 | 22 | ||
23 | end | 23 | end |
plugins/sub_organizations/test/unit/sub_organizations_plugin/relation_test.rb
@@ -8,12 +8,12 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -8,12 +8,12 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
8 | 8 | ||
9 | relation.parent = org | 9 | relation.parent = org |
10 | relation.valid? | 10 | relation.valid? |
11 | - assert relation.errors.invalid?(:child) | 11 | + assert relation.errors.include?(:child) |
12 | 12 | ||
13 | relation.parent = nil | 13 | relation.parent = nil |
14 | relation.child = org | 14 | relation.child = org |
15 | relation.valid? | 15 | relation.valid? |
16 | - assert relation.errors.invalid?(:parent) | 16 | + assert relation.errors.include?(:parent) |
17 | end | 17 | end |
18 | 18 | ||
19 | should 'relate two organizations' do | 19 | should 'relate two organizations' do |
@@ -27,9 +27,9 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -27,9 +27,9 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
27 | 27 | ||
28 | should 'not allow self relation' do | 28 | should 'not allow self relation' do |
29 | org = fast_create(Organization) | 29 | org = fast_create(Organization) |
30 | - relation = SubOrganizationsPlugin::Relation.new(:parent_id => org, :child_id => org) | 30 | + relation = SubOrganizationsPlugin::Relation.new(:parent => org, :child => org) |
31 | assert !relation.valid? | 31 | assert !relation.valid? |
32 | - assert relation.errors.invalid?(:child) | 32 | + assert relation.errors.include?(:child) |
33 | end | 33 | end |
34 | 34 | ||
35 | should 'be able to retrieve parents of an organization' do | 35 | should 'be able to retrieve parents of an organization' do |
@@ -39,8 +39,8 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -39,8 +39,8 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
39 | SubOrganizationsPlugin::Relation.create!(:parent => parent1, :child => child) | 39 | SubOrganizationsPlugin::Relation.create!(:parent => parent1, :child => child) |
40 | SubOrganizationsPlugin::Relation.create!(:parent => parent2, :child => child) | 40 | SubOrganizationsPlugin::Relation.create!(:parent => parent2, :child => child) |
41 | 41 | ||
42 | - assert_includes SubOrganizationsPlugin::Relation.parents(child), parent1 | ||
43 | - assert_includes SubOrganizationsPlugin::Relation.parents(child), parent2 | 42 | + assert_includes Organization.parents(child), parent1 |
43 | + assert_includes Organization.parents(child), parent2 | ||
44 | end | 44 | end |
45 | 45 | ||
46 | should 'be able to retrieve children of an organization' do | 46 | should 'be able to retrieve children of an organization' do |
@@ -50,8 +50,8 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -50,8 +50,8 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
50 | SubOrganizationsPlugin::Relation.create!(:parent => parent, :child => child1) | 50 | SubOrganizationsPlugin::Relation.create!(:parent => parent, :child => child1) |
51 | SubOrganizationsPlugin::Relation.create!(:parent => parent, :child => child2) | 51 | SubOrganizationsPlugin::Relation.create!(:parent => parent, :child => child2) |
52 | 52 | ||
53 | - assert_includes SubOrganizationsPlugin::Relation.children(parent), child1 | ||
54 | - assert_includes SubOrganizationsPlugin::Relation.children(parent), child2 | 53 | + assert_includes Organization.children(parent), child1 |
54 | + assert_includes Organization.children(parent), child2 | ||
55 | end | 55 | end |
56 | 56 | ||
57 | should 'not allow cyclical reference' do | 57 | should 'not allow cyclical reference' do |
@@ -61,7 +61,7 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -61,7 +61,7 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
61 | relation = SubOrganizationsPlugin::Relation.new(:parent => org2, :child => org1) | 61 | relation = SubOrganizationsPlugin::Relation.new(:parent => org2, :child => org1) |
62 | 62 | ||
63 | assert !relation.valid? | 63 | assert !relation.valid? |
64 | - assert relation.errors.invalid?(:child) | 64 | + assert relation.errors.include?(:child) |
65 | end | 65 | end |
66 | 66 | ||
67 | should 'not allow multi-level paternity' do | 67 | should 'not allow multi-level paternity' do |
@@ -73,10 +73,10 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -73,10 +73,10 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
73 | r2 = SubOrganizationsPlugin::Relation.new(:parent => org3, :child => org1) | 73 | r2 = SubOrganizationsPlugin::Relation.new(:parent => org3, :child => org1) |
74 | 74 | ||
75 | assert !r1.valid? | 75 | assert !r1.valid? |
76 | - assert r1.errors.invalid?(:child) | 76 | + assert r1.errors.include?(:child) |
77 | 77 | ||
78 | assert !r2.valid? | 78 | assert !r2.valid? |
79 | - assert r2.errors.invalid?(:child) | 79 | + assert r2.errors.include?(:child) |
80 | end | 80 | end |
81 | 81 | ||
82 | should 'add children' do | 82 | should 'add children' do |
@@ -86,11 +86,11 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -86,11 +86,11 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
86 | org4 = fast_create(Organization) | 86 | org4 = fast_create(Organization) |
87 | 87 | ||
88 | SubOrganizationsPlugin::Relation.add_children(org1,org2) | 88 | SubOrganizationsPlugin::Relation.add_children(org1,org2) |
89 | - assert_includes SubOrganizationsPlugin::Relation.children(org1), org2 | 89 | + assert_includes Organization.children(org1), org2 |
90 | 90 | ||
91 | SubOrganizationsPlugin::Relation.add_children(org1,org3,org4) | 91 | SubOrganizationsPlugin::Relation.add_children(org1,org3,org4) |
92 | - assert_includes SubOrganizationsPlugin::Relation.children(org1), org3 | ||
93 | - assert_includes SubOrganizationsPlugin::Relation.children(org1), org4 | 92 | + assert_includes Organization.children(org1), org3 |
93 | + assert_includes Organization.children(org1), org4 | ||
94 | end | 94 | end |
95 | 95 | ||
96 | should 'remove children' do | 96 | should 'remove children' do |
@@ -101,10 +101,10 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | @@ -101,10 +101,10 @@ class SubOrganizationsPlugin::RelationTest < ActiveSupport::TestCase | ||
101 | SubOrganizationsPlugin::Relation.add_children(org1,org2,org3,org4) | 101 | SubOrganizationsPlugin::Relation.add_children(org1,org2,org3,org4) |
102 | 102 | ||
103 | SubOrganizationsPlugin::Relation.remove_children(org1,org2) | 103 | SubOrganizationsPlugin::Relation.remove_children(org1,org2) |
104 | - assert_not_includes SubOrganizationsPlugin::Relation.children(org1), org2 | 104 | + assert_not_includes Organization.children(org1), org2 |
105 | 105 | ||
106 | SubOrganizationsPlugin::Relation.remove_children(org1,org3,org4) | 106 | SubOrganizationsPlugin::Relation.remove_children(org1,org3,org4) |
107 | - assert_not_includes SubOrganizationsPlugin::Relation.children(org1), org3 | ||
108 | - assert_not_includes SubOrganizationsPlugin::Relation.children(org1), org4 | 107 | + assert_not_includes Organization.children(org1), org3 |
108 | + assert_not_includes Organization.children(org1), org4 | ||
109 | end | 109 | end |
110 | end | 110 | end |
plugins/sub_organizations/test/unit/sub_organizations_plugin_test.rb
@@ -29,7 +29,7 @@ class SubOrganizationsTest < ActiveSupport::TestCase | @@ -29,7 +29,7 @@ class SubOrganizationsTest < ActiveSupport::TestCase | ||
29 | 29 | ||
30 | org1_members = plugin.organization_members(org1) | 30 | org1_members = plugin.organization_members(org1) |
31 | 31 | ||
32 | - assert_equal ActiveRecord::NamedScope::Scope, org1_members.class | 32 | + assert_equal ActiveRecord::Relation, org1_members.class |
33 | assert_not_includes org1_members, member1 | 33 | assert_not_includes org1_members, member1 |
34 | assert_includes org1_members, member2 | 34 | assert_includes org1_members, member2 |
35 | assert_includes org1_members, member3 | 35 | assert_includes org1_members, member3 |
@@ -59,7 +59,7 @@ class SubOrganizationsTest < ActiveSupport::TestCase | @@ -59,7 +59,7 @@ class SubOrganizationsTest < ActiveSupport::TestCase | ||
59 | person1_memberships = plugin.person_memberships(person1) | 59 | person1_memberships = plugin.person_memberships(person1) |
60 | person2_memberships = plugin.person_memberships(person2) | 60 | person2_memberships = plugin.person_memberships(person2) |
61 | 61 | ||
62 | - assert_equal ActiveRecord::NamedScope::Scope, person1_memberships.class | 62 | + assert_equal ActiveRecord::Relation, person1_memberships.class |
63 | assert_includes person1_memberships, org1 | 63 | assert_includes person1_memberships, org1 |
64 | assert_not_includes person1_memberships, org2 | 64 | assert_not_includes person1_memberships, org2 |
65 | assert_not_includes person1_memberships, org3 | 65 | assert_not_includes person1_memberships, org3 |
plugins/sub_organizations/views/box_organizer/_related_organizations_block.html.erb
0 → 100644
@@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
1 | +<div id='edit-related-organizations-block'> | ||
2 | + <label for="block_organization_type"><%= _('Type of organizations to be displayed') %></label><br/> | ||
3 | + <%= select_tag('block[organization_type]', options_for_select([[_('Both'), 'both'], [_('Community'), 'community'], [_('Enterprise'), 'enterprise']], @block.organization_type)) %> | ||
4 | + <%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 3) %> | ||
5 | + <%= check_box(:block, :prioritize_profiles_with_image) %> | ||
6 | + <label for="block_prioritize_profiles_with_image"><%= _('Prioritize profiles with image') %></label> | ||
7 | +</div> |
plugins/sub_organizations/views/box_organizer/_related_organizations_block.rhtml
@@ -1,7 +0,0 @@ | @@ -1,7 +0,0 @@ | ||
1 | -<div id='edit-related-organizations-block'> | ||
2 | - <label for="block_organization_type"><%= _('Type of organizations to be displayed') %></label><br/> | ||
3 | - <%= select_tag('block[organization_type]', options_for_select([[_('Both'), 'both'], [_('Community'), 'community'], [_('Enterprise'), 'enterprise']], @block.organization_type)) %> | ||
4 | - <%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 3) %> | ||
5 | - <%= check_box(:block, :prioritize_profiles_with_image) %> | ||
6 | - <label for="block_prioritize_profiles_with_image"><%= _('Prioritize profiles with image') %></label> | ||
7 | -</div> |
plugins/sub_organizations/views/sub_organizations_plugin_myprofile/index.html.erb
@@ -9,10 +9,10 @@ | @@ -9,10 +9,10 @@ | ||
9 | </ul> | 9 | </ul> |
10 | <% end %> | 10 | <% end %> |
11 | 11 | ||
12 | -<% form_tag do %> | 12 | +<%= form_tag do %> |
13 | <% button_bar do %> | 13 | <% button_bar do %> |
14 | - <%= button(:add, __('Create a new sub-community'), :controller => 'memberships', :action => 'new_community', :profile => user.identifier, :sub_organizations_plugin_parent_to_be => profile.id) %> | ||
15 | - <%= button :add, __('Register a new sub-enterprise'), :controller => 'enterprise_registration', :sub_organizations_plugin_parent_to_be => profile.id if environment.enabled?('enterprise_registration') %> | 14 | + <%= button(:add, _('Create a new sub-community'), :controller => 'memberships', :action => 'new_community', :profile => user.identifier, :sub_organizations_plugin_parent_to_be => profile.id) %> |
15 | + <%= button :add, _('Register a new sub-enterprise'), :controller => 'enterprise_registration', :sub_organizations_plugin_parent_to_be => profile.id if environment.enabled?('enterprise_registration') %> | ||
16 | <% end %> | 16 | <% end %> |
17 | 17 | ||
18 | <p><%= _('Fill in the search field to find the groups that should be added as sub-group of this organization:') %></p> | 18 | <p><%= _('Fill in the search field to find the groups that should be added as sub-group of this organization:') %></p> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
0 → 100644
@@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
1 | +<% extend SubOrganizationsPlugin::SearchHelper %> | ||
2 | +<div class="related-organizations-list-block"> | ||
3 | + | ||
4 | + <h1><%= _("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | ||
5 | + <ul> | ||
6 | + <% organizations.each do |organization| %> | ||
7 | + <li class="related-organizations-item"> | ||
8 | + <div class="related-organizations-item"> | ||
9 | + <div class="related-organizations-item-column-left"> | ||
10 | + <%= profile_image_link organization, :big, 'div' %> | ||
11 | + </div> | ||
12 | + <div class="related-organizations-item-column-right"> | ||
13 | + <%= link_to_homepage(organization.name, organization.identifier, :class => "search-result-title") %> | ||
14 | + <div class="related-organizations-description"> | ||
15 | + <% if organization.description %> | ||
16 | + <% body_stripped = strip_tags(organization.description) %> | ||
17 | + <% elsif organization.home_page and organization.home_page.body %> | ||
18 | + <% body_stripped = strip_tags(organization.home_page.body) %> | ||
19 | + <% end %> | ||
20 | + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> | ||
21 | + </div> | ||
22 | + <div class="related-organizations-region"> | ||
23 | + <span class="related-organizations-region-label"><%= _("City") %></span> | ||
24 | + <% if organization.region %> | ||
25 | + <span class="related-organizations-region-name"><%= city_with_state(organization.region) %></span> | ||
26 | + <% elsif organization.city and organization.state %> | ||
27 | + <span class="related-organizations-region-name"><%= "#{organization.city}, #{organization.state}" %></span> | ||
28 | + <% end %> | ||
29 | + </div> | ||
30 | + | ||
31 | + <div class="related-organizations-categorization"> | ||
32 | + <% organization.top_level_categorization.each do |parent, children| %> | ||
33 | + <div class="related-organizations-category-<%=parent.id%> related-organizations-category"> | ||
34 | + <span class="related-organizations-categorization-parent"><%= parent.name %></span> | ||
35 | + <span class="related-organizations-categorization-children"> | ||
36 | + <%= children.collect(&:name).join(', ') %> | ||
37 | + </span> | ||
38 | + </div> | ||
39 | + <% end %> | ||
40 | + </div> | ||
41 | + </div> | ||
42 | + | ||
43 | + <br class="clearfix" /> | ||
44 | + | ||
45 | + </div> | ||
46 | + </li> | ||
47 | + <% end %> | ||
48 | + </ul> | ||
49 | + | ||
50 | + <div id='pagination-related-organizations'> | ||
51 | + <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | ||
52 | + </div> | ||
53 | + | ||
54 | + <% button_bar(:class => "related-organizations-button-bar") do %> | ||
55 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | ||
56 | + <%= button :add, _("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | ||
57 | + | ||
58 | + <% if !@full %> | ||
59 | + <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ||
60 | + <% end %> | ||
61 | + <% end %> | ||
62 | + | ||
63 | +</div> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.rhtml
@@ -1,63 +0,0 @@ | @@ -1,63 +0,0 @@ | ||
1 | -<% extend SubOrganizationsPlugin::SearchHelper %> | ||
2 | -<div class="related-organizations-list-block"> | ||
3 | - | ||
4 | - <h1><%= __("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | ||
5 | - <ul> | ||
6 | - <% organizations.each do |organization| %> | ||
7 | - <li class="related-organizations-item"> | ||
8 | - <div class="related-organizations-item"> | ||
9 | - <div class="related-organizations-item-column-left"> | ||
10 | - <%= profile_image_link organization, :big, 'div' %> | ||
11 | - </div> | ||
12 | - <div class="related-organizations-item-column-right"> | ||
13 | - <%= link_to_homepage(organization.name, organization.identifier, :class => "search-result-title") %> | ||
14 | - <div class="related-organizations-description"> | ||
15 | - <% if organization.description %> | ||
16 | - <% body_stripped = strip_tags(organization.description) %> | ||
17 | - <% elsif organization.home_page and organization.home_page.body %> | ||
18 | - <% body_stripped = strip_tags(organization.home_page.body) %> | ||
19 | - <% end %> | ||
20 | - <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> | ||
21 | - </div> | ||
22 | - <div class="related-organizations-region"> | ||
23 | - <span class="related-organizations-region-label"><%= _("City") %></span> | ||
24 | - <% if organization.region %> | ||
25 | - <span class="related-organizations-region-name"><%= city_with_state(organization.region) %></span> | ||
26 | - <% elsif organization.city and organization.state %> | ||
27 | - <span class="related-organizations-region-name"><%= "#{organization.city}, #{organization.state}" %></span> | ||
28 | - <% end %> | ||
29 | - </div> | ||
30 | - | ||
31 | - <div class="related-organizations-categorization"> | ||
32 | - <% organization.top_level_categorization.each do |parent, children| %> | ||
33 | - <div class="related-organizations-category-<%=parent.id%> related-organizations-category"> | ||
34 | - <span class="related-organizations-categorization-parent"><%= parent.name %></span> | ||
35 | - <span class="related-organizations-categorization-children"> | ||
36 | - <%= children.collect(&:name).join(', ') %> | ||
37 | - </span> | ||
38 | - </div> | ||
39 | - <% end %> | ||
40 | - </div> | ||
41 | - </div> | ||
42 | - | ||
43 | - <br class="clearfix" /> | ||
44 | - | ||
45 | - </div> | ||
46 | - </li> | ||
47 | - <% end %> | ||
48 | - </ul> | ||
49 | - | ||
50 | - <div id='pagination-related-organizations'> | ||
51 | - <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | ||
52 | - </div> | ||
53 | - | ||
54 | - <% button_bar(:class => "related-organizations-button-bar") do %> | ||
55 | - <%= button :back, _('Go back'), { :controller => 'profile' } %> | ||
56 | - <%= button :add, __("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | ||
57 | - | ||
58 | - <% if !@full %> | ||
59 | - <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ||
60 | - <% end %> | ||
61 | - <% end %> | ||
62 | - | ||
63 | -</div> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_related_organizations.html.erb
0 → 100644
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +<div class="common-profile-list-block"> | ||
2 | + <h1><%= _("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | ||
3 | + | ||
4 | + <ul class='profile-list'> | ||
5 | + <% organizations.each do |organization| %> | ||
6 | + <%= profile_image_link(organization)%> | ||
7 | + <% end %> | ||
8 | + </ul> | ||
9 | + <% if organizations.length == 0 %> | ||
10 | + <li><%= _("There are no sub-#{organization_type.pluralize} yet. " ) %></li> | ||
11 | + <% end %> | ||
12 | + <% button_bar(:class => "related-organizations-button-bar") do %> | ||
13 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | ||
14 | + <%= button :add, _("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | ||
15 | + | ||
16 | + <% if !@full %> | ||
17 | + <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ||
18 | + <% end %> | ||
19 | + <% end %> | ||
20 | +</div> | ||
21 | +<% if @full %> | ||
22 | + <div id='pagination-profiles'> | ||
23 | + <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | ||
24 | + </div> | ||
25 | +<% end %> | ||
26 | +<!-- fim class="common-profile-list-block" --> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_related_organizations.rhtml
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -<% extend SubOrganizationsPlugin::ApplicationHelper %> | ||
2 | -<div class="common-profile-list-block"> | ||
3 | - <h1><%= __("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | ||
4 | - | ||
5 | - <ul class='profile-list'> | ||
6 | - <% organizations.each do |organization| %> | ||
7 | - <%= profile_image_link(organization)%> | ||
8 | - <% end %> | ||
9 | - </ul> | ||
10 | - <% if organizations.length == 0 %> | ||
11 | - <li><%= __("There are no sub-#{organization_type.pluralize} yet. " ) %></li> | ||
12 | - <% end %> | ||
13 | - <% button_bar(:class => "related-organizations-button-bar") do %> | ||
14 | - <%= button :back, _('Go back'), { :controller => 'profile' } %> | ||
15 | - <%= button :add, __("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | ||
16 | - | ||
17 | - <% if !@full %> | ||
18 | - <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ||
19 | - <% end %> | ||
20 | - <% end %> | ||
21 | -</div> | ||
22 | -<% if @full %> | ||
23 | - <div id='pagination-profiles'> | ||
24 | - <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | ||
25 | - </div> | ||
26 | -<% end %> | ||
27 | -<!-- fim class="common-profile-list-block" --> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/related_organizations.html.erb
0 → 100644
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +<% extend SubOrganizationsPlugin::SearchHelper %> | ||
2 | +<% extend SubOrganizationsPlugin::RelationHelper %> | ||
3 | + | ||
4 | +<div id="search-actions"> | ||
5 | + <%= display_selectors(params[:display]) %> | ||
6 | +</div> | ||
7 | + | ||
8 | +<% if params[:type] == 'community' %> | ||
9 | + <%= display_relation(@communities,params[:type],params[:display]) %> | ||
10 | +<% end %> | ||
11 | + | ||
12 | +<% if params[:type] == 'enterprise' %> | ||
13 | + <%= display_relation(@enterprises,params[:type],params[:display]) %> | ||
14 | +<% end %> | ||
15 | + | ||
16 | +<% if ["full"].include?(params[:display]) and !params[:type] %> | ||
17 | + <%= display_relation(@total,"organizations",params[:display]) %> | ||
18 | +<% elsif !params[:type] %> | ||
19 | + <%= display_relation(@communities,"community",params[:display]) %> | ||
20 | + <%= display_relation(@enterprises,"enterprise",params[:display]) %> | ||
21 | +<% end %> |
plugins/sub_organizations/views/sub_organizations_plugin_profile/related_organizations.rhtml
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -<% extend SubOrganizationsPlugin::SearchHelper %> | ||
2 | -<% extend SubOrganizationsPlugin::RelationHelper %> | ||
3 | - | ||
4 | -<div id="search-actions"> | ||
5 | - <%= display_selectors(params[:display]) %> | ||
6 | -</div> | ||
7 | - | ||
8 | -<% if params[:type] == 'community' %> | ||
9 | - <%= display_relation(@communities,params[:type],params[:display]) %> | ||
10 | -<% end %> | ||
11 | - | ||
12 | -<% if params[:type] == 'enterprise' %> | ||
13 | - <%= display_relation(@enterprises,params[:type],params[:display]) %> | ||
14 | -<% end %> | ||
15 | - | ||
16 | -<% if ["full"].include?(params[:display]) and !params[:type] %> | ||
17 | - <%= display_relation(@total,"organizations",params[:display]) %> | ||
18 | -<% elsif !params[:type] %> | ||
19 | - <%= display_relation(@communities,"community",params[:display]) %> | ||
20 | - <%= display_relation(@enterprises,"enterprise",params[:display]) %> | ||
21 | -<% end %> |