File tree Expand file tree Collapse file tree 3 files changed +49
-13
lines changed
Expand file tree Collapse file tree 3 files changed +49
-13
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,14 @@ class PostsController < ApplicationController
66 def index
77 context = model . active . of_active_members
88
9- if current_organization . present?
10- context = context . where (
11- organization_id : current_organization . id
12- )
9+ if current_user . present? && current_organization . present?
10+ if params [ :show_allied ] . present?
11+ allied_org_ids = current_organization . allied_organizations . pluck ( :id )
12+ org_ids = [ current_organization . id ] + allied_org_ids
13+ context = context . by_organizations ( org_ids )
14+ elsif !params [ :org ] . present?
15+ context = context . by_organization ( current_organization . id )
16+ end
1317 end
1418
1519 posts = apply_scopes ( context )
@@ -98,15 +102,6 @@ def post_params
98102 end
99103 end
100104
101- # TODO: remove this horrible hack ASAP
102- #
103- # This hack set the current organization to the post's
104- # organization, both in session and controller instance variable.
105- #
106- # Before changing the current organization it's important to check that
107- # the current_user is an active member of the organization.
108- #
109- # @param organization [Organization]
110105 def update_current_organization! ( organization )
111106 return unless current_user && current_user . active? ( organization )
112107
Original file line number Diff line number Diff line change @@ -84,6 +84,12 @@ def rejected_alliances
8484 source_alliances . rejected . or ( target_alliances . rejected )
8585 end
8686
87+ def allied_organizations
88+ source_org_ids = source_alliances . accepted . pluck ( :target_organization_id )
89+ target_org_ids = target_alliances . accepted . pluck ( :source_organization_id )
90+ Organization . where ( id : source_org_ids + target_org_ids )
91+ end
92+
8793 def ensure_reg_number_seq!
8894 update_column ( :reg_number_seq , members . maximum ( :member_uid ) )
8995 end
Original file line number Diff line number Diff line change 3737 </ ul >
3838 </ li >
3939 </ ul >
40+ < < < < < < < HEAD
41+ =======
42+ < ul class ="nav navbar-nav d-none d-sm-flex ">
43+ < li class ="dropdown nav-item ">
44+ < a class ="dropdown-toggle nav-link text-primary " href ="# " data-bs-toggle ="dropdown " role ="button " aria-expanded ="false ">
45+ <%= selected_org ? selected_org . name : t ( "activerecord.models.organization.other" ) %>
46+ </ a >
47+ < ul class ="dropdown-menu " role ="menu ">
48+ < li >
49+ <%
50+ query_params = { }
51+ query_params [ :show_allied ] = true
52+ query_params [ :cat ] = params [ :cat ] if params [ :cat ] . present?
53+ link_path = "#{ base_path } ?#{ query_params . to_query } "
54+ %>
55+ <%= link_to "× #{ t ( 'global.all' ) } " , link_path , class : "dropdown-item" %>
56+ </ li >
57+ <% allied_organizations . each do |org | %>
58+ <% next if org . id . to_s == params [ :org ] %>
59+ < li >
60+ <%
61+ query_params = { }
62+ query_params [ :org ] = org . id
63+ query_params [ :cat ] = params [ :cat ] if params [ :cat ] . present?
64+ link_path = "#{ base_path } ?#{ query_params . to_query } "
65+ %>
66+ <%= link_to link_path , class : "dropdown-item" do %>
67+ <%= org . name %>
68+ <% end %>
69+ </ li >
70+ <% end %>
71+ </ ul >
72+ </ li >
73+ </ ul >
74+ > > > > > > > 66663daa (refactor code)
4075 </ form >
4176</ div>
You can’t perform that action at this time.
0 commit comments