ref: master
plugins/sub_organizations/controllers/sub_organizations_plugin_profile_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
class SubOrganizationsPluginProfileController < ProfileController append_view_path File.join(File.dirname(__FILE__) + '/../views') before_filter :organizations_only def children children = Organization.children(profile) family_relation(children) render 'related_organizations' end def parents parents = Organization.parentz(profile) family_relation(parents) render 'related_organizations' end private def family_relation(_profile) @communities = _profile.communities @enterprises = _profile.enterprises @full = true if !params[:type] and !params[:display] @communities = SubOrganizationsPlugin.limit(@communities) @enterprises = SubOrganizationsPlugin.limit(@enterprises) @full = false elsif !params[:type] @total = _profile @total = @total.paginate(:per_page => 12, :page => params[:npage]) if params[:display] == 'compact' @full = false end else @communities = @communities.paginate(:per_page => 12, :page => params[:npage]) @enterprises = @enterprises.paginate(:per_page => 12, :page => params[:npage]) end end def organizations_only render_not_found if !profile.organization? end end |